Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
705 views
in Technique[技术] by (71.8m points)

ffmpeg - Checking keyframe interval?

How can I check keyframe interval of a video file?

all I can see in ffmpeg output is:

  Metadata:
    metadatacreator : Yet Another Metadata Injector for FLV - Version 1.8
    hasKeyframes    : true
    hasVideo        : true
    hasAudio        : true
    hasMetadata     : true
    canSeekToEnd    : true
    datasize        : 256600272
    videosize       : 210054362
    audiosize       : 45214634
    lasttimestamp   : 5347
    lastkeyframetimestamp: 5347
    lastkeyframelocation: 256649267
  Duration: 01:29:07.24, start: 0.040000, bitrate: 383 kb/s
    Stream #0:0: Video: h264 (High), yuv420p, 720x304 [SAR 1:1 DAR 45:19], 312 kb/s, 25 tbr, 1k tbn, 50 tbc
    Stream #0:1: Audio: mp3, 44100 Hz, mono, s16p, 64 kb/s
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...