FFMPEG waveform transparent, background solid color

有些话、适合烂在心里 提交于 2019-12-10 11:04:31

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/37149739/ffmpeg-waveform-transparent-background-solid-color

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!