给定帧上的ffmpeg drawbox

céd*_*ric 5 ffmpeg filter frame

我在视频中添加了数千个矩形框.现在我正在使用这个命令:

ffmpeg.exe -i small.ts -vf drawbox=10:10:50:50:red,drawbox=100:100:200:200:green small_with_box.ts
Run Code Online (Sandbox Code Playgroud)

但是我不希望在整个框架上添加框,而是在给定的框架上添加框.任何人都知道我该怎么做?

llo*_*gan 11

drawbox视频滤波器具有时间线编辑支持.您可以看到哪些过滤器支持时间轴编辑:

$ ffmpeg -filters
…
Filters:
  T. = Timeline support
  .S = Slice threading
  A = Audio input/output
  V = Video input/output
  N = Dynamic number and/or type of input/output
  | = Source or sink filter
…
 .. deshake          V->V       Stabilize shaky video.
 T. drawbox          V->V       Draw a colored box on the input video.
 T. drawgrid         V->V       Draw a colored grid on the input video.
Run Code Online (Sandbox Code Playgroud)

您可以看到drawboxdrawgrid拥有时间表支持,但deshake目前没有.

用法示例.这将从框架28-32放置红色框,从60秒开始放置绿色框.另请参阅有关其他功能的表达式评估的文档.

ffmpeg -i small.ts -vf "drawbox=enable='between(n,28,32)' : x=10 : y=10 : w=50 \
: h=50 : color=red,drawbox=enable='gte(t,60)' : x=100 : y=100 : w=200 : \
h=200 : color=green" -codec:a copy small_with_box.ts
Run Code Online (Sandbox Code Playgroud)