FFmpeg Audio Merge: Volume Level Adjustments, Sidechain Processing, and Ducking Stopped Working
In this article, we will discuss how to merge stereo background music with a mono voiceover audio while adjusting the volume levels and using sidechain processing and ducking. We will troubleshoot why ducking may have stopped working and provide a detailed guide on how to achieve the desired audio output using FFmpeg.
Merging Stereo Background Music with Mono Voiceover Audio
To merge stereo background music with a mono voiceover audio, we can use the -filter_complex option in FFmpeg. Here's an example command:
ffmpeg -i background.mp3 -i voiceover.mp3 -filter_complex "[0:a][1:a]concat=n=2:v=0:a=1[outa]" -map "[outa]" output.mp3In this command, background.mp3 is the stereo background music file, and voiceover.mp3 is the mono voiceover audio file. The concat filter is used to concatenate the two audio streams into one. The n parameter specifies the number of inputs (in this case, 2), the v parameter specifies that there are no video streams, and the a parameter specifies that there is one audio stream. The output is mapped to [outa] and saved to output.mp3.
Volume Level Adjustments
To adjust the volume levels of the background music and voiceover audio, we can use the volume filter. Here's an example command:
ffmpeg -i background.mp3 -i voiceover.mp3 -filter_complex "[0:a]volume=0.8[bg];[1:a]volume=1.2[vo];[bg][vo]concat=n=2:v=0:a=1[outa]" -map "[outa]" output.mp3In this command, we've added the volume filter to both the background music and voiceover audio. The background music is set to 80% volume (volume=0.8), and the voiceover audio is set to 120% volume (volume=1.2). The output is then concatenated as before and saved to output.mp3.
Sidechain Processing and Ducking
Sidechain processing and ducking are techniques used to automatically lower the volume of one audio stream when another audio stream is playing. In our case, we want to lower the volume of the background music when the voiceover audio is playing. To achieve this, we can use the compand and afade filters.
First, we'll use the compand filter to compress the dynamic range of the background music. This will make it easier to lower the volume when the voiceover audio is playing. Here's an example command:
ffmpeg -i background.mp3 -filter_complex "[0:a]compand=attacks=10:gains=6:release=100[bg]" -map "[bg]" background_compressed.mp3In this command, we've added the compand filter to the background music. The attacks parameter specifies the attack time (how quickly the volume increases), the gains parameter specifies the gain reduction, and the release parameter specifies the release time (how quickly the volume decreases). The output is saved to background_compressed.mp3.
Next, we'll use the afade filter to lower the volume of the background music when the voiceover audio is playing. Here's an example command:
ffmpeg -i background_compressed.mp3 -i voiceover.mp3 -filter_complex "[0:a]afade=t=out:st=10:d=3[bg];[1:a][bg]sidechain=mode=normal:gain=12:volume=0.8[vo];[bg][vo]concat=n=2:v=0:a=1[outa]" -map "[outa]" output.mp3In this command, we've added the afade filter to the background music to lower the volume from 10 seconds to 13 seconds (afade=t=out:st=10:d=3). We've also added the sidechain filter to the voiceover audio to lower the volume of the background music when the voiceover audio is playing (sidechain=mode=normal:gain=12:volume=0.8). The output is then concatenated as before and saved to output.mp3.
Troubleshooting Ducking Stopped Working
If ducking has stopped working, there are a few things to check:
- Make sure the
sidechainfilter is being used correctly. Check the parameters for themode,gain, andvolumeoptions. - Check the volume levels of the input audio files. If the volume is too low or too high, ducking may not work correctly.
- Check the attack and release times of the
compandfilter. If the attack time is too short or the release time is too long, ducking may not work correctly.
References
--endarticle--