Browse Source

Fallback to lossy audio codec for bitrate limit (#13127)

gnattu 6 months ago
parent
commit
65f722f23c
1 changed files with 5 additions and 0 deletions
  1. 5 0
      Jellyfin.Api/Helpers/StreamingHelpers.cs

+ 5 - 0
Jellyfin.Api/Helpers/StreamingHelpers.cs

@@ -235,6 +235,11 @@ public static class StreamingHelpers
                     state.VideoRequest.MaxHeight = resolution.MaxHeight;
                     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)
         var ext = string.IsNullOrWhiteSpace(state.OutputContainer)