I am trying to write an ffmpeg command to generate a waveform from audio. I've managed to generate the waveform but I fail when trying to add a line such that the silent areas are not blank.
Currently the command is:
-filter_complex "[0:a]aformat=channel_layouts=mono,compand=attacks=0:points=-80/-900|-45/-15|-27/-9|0/-7|20/-7:gain=15,showwavespic=s=180x26:colors=#7c84cc[fg];color=s=180x26:color=#303030[bg];[bg][fg]overlay=format=auto,drawbox=x=(iw-w)/2:y=(ih-h)/2:w=iw:h=1:color=#7c84cc" -frames:v 1
I have added some tweaks of my own to boost the visual appeal but what I would like is to use the drawbox without the color filter. If I try to do that the line disappears during the silent part.
I have also attempted to use a transparent image as the background but that failed as well.
I have relied heavily on this question when approaching this problem:
Generating a waveform using ffmpeg
One option would be to use the
gradients
filter, to add a changing colour gradient.e.g.
There is a
speed
parameter as well to adjust the gradient rotation.Edit: Having checked because @soundflix complained this didn't show a flat line during silence, I added a 10 second silence to the middle of a piece of audio.
This was the result:
which rather suggests it does show a flat line using
ffmpeg version 4.4.2-0ubuntu0.22.04.1