FFmpeg showwaves滤镜波形颜色设置问题:如何生成半透明白色波形
Hey Rob, let's get that semi-transparent white waveform working for you! The issue with your current command is that you're relying on colorkey to remove the default black background of showwaves, which can introduce unexpected color artifacts or even accidentally affect your waveform itself. Instead, we can simplify the process by directly generating the waveform on a transparent background and adjusting its opacity explicitly.
Here's the modified command that will give you the semi-transparent white waveform over your Mars surface image:
ffmpeg -i 00002.wav -i MarsSurface.jpg -filter_complex "[0:a]showwaves=s=1920x1080:mode=cline:colors=white:rate=24:scale=lin:bgcolor=0x00000000,format=yuva420p,colorchannelmixer=aa=0.5[v];[1:v]scale=1920:1080[bg];[bg][v]overlay[outv]" -map "[outv]" -map 0:a output.mp4
Let me break down the key changes I made:
- Added
bgcolor=0x00000000to theshowwavesfilter: This tells FFmpeg to generate the waveform on a fully transparent background right off the bat, so we don't need thecolorkeyfilter anymore (which was causing unnecessary complications). - Added
colorchannelmixer=aa=0.5: This adjusts the alpha (transparency) of the waveform. Theaaparameter controls how transparent the waveform is—0would make it fully invisible,1fully opaque, and0.5gives you that nice semi-transparent look you want. Feel free to tweak this value (like0.3for more transparency or0.7for less) to match your preference. - Removed the
colorkeyfilter: Since we're using a transparent background now, this step is no longer needed and was potentially interfering with your waveform's color.
If you still run into issues with the waveform appearing too dim (which can happen with linear scaling), you can add a geq filter to boost the waveform's brightness, but with the above command, you should see a crisp, semi-transparent white waveform over your background image.
备注:内容来源于stack exchange,提问作者Rob

