0

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

kaif15
  • 1

1 Answers1

0

One option would be to use the gradients filter, to add a changing colour gradient.

e.g.

ffmpeg -i input.mp3 -filter_complex "gradients=s=vga:c0=303030:c1=7c84cc:x0=0:x1=0:y0=0:y1=640 [bg];[0:a]showwaves=mode=p2p:s=vga:split_channels=1:scale=lin:draw=scale:colors=Yellow|White[v];[bg][v]overlay=shortest=1:format=rgb:alpha=premultiplied [vid]" -map "[vid]" -map 0:a  -vsync vfr -preset ultrafast -f matroska - | ffplay -autoexit -

There is a speed parameter as well to adjust the gradient rotation.

enter image description here

Rolf of Saxony
  • 21,661
  • 5
  • 39
  • 60