ffmpeg cli过滤器,需要用户输入 [英] ffmpeg cli filter that require user input

查看:139
本文介绍了ffmpeg cli过滤器,需要用户输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法可以为ffmpeg编写过滤器脚本,以便每当我输入内容时,过滤器都会改变行为?

Is there a way to script filters for ffmpeg, such that when ever I give an input, the filter will change behavior?

一个例子是在录制流时,用一个键改变对比度,或用另一个键混合两个视频.

An example would be changing contrast with a key, or blending two videos with another key, while recording the stream.

我已经看到我可以以静态方式执行此操作,例如以新行为重新开始记录,然后再调用concat,由于进程终止和进程失灵,这会导致某些帧丢失,但是我想知道是否有可能,而无需重新启动.

I've seen I could do this in a static way, like restart recording with the new behavior, and calling for a concat after, this results in some frame loss because of the process killing and process lifiting, but I wanted to know If this is possible, with out calling for restart.

推荐答案

使用 zmq和azmq 过滤器.与使用预先编写的命令的sendcmd过滤器不同,(a)zmq允许您任意发送过滤器命令.

Use the zmq and azmq filters. Unlike the sendcmd filter, which uses pre-written commands, (a)zmq allows you arbitrarily to send filter commands.

要启用这些过滤器,您需要安装libzmq库和标头,并用--enable-libzmq配置ffmpeg.

To enable these filters you need to install the libzmq library and headers and configure ffmpeg with --enable-libzmq.

仅支持命令的过滤器可以与此过滤器一起使用.请参考ffmpeg -filters的输出以查看哪些过滤器支持命令的列表.此外,并非过滤器的所有选项都被视为命令.有关支持的命令列表,请参阅每个过滤器的文档.

Only filters that support commands can be used with this filter. Refer to the output of ffmpeg -filters to view a list of which filters support commands. Additionally, not all options for a filter are considered to be commands. Refer to the documentation of each filter for a list of supported commands.

请考虑以下由ffplay生成的过滤器图.在此示例中,最后一个覆盖过滤器具有实例名称.所有其他过滤器将具有默认实例名称.

Consider the following filtergraph generated by ffplay. In this example the last overlay filter has an instance name. All other filters will have default instance names.

ffplay -dumpgraph 1 -f lavfi "
color=s=100x100:c=red  [l];
color=s=100x100:c=blue [r];
nullsrc=s=200x100, zmq [bg];
[bg][l]   overlay     [bg+l];
[bg+l][r] overlay@my=x=100 "

要更改视频左侧的颜色,可以使用以下命令:

To change the color of the left side of the video, the following command can be used:

echo Parsed_color_0 c yellow | tools/zmqsend

要更改右侧:

echo Parsed_color_1 c pink | tools/zmqsend

要更改右侧的位置,请执行以下操作:

To change the position of the right side:

echo overlay@my x 150 | tools/zmqsend

这篇关于ffmpeg cli过滤器,需要用户输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆