使用 ffprobe 进行切割检测

Cut detection with ffprobe

我正在尝试使用 ffprobe 检测镜头之间的剪辑。我使用以下命令:

ffprobe -show_frames -of compact=p=0 -f lavfi "movie=test_clip.avi,select=gt(scene\,.4)" > test_clip_cuts.txt

它工作得很好,毫无疑问。但现在我只想检测特定范围内的切割。比方说从 3 到 8 秒。我该怎么做?

我尝试使用 -read_intervals 3%8 但它给了我一个错误:

Could not seek to position 3000000: Invalid argument
Could not read packets in interval id:0 start:3 end:8

命令 -read_intervals %+3(从最开始读到第 3 秒)有效,但以一种奇怪的方式 - 它检测到第 4 秒(我猜甚至超过)的剪切。

所以我很困惑。那些 "intervals" 是什么以及如何使用它们?是否可以在常规秒内设置范围?

以防万一这是我的测试剪辑https://yadi.sk/i/nd-c12mYeQ2nb

终于找到答案了 =)
要仅检测 3 到 8 秒之间的切割,我必须更换

"movie=test_clip.avi,select=gt(scene\,.4)"

"movie=test_clip.avi,select=between(t\,3\,8)*gt(scene\,.4)"

看完libavfilter documentation, I found the best way to do this is with a combination of the movie seek_point option and the trim option

ffprobe -show_frames -of compact=p=0 -f lavfi "movie=test_clip.avi:seek_point=3,trim=3:8,select=gt(scene\,0.4)" > test_clip_cuts.txt

如果您希望使用开始时间和持续时间,可以使用语法 :seek_point=3,trim=3:duration=5

这仅对指定的视频部分运行 cut/scene 检测。使用 between 给出相同的输出,但仍然对整个视频运行检测,这对于大视频来说要慢得多。我似乎也找不到文档中任何地方提到的 between 。如果视频的目标部分接近开头,单独使用 trim 会很快,但随着视频的深入,速度会变慢。如果在与 seek_point 一起使用时 trim 选项中省略了 start 时间,检测似乎有时会比预期早大约一秒开始,可能是因为 seek_point 正在寻求最近的关键帧。