How to create movie on Android from images?

How can you create the smallest possible animated GIF from a series of images from the command line?

  • I am trying to create an animated gif movie of gameplay of a game I am developing. My code spits out a bunch of numbered screenshots: image_00000.png, image_00001.png, image_00002.png... I tried various techniques to create a gif, but so far the results are not good. I first just tried compiling the images using Imagemagick convert, but the resulting gif is the same size as the sum of input files. I assume the png files are just packed in there and are being decompressed on the fly. Then I tried mogrify, turned off dithering, set number of colours to 32, set optimise to 3, etc. But the colour quantisation and lack of dithering is awful, and the file is only slightly smaller anyway. The strange thing is, the output is slightly flickery, meaning that the whole image is encoded for each frame. In my movie, there are only a few sprites moving on a static background, so probably only 10% of the pixels are changing from frame to frame. I don't know much about the format, but I assumed gif used something like Run-Length-Encoding on the differences between frames for great compression. So far I haven't been able to get that. Is it just finding the correct combination of mogrify parameters, or do I need to use a specific tool?

  • Answer:

    That's how animated GIFs work. There's no compression of any sort. The GIF standard included switching between a series of images as a mechanism to present a slide-show of individual pictures. Each picture is included in its entirety. There is no compression other than the basic GIF image compression on each frame. There are no I/B/P-frames - it's not a video format. You might instead consider a video file format, of which there are many. They do incorporate video compression techniques and will result in much higher compression ratios, accurate frame rates, and better quality results.

James McInnes at Quora Visit the source

Was this solution helpful to you?

Other answers

GIF does not use RLE.  I suppose you should be able to coax Ffmpeg into producing a lossless RLE encoded AVI if you want that. However, the question was about animated GIFs. The main trick in order to achieve more compression of a GIF-animation than the sum of individual PNGs is to convert the pixles which have not changed between frames into 'transparency'.  ImageMagic can do that for you.  Try:  convert -delay 20 image_*.png -coalesce -layers Optimize animation.gif There are a myriad of options which could help reduce final animation size with or without information loss, but their use is very dependent on the characteristics of the source images.

Frode Tennebø

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.