How can I convert a video file to a sequence of images, for example one frame every N seconds. Can mplayer or ffmpeg do this? I have used MPlayer to grab screenshots manually but I would like to automate this for a long video.

link|improve this question

67% accept rate
feedback

7 Answers

Short version:

ffmpeg -itsoffset -4 -i test.avi -vcodec mjpeg -vframes 1 -an -f rawvideo -s 320x240 test.jpg

This command generates a 320×240 sized PNG thumbnail at the 4th second in the video. Put this in a script that changes the time and file name and you're done .

Long version: http://blog.prashanthellina.com/2008/03/29/creating-video-thumbnails-using-ffmpeg/

link|improve this answer
This seems to do what I want, but with one problem. It will process the file from the start on each iteration, getting exponentially slow. – Liam Apr 27 '10 at 14:42
@Liam - Does it help if you leave the offset time alone (set it at 1) and use the -ss position flag to seek further into the file instead? -ss Seek to given time position in seconds. hh:mm:ss[.xxx] syntax is also supported – Nifle Apr 29 '10 at 7:53
@liam: put the -ss before the -i so that the seek happens before the input video gets decoded. this should speed it up. source – quack quixote Apr 29 '10 at 17:03
feedback
up vote 2 down vote accepted
mplayer -vo jpeg -sstep 5 file.avi

will save a frame as a jpeg file every 5 seconds.

However, it will not stop at the end of the file, it will continue producing copies of the last frame. To avoid this, find the duration of the video in seconds (using another player) and subtract 2, and use this value for the -endposoption. For example, for a 147 second video:

mplayer -vo jpeg -sstep 5 -endpos 145 file.avi
link|improve this answer
this sounds like an mplayer bug. nice workaround. – quack quixote Apr 29 '10 at 17:04
feedback

If

$ mplayer -vo help | grep JPEG

finds something, you can use it to dump the video into a sequence of jpg files.

link|improve this answer
feedback

You can skip frames in VirtualDub. Just use "Decimate By" option located at Video -> Frame Rate menu. For example if you set "Decimate By 100" then use File -> Export -> Image sequence, it will save only every 100th frame.

link|improve this answer
feedback

Media Player Classic (MPC) can do this, too.

link|improve this answer
feedback

You could also try this

from the VLC command line...

vlc "C:\YOUR\file\path\file.avi" -V image --image-out-prefix=capname --image-out-ratio=60

file.avi is the video you want to capture from, capname is the prefix of the saved images, you might want to play around with the ratio (60 means that 1 out of 60 images is captured) You can add more commands, for example --image-out-format jpeg will save your caps as jpegs instead of of pngs, --snapshot-path lets you choose where to save your caps.

Source of above

link|improve this answer
I got this message: The command line options couldn't be loaded, check that they are valid. – Liam Apr 28 '10 at 9:45
On Ubuntu, I got this message: unknown option or missing mandatory argument `--image-out-prefix=capname' – Liam Apr 28 '10 at 9:54
feedback

VirtualDub can do this for you

File -> Export -> Image sequence

enter image description here

link|improve this answer
Will this save every frame as an image? – Liam Apr 27 '10 at 15:32
yes, every frame. – Shevek Apr 27 '10 at 16:25
I need to skip most frames, outputting all frames will use up too much storage space. I need just one frame every few seconds. – Liam Apr 28 '10 at 9:56
feedback

Your Answer

 
or
required, but never shown

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