Answers.Body: <p>One way to make the volume levels consistent is:</p>
  <pre><code>ffmpeg -i in.mp3 -i out.mp3 -filter_complex &quot;[1:a]asplit=2[sc][mix];[0:a][sc]sidechaincompress[compr];[compr][mix]amerge&quot; -c:a libmp3lame res.mp3
  </code></pre>
  <p>But this may not be the best way. Please let me know if there are better ways, and what are the pros and cons of the above method. thanks.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-05-26T11:41:38.487Z
Answers.LastActivityDate: 2021-05-26T11:41:38.487Z
Answers.UserDisplayName: ILPuser
Body: <p>I am trying to use ffmpeg to merge two audios, in.mp3 and out.mp3, like this:</p>
  <pre><code>ffmpeg -i in.mp3 -i out.mp3 -filter_complex amix=inputs=2:duration=longest -c:a libmp3lame res.mp3
  </code></pre>
  <p>But the final output res.mp3 has different volume levels.</p>
  <p>When I run ffmpeg 'volumedetect' it gives these outputs:</p>
  <p><strong>1. For in.mp3</strong></p>
  <pre><code>ffmpeg -i in.mp3 -af &quot;volumedetect&quot; -vn -sn -dn -f null NUL
  </code></pre>
  <p>Stream #0:0: Audio: pcm_s16le, 44100 Hz, stereo, s16, 1411 kb/s</p>
  <p>size=N/A time=00:02:07.17 bitrate=N/A speed= 344x</p>
  <p>[Parsed_volumedetect_0 @ 00554a00] mean_volume: -22.3 dB</p>
  <p>[Parsed_volumedetect_0 @ 00554a00] max_volume: -0.3 dB</p>
  <hr>
  <p><strong>2. For out.mp3</strong></p>
  <pre><code>ffmpeg -i out.mp3 -af &quot;volumedetect&quot; -vn -sn -dn -f null NUL
  </code></pre>
  <p>Stream #0:0: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s</p>
  <p>size=N/A time=00:02:07.17 bitrate=N/A speed= 434x</p>
  <p>[Parsed_volumedetect_0 @ 00441100] mean_volume: -22.5 dB</p>
  <p>[Parsed_volumedetect_0 @ 00441100] max_volume: -3.5 dB</p>
  <hr>
  Given the differences in Hz, speed, mean/max volumes - what is the right way to normalize the two audios before merging them with amix?
  <p><em>THANKS!</em></p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-05-22T18:03:50.813Z
Comments.Text: I used this and it worked:                                                                                                    
  **ffmpeg -i in.mp3 -i out.mp3 -filter_complex "[1:a]asplit=2[sc][mix];[0:a][sc]sidechaincompress[compr];[compr][mix]amerge" -c:a libmp3lame res.mp3**
Comments.UserDisplayName: ILPuser
Tags: <ffmpeg><audio>
Title: Correct way to normalize two audios before using filter_complex amix
UserDisplayName: ILPuser
ThreadText: # Correct way to normalize two audios before using filter_complex amix
  
  (Asked by: username_0 on 2021-05-22)
  
  I am trying to use ffmpeg to merge two audios, in.mp3 and out.mp3, like this:
  
  ```
  ffmpeg -i in.mp3 -i out.mp3 -filter_complex amix=inputs=2:duration=longest -c:a libmp3lame res.mp3
  
  ```
  
  But the final output res.mp3 has different volume levels.
  
  When I run ffmpeg 'volumedetect' it gives these outputs:
  
  **1. For in.mp3**
  
  ```
  ffmpeg -i in.mp3 -af "volumedetect" -vn -sn -dn -f null NUL
  
  ```
  
  Stream #0:0: Audio: pcm\_s16le, 44100 Hz, stereo, s16, 1411 kb/s
  
  size=N/A time=00:02:07.17 bitrate=N/A speed= 344x
  
  [Parsed\_volumedetect\_0 @ 00554a00] mean\_volume: -22.3 dB
  
  [Parsed\_volumedetect\_0 @ 00554a00] max\_volume: -0.3 dB
  
  ---
  
  **2. For out.mp3**
  
  ```
  ffmpeg -i out.mp3 -af "volumedetect" -vn -sn -dn -f null NUL
  
  ```
  
  Stream #0:0: Audio: pcm\_s16le, 48000 Hz, stereo, s16, 1536 kb/s
  
  size=N/A time=00:02:07.17 bitrate=N/A speed= 434x
  
  [Parsed\_volumedetect\_0 @ 00441100] mean\_volume: -22.5 dB
  
  [Parsed\_volumedetect\_0 @ 00441100] max\_volume: -3.5 dB
  
  ---
  
  Given the differences in Hz, speed, mean/max volumes - what is the right way to normalize the two audios before merging them with amix?
  
  *THANKS!*
  
  **Tags:** ffmpeg, audio
  
  > **Comments:**
  > **username_0**: I used this and it worked:                                                                                                     **ffmpeg -i in.mp3 -i out.mp3 -filter_complex "[1:a]asplit=2[sc][mix];[0:a][sc]sidechaincompress[compr];[compr][mix]amerge" -c:a libmp3lame res.mp3**  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2021-05-26. Score: 1
  
  One way to make the volume levels consistent is:
  
  ```
  ffmpeg -i in.mp3 -i out.mp3 -filter_complex "[1:a]asplit=2[sc][mix];[0:a][sc]sidechaincompress[compr];[compr][mix]amerge" -c:a libmp3lame res.mp3
  
  ```
  
  But this may not be the best way. Please let me know if there are better ways, and what are the pros and cons of the above method. thanks.
  
  
  ---
  
  