[英]FFMpeg C++ How to create a filter with multiple outputs?
For example, we have one AVFrame
with a size of 128x128 pixels and the task is to split the AVFrame
into 4 parts (4 separate AVFrame
).例如,我们有一个
AVFrame
大小为128×128像素和任务是将分裂AVFrame
成4份(4独立AVFrame
)。 To do this, I fill the graph with filters using the avfilter_graph_parse2(...)
function, and then call avfilter_graph_config(...)
.为此,我使用
avfilter_graph_parse2(...)
函数avfilter_graph_parse2(...)
滤器填充图形,然后调用avfilter_graph_config(...)
。
Let's start.开始吧。 Let's cut out the top left corner.
让我们剪掉左上角。 To crop a frame, we need to use the
crop
filter, which means we initialize the AVFilterGraph graph with the line:要裁剪一帧,我们需要使用
crop
过滤器,这意味着我们用以下行初始化 AVFilterGraph 图:
buffer = width = 128: height = 128: pix_fmt = 2: time_base = 1/25, pixel_aspect = 128/64 [pad_in];
[pad_in] crop = w = 64: h = 64: x = 0: y = 0, buffersink;
Everything works great!一切都很好! Now let's try to make several outputs:
现在让我们尝试制作几个输出:
buffer = width = 128: height = 128: pix_fmt = 2: time_base = 1/25, pixel_aspect = 128/64 [pad_in];
[pad_in] crop = w = 64: h = 64: x = 0: y = 0, buffersink;
[pad_in] crop = w = 64: h = 64: x = 64: y = 0, buffersink;
[pad_in] crop = w = 64: h = 64: x = 0: y = 64, buffersink;
[pad_in] crop = w = 64: h = 64: x = 64: y = 64, buffersink
As you can see, we have one buffer
for the input image, 4 crop
filters for cutting each piece, and 4 buffersink
filters for the output images.如您所见,我们有一个用于输入图像的
buffer
,4 个用于切割每一块的crop
过滤器,以及 4 个用于输出图像的buffersink
过滤器。 The call avfilter_graph_parse2(...)
returns 0, which is good, but avfilter_graph_config()
returns the error code -22 == AVERROR(EINVAL)
and the message is output to the console: Input pad "default" with type video of the filter instance "Parsed_crop_3" of crop not connected to any source.
调用
avfilter_graph_parse2(...)
返回 0,这很好,但是avfilter_graph_config()
返回错误代码-22 == AVERROR(EINVAL)
并且消息输出到控制台: Input pad "default" with type video of the filter instance "Parsed_crop_3" of crop not connected to any source.
I am asking for your help in creating a filter with multiple outputs.我正在请求您帮助创建具有多个输出的过滤器。
Alan's comment directed me to split
filter . Alan 的评论指示我
split
filter 。 And I did this:我这样做了:
buffer=width=128:height=128:pix_fmt=2:time_base=1/25,sar=1 [pad_in];
[pad_in] split=4 [pad_split_0] [pad_split_1] [pad_split_2] [pad_split_3];
[pad_split_0] crop=w=64:h=64:x=0:y=0,buffersink;
[pad_split_1] crop=w=64:h=64:x=64:y=0,buffersink;
[pad_split_2] crop=w=64:h=64:x=0:y=64,buffersink;
[pad_split_3] crop=w=64:h=64:x=64:y=64,buffersink
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.