1
I need to convert a series of images to gifs.
I found three broad ways to do this. One involving ImageMagick, One involving gifsicle and another involving avconv.
I can't use Imagemagick because it's a lot slower than any of the other methods. I can't use gifsicle because it cannot work with "png" files. I could convert the PNGs to gifs with ImageMagick's 'mogrify' command and then bring them together into a single gif with gifsicle, but this would involve slowing things down with mogrify which is a deal-breaker for my case.
I've found out how to do what I need with avconv, but for some reason the resulting gif has double the frame rate.
This is the command I'm using:
avconv -i frame%15d.png -s qvga -vf format=rgb8,format=rgb24 -pix_fmt rgb24 -r 10 output.gif
And the output with that:
avconv version 9.13-6:9.13-0ubuntu0.14.04.1, Copyright (c) 2000-2014 the Libav developers
built on May 9 2014 13:34:03 with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
Input #0, image2, from 'frame%15d.png':
Duration: 00:00:12.04, start: 0.000000, bitrate: N/A
Stream #0.0: Video: png, rgb24, 320x240, 25 fps, 25 tbr, 25 tbn
File 'output.gif' already exists. Overwrite ? [y/N] y
Output #0, gif, to 'output.gif':
Metadata:
encoder : Lavf54.20.3
Stream #0.0: Video: rawvideo, rgb24, 320x240, q=2-31, 200 kb/s, 90k tbn, 10 tbc
Stream mapping:
Stream #0:0 -> #0:0 (png -> rawvideo)
Press ctrl-c to stop encoding
frame= 121 fps= 0 q=0.0 Lsize= 10406kB time=12.10 bitrate=7044.8kbits/s
video:27225kB audio:0kB global headers:0kB muxing overhead -61.779245%
There's 301 images meant to last 30 seconds which is why I'm forcing a framerate of 10. It seems to be ignoring that though.
If I also force the input frame rate with "-r 10" the resulting gif lasts for 60 seconds at half my desired framerate.
Command with FPS forced in both input and output:
avconv -r 10 -i frame%15d.png -s qvga -vf format=rgb8,format=rgb24 -pix_fmt rgb24 -r 10 output2.gif
And the output:
avconv version 9.13-6:9.13-0ubuntu0.14.04.1, Copyright (c) 2000-2014 the Libav developers
built on May 9 2014 13:34:03 with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
Input #0, image2, from 'frame%15d.png':
Duration: 00:00:12.04, start: 0.000000, bitrate: N/A
Stream #0.0: Video: png, rgb24, 320x240, 25 fps, 25 tbr, 25 tbn
Output #0, gif, to 'output2.gif':
Metadata:
encoder : Lavf54.20.3
Stream #0.0: Video: rawvideo, rgb24, 320x240, q=2-31, 200 kb/s, 90k tbn, 10 tbc
Stream mapping:
Stream #0:0 -> #0:0 (png -> rawvideo)
Press ctrl-c to stop encoding
frame= 301 fps=270 q=0.0 Lsize= 25884kB time=30.10 bitrate=7044.5kbits/s
video:67725kB audio:0kB global headers:0kB muxing overhead -61.780963%
I have no idea what I'm doing wrong right now and would appreciate someone's input.
Alternatively, if someone knows a quick way to convert a batch of PNGs to individual gifs without using ImageMagick, I can then bring them together with gifsicle.
1Please include the full, uncut command line output – slhck – 2014-05-13T09:03:16.943
Sorry about that. Added it now. – Nikhil – 2014-05-13T11:11:13.967