diff options
| author | Shadowghost <Ghost_of_Stone@web.de> | 2023-02-27 00:08:25 +0100 |
|---|---|---|
| committer | Shadowghost <Ghost_of_Stone@web.de> | 2023-02-27 10:38:50 +0100 |
| commit | 9880a2b3e1ae0b88b5f5545681bd7394f3d35e84 (patch) | |
| tree | 952b53742fe990dfb1b51de62120beed238ca72b | |
| parent | 4a1498f614ca3f51908e8e7ead0ea921222f0f2b (diff) | |
Enforce HLS codec restrictions
| -rw-r--r-- | MediaBrowser.Model/Dlna/StreamBuilder.cs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/MediaBrowser.Model/Dlna/StreamBuilder.cs b/MediaBrowser.Model/Dlna/StreamBuilder.cs index ab81bfb34..b3982fefa 100644 --- a/MediaBrowser.Model/Dlna/StreamBuilder.cs +++ b/MediaBrowser.Model/Dlna/StreamBuilder.cs @@ -799,6 +799,14 @@ namespace MediaBrowser.Model.Dlna { // Prefer matching video codecs var videoCodecs = ContainerProfile.SplitValue(videoCodec); + + // Enforce HLS video codec restrictions + if (string.Equals(playlistItem.SubProtocol, "hls", StringComparison.OrdinalIgnoreCase)) + { + var supportedHlsVideoCodecs = new List<string> { "h264", "hevc" }; + videoCodecs = videoCodecs.Where(codec => supportedHlsVideoCodecs.Contains(codec)).ToArray(); + } + var directVideoCodec = ContainerProfile.ContainsContainer(videoCodecs, videoStream?.Codec) ? videoStream?.Codec : null; if (directVideoCodec is not null) { @@ -834,6 +842,22 @@ namespace MediaBrowser.Model.Dlna // Prefer matching audio codecs, could do better here var audioCodecs = ContainerProfile.SplitValue(audioCodec); + + // Enforce HLS audio codec restrictions + if (string.Equals(playlistItem.SubProtocol, "hls", StringComparison.OrdinalIgnoreCase)) + { + var supportedHlsAudioCodecs = new List<string> { "aac", "ac3", "eac3", "mp3" }; + if (string.Equals(playlistItem.Container, "mp4", StringComparison.OrdinalIgnoreCase)) + { + // fMP4 supports more codecs than TS + supportedHlsAudioCodecs.Add("alac"); + supportedHlsAudioCodecs.Add("flac"); + supportedHlsAudioCodecs.Add("opus"); + } + + audioCodecs = audioCodecs.Where(codec => supportedHlsAudioCodecs.Contains(codec)).ToArray(); + } + var directAudioStream = candidateAudioStreams.FirstOrDefault(stream => ContainerProfile.ContainsContainer(audioCodecs, stream.Codec)); playlistItem.AudioCodecs = audioCodecs; if (directAudioStream is not null) |
