【WSL2笔记7】Ubuntu 环境FFmpeg功能实测笔记 不定期更新
39.25 chromakey 色度键
YUV colorspace color/chroma keying.
YUV 色彩空间颜色/色度键控。
39.25.1 参数说明
The filter accepts the following options:
筛选器接受以下选项:
-
color
The color which will be replaced with transparency.
将替换为透明度的颜色。 -
similarity
Similarity percentage with the key color.
与关键颜色的相似度百分比。
0.01 matches only the exact key color, while 1.0 matches everything.
0.01 仅匹配确切的键颜色,而 1.0 匹配所有内容。 -
blend
Blend percentage. 混合百分比。
0.0 makes pixels either fully transparent, or not transparent at all.
0.0 使像素完全透明,或者根本不透明。
Higher values result in semi-transparent pixels, with a higher transparency the more similar the pixels color is to the key color.
值越高,像素越半透明,透明度越高,像素颜色与主色越相似。 -
yuv
Signals that the color passed is already in YUV instead of RGB.
表示传递的颜色已采用 YUV 而不是 RGB 格式。
Literal colors like “green” or “red” don’t make sense with this enabled anymore. This can be used to pass exact YUV values as hexadecimal numbers.
启用此功能后,像“绿色”或“红色”这样的文字颜色不再有意义。这可用于将精确的 YUV 值作为十六进制数传递。
39.25.2 实测效果对比
39.25.2.1 similarity=<0.30 - 0.10> blend<0.20 - 0.01>
- 先看对比视频
chromakey_0.30_0.01-0.05-0.10
39.25.2.1.1 区间测试
- similarity=0.30 blend=0.20
ffmpeg -i input_bg.jpg -i input_fg.mp4 \
-y -q 2 \
-filter_complex "\
[1:v]chromakey=0x00FF00:0.3:0.2,scale=1920:1080[fg];\
[0:v]scale=1920:-1,crop=1920:1080:0:0,gblur=2[bg];\
[bg][fg]overlay=10:20[out]" \
-map "[out]" \
chromakey_0.30_0.20.mp4
- similarity=0.30 blend=0.10
ffmpeg -i input_bg.jpg -i input_fg.mp4 \
-y -q 2 \
-filter_complex "\
[1:v]chromakey=0x00FF00:0.3:0.1,scale=1920:1080[fg];\
[0:v]scale=1920:-1,crop=1920:1080:0:0,gblur=2[bg];\
[bg][fg]overlay=10:20[out]" \
-map "[out]" \
chromakey_0.30_0.10.mp4
- similarity=0.30 blend=0.05
ffmpeg -i input_bg.jpg -i input_fg.mp4 \
-y -q 2 \
-filter_complex "\
[1:v]chromakey=0x00FF00:0.3:0.05,scale=1920:1080[fg];\
[0:v]scale=1920:-1,crop=1920:1080:0:0,gblur=2[bg];\
[bg][fg]overlay=10:20[out]" \
-map "[out]" \
chromakey_0.30_0.05.mp4
- similarity=0.30 blend=0.01
ffmpeg -i input_bg.jpg -i input_fg.mp4 \
-y -q 2 \
-filter_complex "\
[1:v]chromakey=0x00FF00:0.3:0.01,scale=1920:1080[fg];\
[0:v]scale=1920:-1,crop=1920:1080:0:0,gblur=2[bg];\
[bg][fg]overlay=10:20[out]" \
-map "[out]" \
chromakey_0.30_0.01.mp4
- similarity=0.20 blend=0.01
ffmpeg -i input_bg.jpg -i input_fg.mp4 \
-y -q 2 \
-filter_complex "\
[1:v]chromakey=0x00FF00:0.2:0.01,scale=1920:1080[fg];\
[0:v]scale=1920:-1,crop=1920:1080:0:0,gblur=2[bg];\
[bg][fg]overlay=10:20[out]" \
-map "[out]" \
chromakey_0.20_0.01.mp4
- similarity=0.25 blend=0.01
ffmpeg -i input_bg.jpg -i input_fg.mp4 \
-y -q 2 \
-filter_complex "\
[1:v]chromakey=0x00FF00:0.25:0.01,scale=1920:1080[fg];\
[0:v]scale=1920:-1,crop=1920:1080:0:0,gblur=2[bg];\
[bg][fg]overlay=10:20[out]" \
-map "[out]" \
chromakey_0.25_0.01.mp4
- similarity=0.25 blend=0.1
ffmpeg -i input_bg.jpg -i input_fg.mp4 \
-y -q 2 \
-filter_complex "\
[1:v]chromakey=0x00FF00:0.25:0.1,scale=1920:1080[fg];\
[0:v]scale=1920:-1,crop=1920:1080:0:0,gblur=2[bg];\
[bg][fg]overlay=10:20[out]" \
-map "[out]" \
chromakey_0.25_0.1.mp4
39.25.2.1.1 区间测试
找出两个较好效果的范围区间,进行后续更多的对比测试
- similarity=0.25 blend=0.1
- similarity=0.30 blend=0.05
39.25.2.2 similarity=0.25 blend<0.15 - 0.01>
对比视频