Skip to content

Instantly share code, notes, and snippets.

@tucan9389
Created March 10, 2020 06:30
Show Gist options
  • Save tucan9389/5984e4a55e3ed0a44468530a20927d42 to your computer and use it in GitHub Desktop.
Save tucan9389/5984e4a55e3ed0a44468530a20927d42 to your computer and use it in GitHub Desktop.
convert videos to gifs with ffmpeg
width="400"
fps="12"
for path in "$@"
do
echo "$path"
# path setup
video_path=$path
directory_path=`dirname "$path"`
file=`basename "$path"`
extension="${file##*.}"
filename="${file%.*}"
echo $extension
gif_path="${video_path%.*}.gif"
echo $gif_path
ffmpeg -y -i $video_path -vf fps=$fps,scale=$width:-1:flags=lanczos,palettegen palette.png;
ffmpeg -y -i $video_path -i palette.png -filter_complex "fps=$fps,scale=$width:-1:flags=lanczos[x];[x][1:v]paletteuse" $gif_path;
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment