Relação Ametódica

Data Science, Machine Learning, Artificial Intelligence, Visualization, and Complex Systems.

Bash function to convert Video to GIF with ffmpeg

Just add this to your .profile or place it in some function script and source it.

video2gif() {   
    ffmpeg -y -i "${1}" -vf fps=${3:-10},scale=${2:-320}:-1:flags=lanczos,palettegen "${1}.png";   
    ffmpeg -i "${1}" -i "${1}.png" -filter_complex "fps=${3:-10},scale=${2:-320}:-1:flags=lanczos[x];[x][1:v]paletteuse" "${1}".gif;   
    rm "${1}.png"; 
}

There is no simple mnemonic to memorize when converting video, so it is clearly better to have this function somewhere to be able to use like:

video2gif input.mov