简体   繁体   English

FFMPEG 场景检测:叠加原始帧号

[英]FFMPEG scene detection: overlay original frame number

I'm able to extract all frames that are not similar to the previous frame from a video file using ffmpeg -i video.mp4 -vf "select=gt(scene\,0.003),setpts=N/(30*TB)" frame%d.jpg ( source )我可以使用ffmpeg -i video.mp4 -vf "select=gt(scene\,0.003),setpts=N/(30*TB)" frame%d.jpg从视频文件中提取与前一帧不相似的所有帧ffmpeg -i video.mp4 -vf "select=gt(scene\,0.003),setpts=N/(30*TB)" frame%d.jpg ( 来源)

I would like to overlay the frame number onto each selected frame.我想将帧号覆盖到每个选定的帧上。 I tried adding drawtext=fontfile=/Windows/Fonts/Arial.ttf: text='frame\: %{frame_num}': x=(w-tw)/2: y=h-(2*lh): fontcolor=white: box=1: boxcolor=0x00000000@1: fontsize=30 to the filter after select and setpts, however %{frame_num} returns 1, 2, 3, ... ( source )我尝试添加drawtext=fontfile=/Windows/Fonts/Arial.ttf: text='frame\: %{frame_num}': x=(w-tw)/2: y=h-(2*lh): fontcolor=white: box=1: boxcolor=0x00000000@1: fontsize=30到 select 和 setpts之后的过滤器,但是 %{frame_num} 返回1, 2, 3, ... ( source )

If I put drawtext before select and setpts, I get something like 16, 42, 181, ... as frame numbers (which is exactly what I want), but since the scene detection runs after adding the text overlay, changes in the overlay may be detected as well.如果我将 drawtext 放在 select 和 setpts之前,我会得到类似 16、42、181 16, 42, 181, ...作为帧号(这正是我想要的),但由于在添加文本覆盖运行场景检测,覆盖中的变化也可能被检测到。

Is it possible to do the scene detection and overlay independently from another?是否可以独立于另一个进行场景检测和叠加? [in] split [out0][out1] can be used to apply filters separately, but I don't know how to "combine" the results again. [in] split [out0][out1]可用于单独应用过滤器,但我不知道如何再次“组合”结果。

You are on the right track.你在正确的轨道上。 Use split first to create two streams.先使用 split 创建两个流。 Run scene detection on one, and draw text on another.在一个上运行场景检测,在另一个上绘制文本。 Then use overlay to paint the numbered stream on the pruned stream - only the corresponding pruned numbered frames will be emitted.然后使用覆盖在修剪后的 stream 上绘制编号的 stream - 只会发出相应的修剪后的编号帧。

ffmpeg -i video.mp4 -vf "split=2[num][raw];[raw]select=gt(scene\,0.003)[raw];[num]drawtext=fontfile=/Windows/Fonts/Arial.ttf: text='frame\: %{frame_num}': x=(w-tw)/2: y=h-(2*lh): fontcolor=white: box=1: boxcolor=0x00000000@1: fontsize=30[num];[raw][num]overlay=shortest=1,setpts=N/(30*TB)" -r 30 frame%d.jpg

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM