Many of the questions asking how to create an animated gif from a set of png images suggest to use a variant of ImageMagick's convert
command:
convert -delay 2 -loop 0 *.png animated.gif
However, I have a few thousand images and thus convert
uses up all my memory, swap, and then crashes. What alternative software exists, which is more memory-conscious? I could use another open format if .gif
is not supported, and I do prefer a CLI tool.
Best Answer
It sounds like you're trying to make a video. If that's the case, then I'd use a proper video format.
In this case, I'd use ffmpeg to convert the individual PNG files to a H.264 video. Since ffmpeg is made to work with videos that can be hours long, it should have no problem with your thousands of images. Using H.264 instead of animated gif will result in a vast improvement in image quality.
Something like this should work for you:
-framerate 1/2
: This sets the framerate to one-half FPS, or 2 seconds per frame.-i img%04d.png
: This tells ffmpeg to read the filesimg0000.png
thoughimg9999.png
.-c:v libx264
: Use video codec libx264.-crf <number>
: Quality setting. 0 to 51. 23 is the default. 0 is true lossless encoding, which will be quite high bandwidth. 18 is nearly visually lossless.-r 30
: Set the output framerate to 30 FPS. Each of the input images will be duplicated to make the output what you specify here. You can leave this parameter off, and the output file will be at the input framerate, but the resulting movie didn't display properly when I tried it just now.out.mp4
: Output filename.References: