Skip to content

Instantly share code, notes, and snippets.

@Emuentes
Last active June 24, 2020 17:45
Show Gist options
  • Save Emuentes/48aa25ffca6e086922abc74fea3cedcd to your computer and use it in GitHub Desktop.
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)
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