32

如何检查视频文件的关键帧间隔?

我在 ffmpeg 输出中只能看到:

  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
4

2 回答 2

67

您可以显示每个帧的时间戳,ffprobeawk输出关键帧信息。适用于 Linux 和 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}'

或者一种适用于任何操作系统且不需要awk或类似附加处理工具的较慢方法:

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

结果:

0.000000
2.502000
3.795000
6.131000
10.344000
12.554000
16.266000
17.559000
...

有关更多信息,请参阅ffprobe文档

于 2013-08-06T18:48:27.643 回答
3

以下命令将为您提供视频中所有关键帧的偏移量

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

请注意,该命令可能会响应迟一些。有耐心 :-)

ffprobe命令以 CSV 格式为您提供帧级别的详细信息。Rest 是cutgrep命令的巧妙组合。

cut -d ',' -f4

过滤第四列 - 这指的是 'key_frame' 标志。

grep -n 1

仅过滤关键帧,并在 CSV 提要中显示它们的行号。

stdbuf -oL

withcut命令操作 cut 命令的缓冲区。

于 2017-06-20T08:42:02.003 回答