Created
June 22, 2018 22:40
-
-
Save jhallard/6011379d02b6d2b936f7f3445517a962 to your computer and use it in GitHub Desktop.
How to encode a gif from a video file using ffmpeg at a specific resolution and bitrate
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
gifenc () | |
{ | |
palette="/tmp/palette.png"; | |
filters="fps=$4,scale=$3:-1:flags=lanczos"; | |
ffmpeg -v warning -i $1 -vf "$filters,palettegen" -y $palette; | |
ffmpeg -v warning -i $1 -i $palette -lavfi "$filters [x]; [x][1:v] paletteuse" -y $2 | |
} | |
# use like this to encode /tmp/video.mp4 to /tmp/output.gif at 240p and 12fps | |
# $ gifenc /tmp/video.mp4 /tmp/output.gif 240 12 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment