Skip to content

Instantly share code, notes, and snippets.

@kkweon
Last active May 22, 2017 20:33
Show Gist options
  • Select an option

  • Save kkweon/170a455f173f507595b7e1fed108ee86 to your computer and use it in GitHub Desktop.

Select an option

Save kkweon/170a455f173f507595b7e1fed108ee86 to your computer and use it in GitHub Desktop.
Convert video to a high quality gif file using FFMPEG and Bash
#!/usr/bin/env bash
input_video=$1
echo "Input Video: $input_video"
if [ -z "$1" ]; then
read input_video
fi
echo "Skip Second: "
read skip_second
echo "Duration: "
read duration
echo "FPS: "
read fps
echo "Scale: "
read scale
echo "Output gif filename (example: output.gif): "
read output
ffmpeg -y -ss $skip_second -t $duration -i $input_video -vf fps=$fps,scale=$scale:-1:flags=lanczos,palettegen palette.png
ffmpeg -ss $skip_second -t $duration -i $input_video -i palette.png -filter_complex "fps=$fps,scale=$scale:-1:flags=lanczos[x];[x][1:v]paletteuse" $output
rm palette.png
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment