I recorded a video, and thought it would be easier to upload as an animated gif. I decided to look at ffmpeg and see if it can create animated gifs, and it can.
In this post I explain how.
Since I created a video, I thought I’d try and figure out how to use ffmpeg to convert the video to an animated gif.
The simplest command to create an animated gif would be:
ffmpeg -i video.mov animated.gif
But this will create a gif file with the same dimensions as the movie and will convert every frame of video, so it might actually end up larger file size than the movie.
Instead, we want to control the x and y dimensions to make it easier to re-use on the web. And we don’t need 30 or 60 frames per second in the gif, usually we can get away with about 5, and sometimes as low as 1 or 2.
All of this helps keep the file size lower.
To convert a video file
video.mov to an animated gif with 5 frames per second and sized to 450 by (whatever height is proportionally correct for that x value)
ffmpeg -i video.mov -vf fps=5,scale=450:-1 animated.gif
ffmpeg will detect your movie type so you should be able to use ‘.mpg’, ‘.mp4’ without changing the command.