Last active
June 24, 2020 17:45
-
-
Save Emuentes/48aa25ffca6e086922abc74fea3cedcd to your computer and use it in GitHub Desktop.
Bash Function to convert an MOV file into an animated gif (great for adding a small animated clip of new functionality to a Pull Request)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function convertMovToGif | |
{ | |
pathToSourceFile=$1 | |
pathToSourceFileDirectory=$(dirname "${pathToSourceFile}") | |
fileName=$(basename "${pathToSourceFile}") | |
filenameWithoutExtension="${fileName%.*}" | |
nameToSaveFileAs="$2" | |
generatedFilePath="$pathToSourceFileDirectory/${nameToSaveFileAs:-$filenameWithoutExtension-generated}.gif" | |
echo "*************************************" | |
echo "-----VIDEO TO GIF - INPUT DATA-------" | |
echo "*************************************" | |
echo "filenameWithoutExtension: $filenameWithoutExtension" | |
echo "generatedFilePath: $generatedFilePath" | |
echo "pathToSourceFile: $pathToSourceFile" | |
echo "nameToSaveFileAs: $nameToSaveFileAs" | |
echo "pathToSourceFileDirectory: $pathToSourceFileDirectory" | |
echo "fileName: $fileName" | |
echo "" | |
echo "*************************************" | |
# EXAMPLE CORRECT INPUTS | |
# ffmpeg \ | |
# -i '/Users/whoeverYouAre/Documents/PR_Visual_Content/WTF-392.mov'\ | |
# -r 15\ | |
# -vf scale=1024:-1\ | |
# '/Users/whoeverYouAre/Documents/PR_Visual_Content/WTF-392-scaled.gif' | |
# DYNAMIC INPUTS | |
ffmpeg \ | |
-i $pathToSourceFile\ | |
-r 12\ | |
-vf scale=1024:-1\ | |
$generatedFilePath | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment