To this date, the GIMP can export to GIF and WEBP animations. But what about video formats? We are not there yet, but ImageMagick and FFMPEG can help us. Warning: contains rent againt GIMP animation support.
The need: OBS Studio animations
Why would you want to export animations in video formats in the first place? Well, video recording and streaming software like OBS Studio does not support animated WebP images as a media input.
There is still the possibility of using the old GIF format for that, but the quality is going to be degraded for images with a lot of colors. APNG and MNG are not supported either as animated inputs.
This leaves us with a few video formats for importing our videos into OBS:
However, it seems that using compressed codecs may have some overhead during playback, at least for WebM that does not seem to have hardware decoding. This may be different for MP4.
I did not want to take the risk and went to the old battle-tested MOV format for my experiment.
GIMP animations are just layers
GIMP has a very basic support of animation playback, in the form of displaying and masking layers or adding them on each other. Given the look of this web page, you can guess that the support for animations is not a priority nor has seen big changes in the last years:
After creating an animation, you have a lot of layers that represent the different frames.
Exporting layers is hard!
Since the GIMP is not able to export in any video format, we will just have to create one using FFMPEG by combining all of the layers ourselves. But wait! The GIMP has no way to export all layers!
This is a known issue from a long time. There is a plugin that is supposed to fix that, but it does not appear in the GIMP's plugin manager interface. As I did not want to spend time figuring how to install plugins manually, I went the hard way: exporting to MNG.
MNG is not widely used and even its support in the GIMP is partial. It is based on putting together a bunch of PNG files, and was eventually replaced by APNG, which GIMP only support by an outdated plugin. So we will use MNG to export our animation, even if no software can play it back. ¯_(ツ)_/¯
The MNG exporter does not show us any progress bar, so we have to wait. WebP does provide a progress bar, but it is way slower than MNG at exporting since it compresses more — even when lossless is activated — and there is no way to tell it to not compress that much in the export window:
Converting MNG to MOV and MP4
Now that the MNG image is generated, we can extract the layers using ImageMagick:
$ convert animation.mng frame%03d.png
This results in many files being created as excepted: be sure to run this command inside of a dedicated directory.
And regroup the frames using FFMPEG into a MOV and MP4 clip at the desired framerate:
$ ffmpeg -r 30 -i frame%03d.png out.mov $ ffmpeg -r 30 -i frame%03d.png out.mp4
I will use the MOV file into OBS in order to not make the CPU load too much, but I guess I could also use MP4 inside of OBS if the decoding is not that slow.
Here is the result:
It boggles my mind that GIMP is not able to natively export layers as distinct images. I guess next time I will try the plugin — or you can do it and come back to me with your results!