Search code examples
ffmpeg

Add audio visualization overlay to video with FFMpeg


Wondering if its possible to add audio visualization to a video. I've found some filters from this site https://lukaprincic.si/development-log/ffmpeg-audio-visualization-tricks Most examples seem to be with an image and audio file and not a video file.

I've tried the following but it just yields a video with audio but no visualization.

ffmpeg -stream_loop -1 -i cassette-edit.mp4 -i test-audio.mp3 -filter_complex "[1:a]showwaves=s=1920x1080:mode=line:colors=white:draw=full,format=rgba[out]" -shortest -map "[out]" -map 0:v -map 1:a 'Cassette Dreams - w visualizer.mp4' -y

Solution

  • Try

    ffmpeg -stream_loop -1 -i cassette-edit.mp4 -i test-audio.mp3 -filter_complex "
        [1:a]showwaves=s=1920x1080:mode=line:colors=white:draw=full[vwave];
        [0:v][vwave]overlay=format=auto[out]
      " -shortest -map "[out]" -map 1:a 'Cassette Dreams - w visualizer.mp4' -y
    

    (as a one-liner, removing all extraneous whitespaces)

    [edit] no need for colorkey as showwave appears to output transparent background. Also try format=auto option on overlay.

    Reference: ffmpeg wiki