【发布时间】:2020-05-16 00:24:43
【问题描述】:
尝试识别一组视频中关键帧的缩略图和时间戳,我从ffmpeg 和ffprobe 得到不同的结果。
需要 1 分钟。以长视频为例:
youtube-dl -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/mp4' 'https://www.youtube.com/watch?v=BHlAlN3z4ss' --output "test.mp4"
1/ 我提取缩略图并在图像上写下提取它的时间戳:
ffmpeg -i test.mp4 -q:v 2 -vf select="eq(pict_type\,PICT_TYPE_I)","drawtext=fontfile=/path/to/Arial.ttf:fontsize=45:fontcolor=yellow:box=1:boxcolor=black:x=(W-tw)/2:y=H-th-10:text='Time\: %{pts\:hms}'" -vsync 0 thumbs/preview%05d.jpg
2/ 我提取并保存所有关键帧的时间戳:
ffprobe -v error -skip_frame nokey -show_entries frame=pkt_pts_time -select_streams v -of csv=p=0 test.mp4 | sort -n > keyframes_timestamps.txt
3/ 对比结果,我发现ffprobe 找到了 29 个关键帧,而ffmpeg 只找到了 32 个。手动比较,我们可以看到 `ffprobe` 没有检测到特定的关键帧,而大多数非常相似。
ffprobe_ts ffmpeg_ts
0.000000 00:00:00.00
5.366667 00:00:05.367
7.200000 00:00:07.200
8.666667 00:00:08.667
10.100000 00:00:10.100
11.500000 00:00:11.500
14.233333 00:00:14.233
15.333333 00:00:15.333
17.366667 00:00:17.367
NO_TS 00:00:18.833
20.800000 00:00:20.800
24.533333 00:00:24.533
25.700000 00:00:25.700
26.033333 00:00:26.033
在较大的视频中,大约不到 5% 的关键帧会发生这种情况。
我找不到关于这个的解释,有人知道吗?或者关于我应该在哪里/什么进一步询问的建议?
感谢您的帮助!
【问题讨论】:
标签: ffmpeg video-processing ffprobe