2

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.

3

Use

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.

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.