Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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.)

share|improve this question
add comment

2 Answers 2

up vote 3 down vote accepted

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.

share|improve this answer
add comment

Also started out with ffmpeg but @slm beat me to it :)

Anyheuw, you could also use mplayer to do a quick and simple dump. E.g.:

mplayer -nosound -ss 45:00 -endpos 15:00 -vo png:z=7 -sstep 30 your_vid.mp4
  • -ss is start possition.
  • -endpos is duaration.
  • -vo takes output driver. Use mplayer -vo help to get a list. Many distros also have tab completion on most of the mplayer options: mplayer -voTabTab
  • -sstep 30 means step 30 seconds between each frame.

Start and endpos takes:

<[[hh:]mm:]ss[.ms]|size[b|kb|mb]>

There is a lot of calculations and buffering going on so not 100% exact, but often close enough.


It also have a gif89a driver, but quality is not the best (compared to dumping images, converting with convert and compiling video with e.g. gifsicle). You could of course play with it. More suited to make short cuts from movies as avatar like gif's:

mplayer -ao null -ss 10:00 -endpos 5 -vo gif89a:fps=5.3 -vf palette,softskip,scale=240:135 videofile.ext

You can then also specify output file by typically:

-vo gif89a:fps=4.9:output=sample.gif

Very on the side, not related at all, but to show the range of -vo, is the ASCII format:

mplayer -vo aa -monitorpixelaspect 0.5 video.mp4

maximize output window and take 5 steps back.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.