本文介绍了在ffmpeg中发送cmd的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么ffmpeg中的sendcmd可以与drawtext一起使用,但不能与scalerotation和其他过滤器一起使用?

Why sendcmd in ffmpeg works with drawtext, but does not work with scale, rotation and other filters?

示例(此代码有效)

ffmpeg  -i testIN.mp4 -filter_complex "[0:v]sendcmd=f=testTXT.cmd,drawtext=fontfile=PF.ttf:text='': fontcolor=white:fontsize=150" testOUT.mp4

testTXT.cmd

testTXT.cmd

0 drawtext reinit 'text=111';
1 drawtext reinit 'text=222';
2 drawtext reinit 'text=333';

示例(此代码无效)

ffmpeg -i testIN.mp4 -filter_complex "[0:v]sendcmd=f=testTXT.cmd,drawbox=x=10:y=10:w=100:h=100" testOUT.mp4

testTXT.cmd

testTXT.cmd

0 drawbox reinit 'x=20:y=20:w=200:h=200';
1 drawbox reinit 'x=30:y=30:w=300:h=300';
2 drawbox reinit 'x=40:y=40:w=400:h=400';

推荐答案

您遇到了几个问题:

  1. 并非所有过滤器都支持 sendcmd .您可以使用ffmpeg -filters查看哪些过滤器支持sendcmd.在过滤器名称的左侧查找"C".此外,只有某些过滤器选项(也称为sendcmd命令")可以与sendcmd一起使用.请参见 FFmpeg过滤器文档,或参考man ffmpeg-filters,并在每个过滤器的命令部分.

  1. Not all filters support sendcmd. You can see which filters support sendcmd with ffmpeg -filters. Look for a "C" to the left of the filter name. Additionally, only certain filter options (aka sendcmd "commands") can be used with sendcmd. See the FFmpeg filter documentation, or refer to man ffmpeg-filters, and view the available options under the Commands section for each filter.

每个过滤器命令必须在sendcmd文件中声明.文档示例中显示的reinit似乎仅限于绘制文本过滤器,但这在文档中没有解释.

Each filter command must be declared in the sendcmd file. The reinit shown in the documentation example appears to be limited to the drawtext filter, but this is not explained in the documentation.

旋转示例

sendcmd文本文件示例:

rotate example

Example sendcmd text file:

    0 rotate angle '45*PI/180';
    1 rotate angle '90*PI/180';
    2 rotate angle '180*PI/180';

示例ffmpeg命令:

    ffmpeg -i input.mp4 -filter_complex "[0:v]sendcmd=f=test.cmd,rotate" output.mp4

上面的示例将在持续时间012上轮换.

The above example will rotate on duration 0, 1, and 2.

sendcmd文本文件示例:

Example sendcmd text file:

0
overlay@1 x 10,
overlay@1 y 10,
overlay@2 x W-w-10,
overlay@2 y H-h-10,
overlay@3 x (W-w)/2,
overlay@3 y (H-h)/2;

# overlay@1 does not move at this duration so it needs no new entry here
2.25
overlay@2 x 10,
overlay@2 y H-h-10,
overlay@3 x (W-w)/2,
overlay@3 y H-h-10;

示例ffmpeg命令:

ffmpeg -i video.mp4 -i overlay1.png -i overlay2.jpg -i overlay3.png -filter_complex "[0:v]sendcmd=f=test.cmd,nullsink;[0:v][1:v]overlay@1[bg1];[bg1][2:v]overlay@2[bg2];[bg2][3:v]overlay[v]" -map "[v]" -map 0:a? -c:a copy output.mp4

这篇关于在ffmpeg中发送cmd的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-10 22:08