I have a folder full of videos that I want to convert to an animated gifs. ffmpeg/avconv does a bad job of doing it directly, so I instead convert the video to a gif by first outputting each frame as a png and then converting back to gif using imagemagick. The problem is that this results in a large gif in terms of file size. To solve this I want to "drop" every second or nth frame from the gif, either by skipping every image file when converting to a gif or by removing frames from a gif. How can I do this on Ubuntu (13.04) using imagemagick or some other command-line utility?
Using a bash script
To do this from the command line, you could use a utility called Gifsicle. There is no built in method to delete every other frame, so you'll need to get your hands dirty with some scripting.
Here is a quick script I made to do just a single GIF:
I tested it out with a simple countdown GIF:
And here is the result after running it through the script:
This script is of course not bulletproof, but it should lead you in the right direction.
This is not an open source or command line solution, but you can do this with Photoshop:
File ▸ Import ▸ Video Frames to Layers...
"Limit To Every __ Frames" will do the trick for you
Here's a simpler solution using gifsicle than JohnB's script:
This command should work in most Unix shells; I've tested it in bash. Replace