【WSL2笔记7】Ubuntu 环境FFmpeg功能实测笔记 不定期更新

这篇笔记详细记录了在Ubuntu系统中使用FFmpeg进行色度键(chromakey)操作的实测过程。作者通过调整`similarity`和`blend`参数,对比不同设置下的效果,寻找最佳区间,并提出优化方案。同时,笔记还涵盖了颜色矩阵(colormatrix)转换和色彩空间(colorspace)的实际应用,包括不同参数的对比测试。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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>

对比视频

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值