'Ducking music using FFmpeg

I want to duck a music audio with a speech audio using FFmpeg (ducking is commonly used to lower background music anytime a person speaks, then raises it when that person finishes speaking). How can I do it with FFmpeg or any other tools (if any)?

There was an FFmpeg filter called sidechaincompress which merges the two, but it doesn't "duck" them. It takes 2 audio inputs, 1st input to be compressed depending on the signal of 2nd input and later compressed signal to be merged with 2nd input:

ffmpeg -i main.flac -i sidechain.flac -filter_complex "[1:a]asplit=2[sc][mix];[0:a][sc]sidechaincompress[compr];[compr][mix]amerge"


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source