Possible ffmpeg solution: low volume when transcoding surround to stereo

Server Version#: 1.28.1.6104-788f82488
Player Version#:
ffmpeg version: 4.2.3

Solution: change rematrix_maxval from 0.000000dB to 0.

The problem should be familiar. When you play a file with 5.1 channel audio on a stereo device, the volume is too low. In my case, I’m casting from an android phone to a chromecast, using direct play. Even though video plays directly, audio still has to be transcoded if it is not already stereo AAC.

I looked through the logs while playing a video where the volume was too low, and I found the ffmpeg command performing the transcode from eac3 to mp3. This part stood out:

-map 0:0 -metadata:s:0 language=jpn -codec:0 copy -filter_complex "[0:1] aresample=async=1:ocl='stereo':rematrix_maxval=0.000000dB:osr=48000[0]"

According to the ffmpeg docs, rematrix_maxval accepts values 0 to 1 to prevent clipping vs preventing volume reduction https://ffmpeg.org/ffmpeg-resampler.html. By default the value is 1 (to prevent clipping) so the intent of the plex command is clearly to preserve volume. However, running the command outside of plex with ffmpeg produces a much quieter output than the original 5.1 input.

ffmpeg -i 1x01.ac3 -c:a libmp3lame -filter_complex "[0:0] aresample=async=1:ocl='stereo':rematrix_maxval=0.000000dB:osr=48000" 1x01.mp3

The first thing I tried was changing the rematrix_maxval to 0 (removing the dB) so that it reads:

rematrix_maxval=0

The resulting mp3 was loud, just like the original ac3 input. The volume is also maintained when transcoding to aac. Can I get a plex employee’s opinion on this? If it’s good, where can I submit the change? I looked at the plex github and there were too many repositories to make sense of.

edit: I guess plex isn’t open source :frowning: so nevermind about the last part.

edit2: I may have been a little off the mark about default values.

Running ffmpeg with defaults actually produces a normal loud mp3:

ffmpeg -i 1x01.ac3 1x01.mp3
  • Running with rematrix_maxval at 0 also produces a loud mp3.
  • rematrix_maxval=1 produces a quiet mp3
  • The original rematrix_maxval=0.000000dB also produces a quiet mp3

So maybe 0.000000dB is a valid argument, and the goal was audio normalization rather than volume preservation. Or maybe not, and rematrix_maxval only defaults to 1 when you pass it with a bad argument in a filter. Regardless, since the volume is about half what it should be, and there is no option for the user to change it, I think it’s better to make it loud.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.