Search code examples
ffmpegkeyframe

Video Keyframe and Iframe


I have confused one thing for Video Frame extraction.

I have sample.mp4 video, 15FPS.

I tried extracting Keyframe with FFMPEG.

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

I get 29 Pictures and I believe I have got 29 I frames. (If I have wrong, Please correct me)

Then I tried extracting specific timeline(10 sec) frame with picture

ffmpeg -i sample.mp4 -ss 00:00:10 -frames:v 1 test1.png

This output picture, I can not find same one among my Keyframes I get.

Question: test1.png, What is frame type? Does it one of P or B frame not I?


Solution

  • I get 29 Pictures and I believe I have got 29 I frames. (If I have wrong, Please correct me)

    Correct. See Checking keyframe interval? to verify.

    Question: test1.png, What is frame type? Does it one of P or B frame not I ?

    Use ffprobe:

    ffprobe -select_streams v -show_entries "frame=pkt_pts_time,pict_type" -of csv input.mp4
    

    Example output:

    frame,9.968000,B
    frame,10.010000,B <---
    frame,10.052000,P
    

    Note that in this example -ss 00:00:10 rounded up to the nearest frame (10.010000). This is a B-frame in this example (input.mp4).