FFMPEG waveform transparent, background solid colo

2019-05-22 06:42发布

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?

enter image description here

标签: ffmpeg mp3
1条回答
你好瞎i
2楼-- · 2019-05-22 07:11

Use this

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

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

查看更多
登录 后发表回答