Last active
May 22, 2017 20:33
-
-
Save kkweon/170a455f173f507595b7e1fed108ee86 to your computer and use it in GitHub Desktop.
Convert video to a high quality gif file using FFMPEG and Bash
This file contains hidden or 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
| #!/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