Linux/Unix/macOS
Following @LordNeckbeard approach with ffmpeg
command, please find the following useful Bash function which can be added into your ~/.bash_profile
file:
# Convert video to gif file.# Usage: video2gif video_file (scale) (fps)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"}
Once the function is loaded (manually or from . ~/.bash_profile
), you should have new video2gif
command.
Example usage:
video2gif input.flv
or:
video2gif input.flv 320 10
Scale to 320 width with 10 frames per second.
You can also specify a different video format (such as mp4).
macOS
You can try GIF Brewery app which can create GIFs from video files.
Alternatively there are several websites which are doing conversion online free of charge.