views:

301

answers:

2

I have some video that I would like to convert to images of frames every 2 sec.

E.g. If the video is 7 seconds long at 15 fps I would like to get frames 1, 31, 61, 91.

The command:

ffmpeg -i foo.mp4 -r 0.5 -f image2 -vcodec mjpeg foo%d.jpg

appears to do what I want, but which frame does it get? 1, 31, 61, 91 or 30, 60, 90 or 13, 43, 73, 103?

+1  A: 

The first image will be from the very first frame.

Note that you very well may get an image or two more that you expect. I believe this is because of rounding and/or that ffmpeg creates a final images. E.g.: Is your video really 7s long? Or is it 7.63s long?

Stu Thompson
In tests of ffmpeg, using it to make movies out of numbered images, it is consistent after the first few frames (e.g. grabbing every 60th), but for the first two second the grabbed frames were not evenly spaced...
Peter
A: 

I ended up doing the following largely borrowed from the ffmpeg tutorial:

ffmpeg -v 3 -vsync 0 -sameq -i movie.mpr  -f image2 "images-%03d.jpeg"

This gives me each frame of the movie as a JPEG numbered 1 to the end of the movie. I then filtered these files using a scripting language, knowing the frame rate was 30fps, to grab every 60th frame.

Peter