FFMPEG:使特定范围的彩色像素透明 [英] FFMPEG: Making a specifc range of color pixels transparent

查看:96
本文介绍了FFMPEG:使特定范围的彩色像素透明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用ffmpeg将一个视频叠加在另一个视频上,但是无法完全理解该错误.我基于此处

I am trying to overlay one video on top of another using ffmpeg, but couldn't quite understand the error. I based on the existing command from here

更具体地说,我想替换所有接近特定颜色的颜色(例如棕色r:82,g:44,b:11),然后将它们设置为透明.

More specifically, I want to replace the all colors close to a specific color (say brown r:82,g:44,b:11), and then have them set as transparent.

ffmpeg -i moonmen.mp4 -i transparent_overlay.mp4 -filter_complex
"[1]split[m][a];
 [a]geq='if(between(r(X,Y), 77, 87)*between(g(X,Y), 39, 49)*between(b(X,Y), 06, 16) ,255:255:255,0:0:0)';
 [m][al]alphamerge[ovr];
 [0][ovr]overlay"
output.mp4

但是我得到了错误:

[Parsed_geq_1 @ 0x7fc8e2e08400] Either YCbCr or RGB but not both must be specified
[AVFilterGraph @ 0x7fc8e2e07c60] Error initializing filter 'geq' with args 'if(between(r(X,Y), 77, 87)*between(g(X,Y), 39, 49)*between(b(X,Y), 06, 16) ,255:255:255,0:0:0)'
Error initializing complex filters.
Invalid argument

推荐答案

geq 过滤器可同时用于RGB和YUV格式输入,因此必须对其中一个表达式进行标记以表明这一点.但更重要的是,您的输入可能不是RGB或Alpha,因此必须首先进行固定.

The geq filter can work on both RGB and YUV format input, so one of the expressions has to be labeled to indicate that. But more importantly, your input may not be RGB, or have alpha, so that has to be fixed first.

ffmpeg -i moonmen.mp4 -i transparent_overlay.mp4 -filter_complex
"[1]format=rgba,geq=r='r(X,Y)':a='if(between(r(X,Y),77,87)*between(g(X,Y),39,49)*between(b(X,Y),6,16),0,255)'[ovr];
 [0][ovr]overlay"
output.mp4

这篇关于FFMPEG:使特定范围的彩色像素透明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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