Changes between Initial Version and Version 1 of Ticket #11083


Ignore:
Timestamp:
Jul 4, 2024, 7:14:03 AM (2 years ago)
Author:
Jiamin.X
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #11083 – Description

    initial v1  
    141141}}}
    142142
    143 From the above, we can see that converting to **fltp** or **s16 with -rematrix_maxval 100** have the exact same max and mean volume, while converting to **s16** directly without setting **-rematrix_maxval** results in lot weaker volume. If I convert from 2-channel **flt** to 2-channel **s16**, the volume will not be affected at all.
     143I also tried converting 2-channel **flt** to 2-channel **s16** and check the volome as below, output: **stereo-s16-from-2-ch-flt.mkv**
     144{{{
     145% ffmpeg -y -i stereo-flt.mkv -c:a pcm_s16le stereo-s16-from-2-ch-flt.mkv
     146Input #0, matroska,webm, from 'stereo-flt.mkv':
     147  Stream #0:0: Audio: pcm_f32le, 48000 Hz, 2 channels, flt, 3072 kb/s (default)
     148Stream mapping:
     149  Stream #0:0 -> #0:0 (pcm_f32le (native) -> pcm_s16le (native))
     150Output #0, matroska, to 'stereo-s16-from-2-ch-flt.mkv':
     151  Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 48000 Hz, stereo, s16, 1536 kb/s (default)
     152}}}
     153
     154Checked the volume of **stereo-flt.mkv** and **stereo-s16-from-2-ch-flt.mkv** (both have the exact same max and mean volume):
     155{{{
     156% ffmpeg -i stereo-flt.mkv -af "volumedetect" -vn -sn -f null /dev/null
     157Input #0, matroska,webm, from 'stereo-flt.mkv':
     158  Stream #0:0: Audio: pcm_f32le, 48000 Hz, 2 channels, flt, 3072 kb/s (default)
     159Stream mapping:
     160  Stream #0:0 -> #0:0 (pcm_f32le (native) -> pcm_s16le (native))
     161Output #0, null, to '/dev/null':
     162  Stream #0:0: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s (default)
     163[Parsed_volumedetect_0 @ 0x7fc091f09c80] n_samples: 6383616
     164[Parsed_volumedetect_0 @ 0x7fc091f09c80] mean_volume: -21.6 dB
     165[Parsed_volumedetect_0 @ 0x7fc091f09c80] max_volume: 0.0 dB
     166[Parsed_volumedetect_0 @ 0x7fc091f09c80] histogram_0db: 1466
     167[Parsed_volumedetect_0 @ 0x7fc091f09c80] histogram_1db: 1310
     168[Parsed_volumedetect_0 @ 0x7fc091f09c80] histogram_2db: 3452
     169[Parsed_volumedetect_0 @ 0x7fc091f09c80] histogram_3db: 4591
     170
     171
     172% ffmpeg -i stereo-s16-from-2-ch-flt.mkv -af "volumedetect" -vn -sn -f null /dev/null
     173Input #0, matroska,webm, from 'stereo-s16-from-2-ch-flt.mkv':
     174  Stream #0:0: Audio: pcm_s16le, 48000 Hz, 2 channels, s16, 1536 kb/s (default)
     175Stream mapping:
     176  Stream #0:0 -> #0:0 (pcm_s16le (native) -> pcm_s16le (native))
     177Output #0, null, to '/dev/null':
     178  Stream #0:0: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s (default)
     179[Parsed_volumedetect_0 @ 0x7fcbc5604080] n_samples: 6383616
     180[Parsed_volumedetect_0 @ 0x7fcbc5604080] mean_volume: -21.6 dB
     181[Parsed_volumedetect_0 @ 0x7fcbc5604080] max_volume: 0.0 dB
     182[Parsed_volumedetect_0 @ 0x7fcbc5604080] histogram_0db: 1466
     183[Parsed_volumedetect_0 @ 0x7fcbc5604080] histogram_1db: 1310
     184[Parsed_volumedetect_0 @ 0x7fcbc5604080] histogram_2db: 3452
     185[Parsed_volumedetect_0 @ 0x7fcbc5604080] histogram_3db: 4591
     186}}}
     187
     188From the above, we can see that converting to **fltp** or **s16 with -rematrix_maxval 100** have the exact same max and mean volume, while converting to **s16** directly without setting **-rematrix_maxval** results in lot weaker volume. Also we can see that converting from 2-channel **flt** to 2-channel **s16**, the volume is not affected at all.
    144189
    145190I checked the code related to the **rematrix_maxval** setting in **libswresample/rematrix.c** (shown below), we can see if **rematrix_maxval** is not manually set, it will be treated differently based on the input and output sample formats, basically for **s16** as either the input or output sample format, **rematrix_maxval** will be set to 1, which will affect the matrix params used in the later rematrix process, essentially attenuates the coefficients used for downmixing and cause volume attenuation as a result.