FFMPEG波形透明,背景纯色 [英] FFMPEG waveform transparent, background solid color

查看:1060
本文介绍了FFMPEG波形透明,背景纯色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用ffmpeg生成波形,我希望背景为纯色,而实际波形为透明.以下内容部分实现了我想要的功能,但背景为黑色.我希望能够将其更改为任何颜色,但波形要透明.我该如何用ffmepg做到这一点?

I am trying to generate a waveform with ffmpeg, I want the background to be a solid color, and the actual waveform to be transparent. The following achieves partially what i want, except that in has a black background. I would like to be able to change this to any color, but have the waveform be transparent. How can i achieve this with ffmepg?

ffmpeg -i input.mp3 -filter_complex \
"[0:a]aformat=channel_layouts=mono,\
compand=gain=-6, \
showwavespic=s=600x120, \
colorchannelmixer=rr=1:gg=0:bb=0:aa=1,\
drawbox=x=(iw-w)/2:y=(ih-h)/2:w=iw:h=1:color=red,\
format=rgba,\
colorkey=#ff0000" \
-vframes 1 output.png

这将生成此波形:背景为黑色,波形本身为透明.如何在保持波形透明的同时将背景色更改为其他颜色?

This generates this waveform: the background is black, the waveform itself is transparent. How do I change the background color to a different color, while still keeping the waveform transparent?

推荐答案

使用此

ffmpeg -i input.mp3 -filter_complex \
   "[0:a]aformat=channel_layouts=mono,compand=gain=-6, \
    showwavespic=s=600x120:colors=white,negate[a]; \
    color=red:600x120[c]; \
    [c][a]alphamerge"  -vframes 1 output.png

在showwavespic中指定的颜色可确保您获得严格的双色输出.比拔钥匙好.

The color specified in the showwavespic ensures that you get a strict duochrome output. Better than pulling a key.

这篇关于FFMPEG波形透明,背景纯色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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