From 65f722f23c781d6346741589a681b8b00579fc8a Mon Sep 17 00:00:00 2001 From: gnattu Date: Mon, 2 Dec 2024 08:08:28 +0800 Subject: [PATCH] Fallback to lossy audio codec for bitrate limit (#13127) --- Jellyfin.Api/Helpers/StreamingHelpers.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Jellyfin.Api/Helpers/StreamingHelpers.cs b/Jellyfin.Api/Helpers/StreamingHelpers.cs index 3a5db2f3fb..74ba423e43 100644 --- a/Jellyfin.Api/Helpers/StreamingHelpers.cs +++ b/Jellyfin.Api/Helpers/StreamingHelpers.cs @@ -235,6 +235,11 @@ public static class StreamingHelpers state.VideoRequest.MaxHeight = resolution.MaxHeight; } } + + if (!EncodingHelper.IsCopyCodec(state.OutputAudioCodec) && string.Equals(state.AudioStream.Codec, state.OutputAudioCodec, StringComparison.OrdinalIgnoreCase) && state.OutputAudioBitrate.HasValue) + { + state.OutputAudioCodec = state.SupportedAudioCodecs.Where(c => !EncodingHelper.LosslessAudioCodecs.Contains(c)).FirstOrDefault(mediaEncoder.CanEncodeToAudioCodec); + } } var ext = string.IsNullOrWhiteSpace(state.OutputContainer)