Program for taking snap-shots of movie

animationimagesvideo

Are there any programs that would let me specify parts of a video-file (avi, mpeg, mp4, …) and take "snap-shots" every so-and-so second/minute, and store it as a series of image-files (eg. jpeg)? For example select part of a movie between 0h45m and 1h00m, and take a "snap-shot" every 30 second.

It may be part of or a plug-in for a video-player (eg. VLC)… the point is that I need something that takes snap-shots automatically, not maually.

Further more, are there any good programs for turning such a series of image-files into an animated-GIF or-PNG file? (It would of course be a bonus if the snap-shot program could optionally save the snaps as animated GIF/PNG.)

Best Answer

You can use ffmpeg to do this. There are several examples over on the ffmpeg website.

Here are a few of them:

  1. This will create one thumbnail image every minute, named img001.jpg, img002.jpg, img003.jpg, ... (%03d means that ordinal number of each thumbnail image should be formatted using 3 digits)

    $ ffmpeg -i myvideo.avi -f image2 -vf fps=fps=1/60 img%03d.jpg
    
  2. This will create one thumbnail image every 10 minutes, named thumb0001.bmp, thumb0002.bmp, thumb0003.bmp, ...

    $ ffmpeg -i test.flv -f image2 -vf fps=fps=1/600 thumb%04d.bmp
    

If you want to make them into a short video you can again enlist the help of ffmpeg. It's discussed on this page of their website.

Here are a few more examples:

  1. Here, each image will have a duration of 5 seconds (the inverse of 1/5 frames per second). By telling FFmpeg to set the input file's FPS option (frames per second) to some very low value, we made FFmpeg duplicate frames at the output and thus we achieved to display each image for some time on screen:

    $ ffmpeg -f image2 -r 1/5 -i img%03d.png -c:v libx264 -r 30 out.mp4
    
  2. If you don't have images numbered and ordered in series (img001.jpg, img002.jpg, img003.jpg) but rather random bunch of images, ffmpeg also supports bash-style globbing (* represents any number of any characters):

    $ ffmpeg -f image2 -r 1 -pattern_type glob -i '*.jpg' -c:v libx264 out.mp4
    

or for png images:

    $ ffmpeg -f image2 -r 1 -pattern_type glob -i '*.png' -c:v libx264 out.mp4

To make the resulting video into an animated gif you could use the steps outlined int his SO Q&A titled: How to generate gif from avi using ffmpeg?:

$ ffmpeg -i video.avi -t 10 out%02d.gif

then:

$ gifsicle --delay=10 --loop *.gif > anim.gif

Here's the link to the tool gifsicle.

Related Question