Checking keyframe interval?

前端 未结 2 1740
傲寒
傲寒 2020-12-14 02:19

How can I check keyframe interval of a video file?

all I can see in ffmpeg output is:

  Metadata:
    metadatacreator : Yet Another Metadata Injector         


        
相关标签:
2条回答
  • 2020-12-14 02:48

    The following command will give you the offsets of all key Frames in the Video

    ffprobe -show_frames -select_streams v:0 \
            -print_format csv Video.mov 2> /dev/null |
    stdbuf -oL cut -d ',' -f4 |
    grep -n 1 |
    stdbuf -oL cut -d ':' -f1
    

    Note that the command might respond a little late. Have patience :-)

    The ffprobe command gives you the frame level details in CSV format. Rest is a smart combination of cut and grep commands.

    cut -d ',' -f4
    

    filters the fourth column - this refers to the 'key_frame' flag.

    grep -n 1
    

    filters the key-frames only, and shows their line numbers in the CSV feed.

    The

    stdbuf -oL
    

    with the cut command manipulates the buffer of the cut command.

    0 讨论(0)
  • 2020-12-14 02:58

    You can display the timestamp for each frame with ffprobe with awk to only output key frame info. Works in Linux and macOS.

    ffprobe -loglevel error -select_streams v:0 -show_entries packet=pts_time,flags -of csv=print_section=0 input.mp4 | awk -F',' '/K/ {print $1}'
    

    Or a slower method that works on any OS and does not require awk or similar additional processing tools:

    ffprobe -loglevel error -skip_frame nokey -select_streams v:0 -show_entries frame=pkt_pts_time -of csv=print_section=0 input.mp4
    

    Results:

    0.000000
    2.502000
    3.795000
    6.131000
    10.344000
    12.554000
    16.266000
    17.559000
    ...
    

    See the ffprobe documentation for more info.

    0 讨论(0)
提交回复
热议问题