rlh   img   mp3   nfo   pro  
./nfo/linux/imagemagick.animated.gif.nfo
Create an animated GIF from a series of captured frames.
1. Capture the sequence with mplayer.

   Capture 50 PNG frames from 5 seconds into video.mp4:
   # mplayer video.mp4 -fps 1 -vo png -ss 5 -frames 50

2. Convert and scale the PNG sequence to 320px wide GIFs:

   # for i in *.png ; do convert -scale 320 "$i" "${i%.*}.gif" ; done

3. Why not delete every second GIF frame to save space:

   Careful with batch deletes! Test with this:
   # ls *.gif | awk 'NR % 2 == 1 { print }'

   ...to see what you can expect, before this:
   # ls *.gif | awk 'NR % 2 == 1 { print }' | xargs rm -f

4. Assemble the animated GIF.

   The delay value controls the animation speed,
   loop value '0' will loop the animation forever:
   # convert -delay 20 -loop 0 *.gif animated.gif

5. Reference:

   ImageMagick v6 Examples:
   Animation Optimization
   Video to GIF, Optimization Summary 

A. Notes

   # convert animated.gif -ordered-dither o8x8,8,8,4 +map -fuzz 15% \
     -colors 32 -coalesce -layers optimize animated2.gif
EOF