# GIF-Screencast-OSX performance testing

I was disappointed with the color and quality that ffmpeg's GIF conversion gives.
Imagemagick's convert can also be used to do the conversion, though this has serious performance penalties.

The following details my experiments of converting a 3.8 second movie to a GIF.

## FFMPEG to PNG -> CONVERT to GIF individually

 * 42 seconds in CONVERT, did not determine file size

```
ffmpeg -i in-trimmed.mov -r 10 -vcodec png out-static-%02d.png 
time for img in out-static*.png; do convert -verbose +dither -layers Optimize "$img" "$img.gif" ;  done
```

## FFMPEG to PNG -> CONVERT TO GIF in bulk

 * 70KB filesize; 7.2 seconds in CONVERT
 * http://dl-web.dropbox.com/u/29440342/screenshots/CTHVGY-Screencast-2013.02.06-18.03.gif

```
ffmpeg -i in-trimmed.mov -r 10 -vcodec png out-static-%02d.png 
time convert -verbose +dither -layers Optimize -resize 600x600\> out-static*.png  GIF:- > out13.gif
```

## FFMPEG to PNG -> CONVERT to GIF in bulk -> gifsicle

 * 56KB size; 7.2 seconds in CONVERT
 * http://dl-web.dropbox.com/u/29440342/screenshots/USNVKN-Screencast-2013.02.06-18.13.gif

```
ffmpeg -i in-trimmed.mov -r 10 -vcodec png out-static-%02d.png 
time convert -verbose +dither -layers Optimize -resize 600x600\> out-static*.png  GIF:- | gifsicle --colors 128 --delay=5 --loop --optimize=3 --multifile - > out12.gif
```

## FFMPEG to PPM -> CONVERT to GIF in bulk

 * 6.7 seconds in CONVERT, 70KB filesize
 * http://dl-web.dropbox.com/u/29440342/screenshots/ZMMDMX-Screencast-2013.02.06-17.59.gif

```
ffmpeg -i in-trimmed.mov -r 10 -vcodec ppm out-static-%02d.ppm
time convert -verbose +dither -layers Optimize -resize 600x600\> out-static*.ppm  GIF:- > out14.gif
```

## FFMPEG to PPM -> CONVERT to GIF in bulk -> gifsicle

 * 7.2 seconds in CONVERT, 56KB filesize
 * http://dl-web.dropbox.com/u/29440342/screenshots/UGTQNY-Screencast-2013.02.06-17.49.gif

```
time ffmpeg -i  in-trimmed.mov -r 10 -f image2pipe -vcodec ppm - |  time convert -verbose +dither -layers Optimize -resize 600x600\> - gif:- | gifsicle --colors 128 --delay=5 --loop --optimize=3 --multifile ->  out15.gif
```

## FFMPEG to GIF -> gifsicle

 * 1 second total (not using CONVERT), 22KB filesize
 * http://dl-web.dropbox.com/u/29440342/screenshots/XVXWCJ-Screencast-2013.02.06-17.48.gif

```
ffmpeg -i in-trimmed.mov -vf "scale=min(iw\,600):-1" -pix_fmt rgb24 -r 10 -f gif - | gifsicle --optimize=3 --delay=7 --colors 128 > out16.gif
```

## Notes

* Omitting resizing down to 600x600 before converting to GIF dramatically slows down CONVERT.
* PPM is the only image format that is compatible with FFMPEG piping directly to CONVERT
  * it has the same performance and compression characteristics as outputting to PNG
  * it avoids creating and cleaning up temporary image files
  * otherwise the temporary files would need to be sorted by numeric order before globbing
  
## Resources

* http://www.imagemagick.org/discourse-server/viewtopic.php?f=2&t=18320#reading-multiple-images-over-standard-input
* http://superuser.com/questions/71028/batch-converting-png-to-jpg-in-linux
* http://zeekish.wordpress.com/2011/09/14/pdf-to-gif-conversion-and-optimization/
* http://stackoverflow.com/questions/3306888/ffmpeg-generate-n-evenly-spaced-png-screenshots
* http://mariovalle.name/postprocessing/ImageTools.html#gifsicle
* http://ffmpeg-users.933282.n4.nabble.com/Converting-avi-files-to-animated-gifs-td935274.html
* https://lists.libav.org/pipermail/ffmpeg-user/2010-August/026860.html
* http://stackoverflow.com/questions/8133242/ffmpeg-resize-down-larger-video-to-fit-desired-size-and-add-padding
* http://superuser.com/questions/318845/improve-quality-of-ffmpeg-created-jpgs