How does this look?
3 MB in size.
What I found out:
The simplest way to make a GIF from a video is to use ffmpeg with no switches like this
ffmpeg -i input.vid output.gif
However you will run into trouble if the video is long or high resolution (or both) because it will attempt to use every frame and leave the height and width unaltered. I tried it with the original Youtube video and ffmpeg eventually froze at which point the output GIF had reached nearly 1 gigabyte in size. If you want a GIF you can host online you will have to abide by file size limits.
So my first thought was, let's skip some frames! You can do this with the skip_frame
switch. I thought, why not skip all the non-key frames? Most video compression algorithms work by having periodic 'key frames' which are encoded in full and then just encoding the changes since the last frame, until the scene has changed enough to warrant writing a new key frame. (When the differences become so big that the compression ratio becomes poor). As the key frames are where the original video encoder decided the image has changed, they might be interesting frames to include in the GIF.
So we include the skip_frame switch and the parameter is no_key
, i.e. please skip the non-key frames (there are other things you can do like skip every nth frame etc)
Also image size reduction is good, so let's shrink it down to something reasonable. The original video as I downloaded it is HD, that is 1920 x 1080. That's crazily big for an animated GIF. Around 240 pixels high is common. Keeping the aspect ratio of the original gives us 422 x 240.
Thus the -s switch for output size:
Put these together:
ffmpeg -skip_frame nokey -i input.mp4 -ss 00:00:00.000 -s 422x240 -t 04:16.000 output.gif