I've used FFmpeg to extract all the I-frames from a MKV/MP4 file but FFmpeg seems to decode all frames to do it, so it takes a very long time if the video file is 1080p and longer than 10 minutes. I only want it to jump from I-frame to I-frame and dump them out to JPG/PNG files. Also, I need to know the timestamp of the I-frame.

The other option was to use FFprobe to get timestamps for all the I-frames, but that also decodes the whole file.

I'm trying to do something similar to Avidemux. In Avidemux you can step to each I-frame very fast by just pressing the up or down arrow keys, but it does so without decode all the B/P frames.

1 Answer 1



ffmpeg -skip_frame nokey -i file -vsync 0 -frame_pts true out%d.png

skip_frame tells the decoder to process only keyframes. -vsync 0 (in this command) preserves timestamps. -frame_pts sets the numeral portion of the output image filename to represent the timestamp. The interpretation of the number requires you to know the framerate e.g. if the framerate is 30 then an image name of out75 corresponds to a timestamp of 75/30 = 2.50 seconds. You can add -r 1000 if you want numbers to represent milliseconds.

  • Please, may you explain the relationship between the use of -r option here and the scale unit of the output index in this particular use case ? Besides -vsync 0 and -r 1000 produce a red warning Using -vsync 0 and -r can produce invalid output files and in theory i expected it to mean the contrary of each other ; therefore i wish to be sure it will not break something.
    – Link-akro
    Dec 19, 2020 at 17:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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