FFmpeg: Convert video to gif

nabbisen - May 14 '21 - - Dev Community

FFmpeg provides simple usage to convert video such as .mkv, .mp3, .mp4, .mov to .gif.

ffmpeg -i <input.video> out.gif
Enter fullscreen mode Exit fullscreen mode

That's it.

Well, the file size of out.gif is sometimes a bit too big. In such a case, it's better to use -r option to specify frame rate.

ffmpeg -i my-sample.mkv -r 10 out.gif
Enter fullscreen mode Exit fullscreen mode

With -r 10, my sample video file got 20% smaller. With -r 5 or less, it would be much smaller.

The official documentation on video options is here.

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .