2

I extracted all frames in a video using ffmpeg -i video.mp4 test_3/0%d.jpg.

Then I tried to extract specific frames using ffmpeg -i video.mp4 -vframes 1 -vf "fps=24,select=eq(n\,221)" x.jpg.

But I get a different frame then the one extracted in the first command.

I used the same fps as ffmpeg printed in the first command in the output info:

Output #0, image2, to 'x.jpg':
  Metadata:
    Stream #0:0(und): Video: mjpeg, yuvj420p(pc), 1920x1080, q=2-31, 200 kb/s, 24 fps, 24 tbn, 24 tbc (default)

Why is there a mismatch in the frames? How can I extract only specific frames, that will be the same to the first command?

2

1 Answer 1

1

The image2 muxer is a constant frame rate muxer, so ffmpeg will duplicate frames if your source is variable frame rate. To ensure a 1:1 correspondence between frames and images, set -vsync 0

ffmpeg -i video.mp4 -vsync 0 test_3/0%d.jpg

Then to extract a particular frame,

ffmpeg -i video.mp4 -vframes 1 -vf "select=eq(n\,221)" -vsync 0 x.jpg

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .