[英]FFMpeg C++ How to create a filter with multiple outputs?
例如,我們有一個AVFrame
大小為128×128像素和任務是將分裂AVFrame
成4份(4獨立AVFrame
)。 為此,我使用avfilter_graph_parse2(...)
函數avfilter_graph_parse2(...)
濾器填充圖形,然后調用avfilter_graph_config(...)
。
開始吧。 讓我們剪掉左上角。 要裁剪一幀,我們需要使用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;
一切都很好! 現在讓我們嘗試制作幾個輸出:
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
如您所見,我們有一個用於輸入圖像的buffer
,4 個用於切割每一塊的crop
過濾器,以及 4 個用於輸出圖像的buffersink
過濾器。 調用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.
我正在請求您幫助創建具有多個輸出的過濾器。
Alan 的評論指示我split
filter 。 我這樣做了:
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.