Convert a series of PNGs to an animated gif or video file
Solution 1:
If you want to convert an image sequence into an animated .gif, the easiest way is via ImageMagick's convert
command:
convert -delay 5 -layers Optimize $FILE_LIST foo.gif
The above command combines all of the files into an optimized animated .gif with a 5 millisecond frame time. You can also do more complicated things with timing via something like:
convert -layers Optimize -delay 5 frame1.png frame2.png -delay 10 frame3.png animation.gif
which gives a 5ms delay for frame1 and frame2, and a 10ms delay for frame3.
Solution 2:
If you're concerned about quality, don't convert to GIF.
To create a video, you can use ffmpeg
:
ffmpeg -f image2 -i 'image%d.png' -vcodec copy out.mkv
-f image2 -i 'image%d.png'
tells ffmpeg
to read the PNG images image1.png
, image2.png
, etc. in sequence. -vcodec copy
losslessly stores the images in a video stream. The resulting video is playable in vlc
or totem
.
Since the image data is just copied, this will be very fast and of course lossless.
(See "How do I encode single pictures into movies?" in ffmpeg's docs.)