You can optimize the PDF animation for size using differential bitmaps and the timeline feature of the animate package.
Note however, that with every new animation frame to be shown the number of differential frames that needs to be re-displayed increases by one. This may slow down a running animation as time advances. Adobe Reader was not primarily optimized for graphical rendering speed. For long bitmap sequences, it may therefore be better to produce a video file (MP4/H.264) and embed this one with the media9 package.
If you still want to animate differential bitmap sequences, proceed as follows:
(1) Create a size optimized version of the original animated gif using gifsicle:
gifsicle -O3 animated.gif > optimized.gif
For testing purposes you could try this animated gif from the asymptote web site: http://asymptote.sourceforge.net/gallery/animations/wheel.gif
(2) Produce a PNG sequence (difference-0.png, difference-1.png, ...) of image differences, using the the ungif.sh script listed below. The script writes the timeline to be used with \animategraphics to standard output which is redirected into the text file timeline.txt:
ungif.sh optimized.gif difference.png > timeline.txt
(3) The PDF with the animated sequence can be produced from the following LaTeX source file (The max. frame number and perhaps the frame rate will need to be adjusted):
\documentclass{article}
\usepackage{animate}
\begin{document}
\noindent\animategraphics[
controls,
width=0.5\linewidth,
timeline=timeline.txt
]{10}{difference-}{0}{99} %adjust the maximum frame number
\end{document}
(4) Before viewing the animation in Adobe Reader, make sure that 'Smooth images' in the Reader settings (Edit->Preferences->Page Display) is un-checked. Otherwise you get ugly artifacts.
Contents of Bash script ungif.sh (requires ImageMagick):
#!/bin/bash
wxh=$(identify -format '%Wx%H' $1[0])
fs=$(identify -format %n $1)
for (( i=0; i<$fs; i++ ))
do
convert -page $wxh ${1}[$i] -matte -background none -layers coalesce -quality 90 ${2/./-$i.}
echo "::${i}x0"
done
animate, but only manually. – nickpapior Apr 07 '13 at 13:49gifsicledoes. We can usegifsiclefor producing a size-optimzed bitmap sequence to be used here. And the timeline feature is needed, as in your answer; thanks for the link! – AlexG Apr 08 '13 at 10:53