ffgif() { p="fps=10,scale=${4:-320}:-1:flags=lanczos"; ffmpeg -y -ss ${2:-0} -i "$1" -to ${3:-0} -vf ${p},palettegen -loglevel error .p.png \ && ffmpeg -ss ${2:-0} -i "$1" -i .p.png -to ${3:-0} -loglevel error -filter_complex "${p}[x];[x][1:v]paletteuse" "${1%.*}".gif \ && rm .p.png; }
Requires ffmpeg to be installed. Here is a nicer layout of the command:
ffgif() { p="fps=10,scale=${4:-320}:-1:flags=lanczos"; ffmpeg -y -ss ${2:-0} -i "$1" -to ${3:-0} -vf ${p},palettegen -loglevel error .p.png \ && ffmpeg -ss ${2:-0} -i "$1" -i .p.png -to ${3:-0} -loglevel error -filter_complex "${p}[x];[x][1:v]paletteuse" "${1%.*}".gif \ && rm .p.png;}
This command takes up to 4 arguments. Hereβs a quick example:
ffgif my_video.mp4 00:00:10 00:00:20 720
In short, it takes my_video.mp4
, starts the gif encoding at timestamp 00:00:10, and encodes until 00:00:20
with the scale 720. Higher scale means higher resolution.
Useful for a quick gif of a video!