47

I have a video and I want to extract 35-th frame out of this video.

I want it to be a png image if possible.

I know there are a lot of questions like this, but I could not find a solution that was using frame number.

2 Answers 2

64

Use the select filter:

ffmpeg -i <input> -vf "select=eq(n\,34)" -vframes 1 out.png

counting starts at 0, so 35th = n value of 34.

5
  • On windows with cmd prompt don't use the quotes around select=[...] Good catch with ffmpeg though, I learn something every day :)
    – jiggunjer
    Commented Dec 8, 2015 at 1:14
  • Also for those interested, this produces the exact same frame as using a calculated time with hexagesimal time format. Tested on a 10.1 second uncompressed video with 300 frames (29.97fps). Time seeked was 00:00:01.17. Though this (the above) method is probably better for encoded formats or samples with high framerates.
    – jiggunjer
    Commented Dec 8, 2015 at 3:05
  • @jiggunjer Use " instead of ' in Windows. Also, 29.97 can be inaccurate. Use 30000/1001.
    – llogan
    Commented Dec 11, 2015 at 2:57
  • @Levan One more thing, it should be 34 in the command, counting starts at 0.
    – jiggunjer
    Commented Dec 17, 2015 at 9:03
  • Is it possible to count backwards from the end and get the last frame, the second to last frame, etc? Commented Sep 26, 2023 at 22:20
17

Two quick-and-dirty ways:

Use the FFmpeg executable with the seek option. You'll need to convert to a time first, e.g. if I want frame 150 and my video is 29.97 FPS the command will be ffmpeg -ss 00:00:05.01 -i myvideo.avi -frames:v 1 myimage.jpg. This might be slightly inaccurate. To seek by exact frame you'd need to use the FFmpeg library with C++.

Another 'hacky' way is using VLC media player. Check menu View -> Advanced controls. Pause video and click the Frame-by-frame button 34 times.

You must log in to answer this question.

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