使用FFmpeg对图像进行调色-colorchannelmixer

前面介绍过两种调色的滤镜之后,相信大家对调色也有了一点认知,并且也能做一些并不是很艺术的技术化的调色了,这回再介绍一个调色滤镜,colorchannelmixer,看滤镜名称很显然是做色彩通道混合用的滤镜,例如在红色通道增加绿色增益、蓝色增益、红色增益、alpha增益的,下面看一下参数说明。


StevenLiu:ffmpeg StevenLiu$ ffmpeg -hide_banner -h filter=colorchannelmixer
Filter colorchannelmixer
  Adjust colors by mixing color channels.
    slice threading supported
    Inputs:
       #0: default (video)
    Outputs:
       #0: default (video)
colorchannelmixer AVOptions:
  rr                <double>     ..FV..... set the red gain for the red channel (from -2 to 2) (default 1)
  rg                <double>     ..FV..... set the green gain for the red channel (from -2 to 2) (default 0)
  rb                <double>     ..FV..... set the blue gain for the red channel (from -2 to 2) (default 0)
  ra                <double>     ..FV..... set the alpha gain for the red channel (from -2 to 2) (default 0)
  gr                <double>     ..FV..... set the red gain for the green channel (from -2 to 2) (default 0)
  gg                <double>     ..FV..... set the green gain for the green channel (from -2 to 2) (default 1)
  gb                <double>     ..FV..... set the blue gain for the green channel (from -2 to 2) (default 0)
  ga                <double>     ..FV..... set the alpha gain for the green channel (from -2 to 2) (default 0)
  br                <double>     ..FV..... set the red gain for the blue channel (from -2 to 2) (default 0)
  bg                <double>     ..FV..... set the green gain for the blue channel (from -2 to 2) (default 0)
  bb                <double>     ..FV..... set the blue gain for the blue channel (from -2 to 2) (default 1)
  ba                <double>     ..FV..... set the alpha gain for the blue channel (from -2 to 2) (default 0)
  ar                <double>     ..FV..... set the red gain for the alpha channel (from -2 to 2) (default 0)
  ag                <double>     ..FV..... set the green gain for the alpha channel (from -2 to 2) (default 0)
  ab                <double>     ..FV..... set the blue gain for the alpha channel (from -2 to 2) (default 0)
  aa                <double>     ..FV..... set the alpha gain for the alpha channel (from -2 to 2) (default 1)

This filter has support for timeline through the 'enable' option.

调整视频色彩的话,设置这些参数之后,有一个计算的公式:

红色部分:

red=red*rr + blue*rb + green*rg + alpha*ra

绿色部分:

green=red*gr + blue*gb + green*gg + alpha*ga

蓝色部分:

blue=red*br + blue*bb + green*bg + alpha*ba

Alpha部分:

alpha=red*ar + blue*ab + green*ag + alpha*aa

公式了解过了,下面看一下设一下测试的值,看看效果,首先还是拿开放版权的视频测试,争取不侵权,看一下原图像是什么样的。

图片

图像看上去挺棒的,一切正常,那么我们先调一下红色通道部分,看一下会变成什么样。

ffplay  -vf colorchannelmixer=rr=0.393:rg=0.769:rb=0.189:ra=0 graded_edit_final_00668.png

看一下效果

图片

颜色整体稍微偏褐色那么了一点,看来是有效果。如果把整体调整得大红色,可以试着这么干,把green和blue通道全部设置0,红色通道全部最大:

ffplay  -vf colorchannelmixer=rr=2:rg=2:rb=2:ra=0:gr=0:gg=0:gb=0:br=0:bg=0:bb=0 graded_edit_final_00668.png

看一下效果,确认一下是不是如我们所设置的值对应:

图片

当然,如果这只偏蓝色一点的话,可以这么设置:

ffplay  -vf colorchannelmixer=br=0.393:bg=0.769:bb=0.189:ba=0 graded_edit_final_00668.png

看一下效果:

图片

做一些基本的调色,用colorchannelmixer基本上可以做到微调色了,效果能好很多。

至于调API设置,可以参考《使用 FFmpeg 实现画中画效果

方法都是相通的。

这一次就介绍到这里,更多的colorchannelmixer的使用方式欢迎随时交流。

作者:悟空 公众号:流媒体技术

版权声明:本文内容转自互联网,本文观点仅代表作者本人。本站仅提供信息存储空间服务,所有权归原作者所有。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至1393616908@qq.com 举报,一经查实,本站将立刻删除。

(0)

相关推荐

  • 基于java的网络聊天室(Java实现聊天室)

    Java聊天室是用Java程序实现的,由客户端和服务器端组成。先启动服务器端,再启动客户端,服务器验证身份后客户便可登陆聊天室。 一 问题描述 对于客户来说: 注册、登陆和退出聊天…

    2022年12月14日
  • 自研流媒体协议探索与实践

    本文《自研流媒体协议探索与实践》来自B站流媒体技术部——B站内部端到端的直播流媒体技术研发团队,为B站直播量身打造了高性能、高性价比的流媒体服务体系。 背景 自从我站从2020年逐…

    2024年3月19日
  • ASPECT: HTTP自适应流的实时盲质量评价 | ICME 2023

    在HTTP自适应视频流中,提出了兼具高性能、低延迟、盲评估于一身的质量评价模块,为Adaptive-BitRate算法提供实时指导。 作者:Chunyi Li, May Lim, …

    2023年4月6日
  • 云/移动端媒体处理技术分享

    今天在部门内做了一个分享,我整理了一下也分享给大家。文章的内容是我在上家单位做的云剪辑和短视频处理用到的一些技术和架构。 先来说一下当初做这个跨平台媒体处理的一个指标吧,当初是对标…

    2022年8月4日
  • B站:自研点直播转码核心

    1. 背景 视频转码是将视频文件经过解封装、解码、滤镜处理、编码、封装从而转换为另一个视频文件的过程,B站每天都有大量的视频原片上传后经过转码系统转换为多个不同分辨率。转换后的视频…

    2024年7月26日
  • WebRTC 架构格局正在发生变化

    现在有一种新型的 WebRTC 应用程序架构正在发展,称为 WebRTC Unbundling,尽管它可能不适用于所有应用程序场景,但至少在开发新的实时视频开发项目时应该考虑一下它。在过去,三种不同类型的 WebRTC 应用架构即符合标准的 WebRTC、开源媒体服务器和称为 CPaaS 的商业媒体服务器是基于 WebRTC 开发的选项,这三个仍然是有效的架构选择,WebRTC Unbundling 只是第四个选择,可以认为它是符合标准的 WebRTC选项的另一种形式。

    2022年4月28日