For a few days I have been looking for alternatives to transform short screencasts into GIF images in order to show you some ideas on my blog. You know, an image is worth a thousand words.
I had the opportunity to play with these tools:
Asciinema I love it!, IMHO is the best way to record a command line session and share it with colleagues. Actually, I used it in my article Self-signed Https support and I will continue using it. In the other hand, you can’t record anything other than a terminal session but it’s the service they offer and it works great.
Peek is also great, but at the time of writing this article, in my Arch Linux didn’t work properly.
Giphy is amazing but I ruled it out because I don’t want my gifs to be hosted in a datacenter in the middle of nowhere.
The drawback with this technique is that you have to write magic spells in the command line to get desired results. If you are interested to read details about these magic spells, I recommend you to read High quality GIF with FFmpeg.
So I thought, it would be nice to create a Docker image that encapsulates all the complexity of this process and allows me to get the desired result without having to install FFmpeg or having to remember commands and complex parameters.
And that’s what I did, a container called kafebob/video2gif based on Linux Alpine with ffmpeg installed and all the necessary adjustments for a proper conversion from video to gif. This container is for x64 architecture, if anyone needs it for Raspberry Pi please let me know in the comments.
The container weighs 30MB and the Dockerfile of this container can be found here.
In order to transform your videos into gifs run the container like this
Also to make your life easier, just create an alias in your profile (
And then just call the transformation like this
Remember that you must have Docker installed and running.
Assuming your video is called
video.wmv and you want to transform it into a gif called
video.gif, you will have to run
After a few seconds you will get the desired gif.
The script also accept these options
-f <framerate>10 fps is the default and works well, but in many cases you can even get good results with lower framerates.
-y <yscale>480 px wide is the default and automatically determine the height while preserving the aspect ratio.
-s <skip_sec>0 is default and will skip the first N seconds of video.
-t <duration_sec>If specified creates a N second output.
From previous example if we do
It will generate a gif with the next specifications
- 30 frames per second.
- 320 pixels wide preserving the aspect ratio.
- Starts at second 10.
- 5 seconds long.
I’m going to create one gif using 10 fps, 480px width size, starting at 13 second and 3 seconds long.
And this is the result, a decent GIF of 3.4MB.
I hope it will be useful