mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-06-22 15:40:45 +01:00
Fix audio sample rate forced to 48 kHz for non-Opus codecs
GetProgressiveAudioFullCommandLine applied the libopus-only sample rate quantization to every codec except Opus, inverting the intended guard. A requested rate such as 44100 Hz was therefore snapped to 48000 Hz for AAC/MP3/FLAC, while Opus (which actually requires the quantization) was skipped entirely. Apply the quantization only when the output codec is Opus, and pass the requested sample rate through unchanged for all other codecs. Fixes #17026 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -7870,13 +7870,14 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||
audioTranscodeParams.Add("-ar " + state.BaseRequest.AudioBitRate);
|
||||
}
|
||||
|
||||
if (!string.Equals(outputCodec, "opus", StringComparison.OrdinalIgnoreCase))
|
||||
var sampleRate = state.OutputAudioSampleRate;
|
||||
if (sampleRate.HasValue)
|
||||
{
|
||||
// opus only supports specific sampling rates
|
||||
var sampleRate = state.OutputAudioSampleRate;
|
||||
if (sampleRate.HasValue)
|
||||
var sampleRateValue = sampleRate.Value;
|
||||
if (string.Equals(outputCodec, "opus", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
var sampleRateValue = sampleRate.Value switch
|
||||
// opus only supports specific sampling rates
|
||||
sampleRateValue = sampleRate.Value switch
|
||||
{
|
||||
<= 8000 => 8000,
|
||||
<= 12000 => 12000,
|
||||
@@ -7884,9 +7885,9 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||
<= 24000 => 24000,
|
||||
_ => 48000
|
||||
};
|
||||
|
||||
audioTranscodeParams.Add("-ar " + sampleRateValue.ToString(CultureInfo.InvariantCulture));
|
||||
}
|
||||
|
||||
audioTranscodeParams.Add("-ar " + sampleRateValue.ToString(CultureInfo.InvariantCulture));
|
||||
}
|
||||
|
||||
// Copy the movflags from GetProgressiveVideoFullCommandLine
|
||||
|
||||
Reference in New Issue
Block a user