From 4b1256e67b7d984ac7737f65b2cceab9a8cb0d96 Mon Sep 17 00:00:00 2001 From: nyanmisaka Date: Fri, 6 May 2022 02:27:16 +0800 Subject: [PATCH 1/3] Fix the issue that HEVC transcoding can't be disabled --- MediaBrowser.Model/Dlna/StreamBuilder.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/MediaBrowser.Model/Dlna/StreamBuilder.cs b/MediaBrowser.Model/Dlna/StreamBuilder.cs index ee9cfeeca..9702412cb 100644 --- a/MediaBrowser.Model/Dlna/StreamBuilder.cs +++ b/MediaBrowser.Model/Dlna/StreamBuilder.cs @@ -771,10 +771,17 @@ namespace MediaBrowser.Model.Dlna private void BuildStreamVideoItem(StreamInfo playlistItem, VideoOptions options, MediaSourceInfo item, MediaStream videoStream, MediaStream audioStream, IEnumerable candidateAudioStreams, string container, string videoCodec, string audioCodec) { - // prefer matching video codecs var videoCodecs = ContainerProfile.SplitValue(videoCodec); var directVideoCodec = ContainerProfile.ContainsContainer(videoCodecs, videoStream?.Codec) ? videoStream?.Codec : null; - playlistItem.VideoCodecs = directVideoCodec != null ? new[] { directVideoCodec } : videoCodecs; + if (directVideoCodec != null) + { + // merge directVideoCodec to videoCodecs + videoCodecs = videoCodecs != null && videoCodecs.Length > 0 + ? videoCodecs.Union(new[] { directVideoCodec }).ToArray() + : new[] { directVideoCodec }; + } + + playlistItem.VideoCodecs = videoCodecs; // copy video codec options as a starting point, this applies to transcode and direct-stream playlistItem.MaxFramerate = videoStream?.AverageFrameRate; From 5386f060957f3af11b2520c35d454fa78daab993 Mon Sep 17 00:00:00 2001 From: Nyanmisaka Date: Mon, 9 May 2022 17:09:03 +0800 Subject: [PATCH 2/3] Apply suggestions from code review Co-authored-by: Cody Robibero --- MediaBrowser.Model/Dlna/StreamBuilder.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/MediaBrowser.Model/Dlna/StreamBuilder.cs b/MediaBrowser.Model/Dlna/StreamBuilder.cs index 9702412cb..d49b92cd3 100644 --- a/MediaBrowser.Model/Dlna/StreamBuilder.cs +++ b/MediaBrowser.Model/Dlna/StreamBuilder.cs @@ -776,9 +776,8 @@ namespace MediaBrowser.Model.Dlna if (directVideoCodec != null) { // merge directVideoCodec to videoCodecs - videoCodecs = videoCodecs != null && videoCodecs.Length > 0 - ? videoCodecs.Union(new[] { directVideoCodec }).ToArray() - : new[] { directVideoCodec }; + Array.Resize(ref videoCodecs, (videoCodecs?.Length ?? 0) + 1); + videoCodecs[^1] = directVideoCodec; } playlistItem.VideoCodecs = videoCodecs; From 9523a1682b2d9b2b2e30833f85777c7e96ca76a3 Mon Sep 17 00:00:00 2001 From: Nyanmisaka Date: Wed, 11 May 2022 16:38:30 +0800 Subject: [PATCH 3/3] Apply suggestions from code review Co-authored-by: Claus Vium --- MediaBrowser.Model/Dlna/StreamBuilder.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MediaBrowser.Model/Dlna/StreamBuilder.cs b/MediaBrowser.Model/Dlna/StreamBuilder.cs index d49b92cd3..56d1ebf54 100644 --- a/MediaBrowser.Model/Dlna/StreamBuilder.cs +++ b/MediaBrowser.Model/Dlna/StreamBuilder.cs @@ -776,7 +776,7 @@ namespace MediaBrowser.Model.Dlna if (directVideoCodec != null) { // merge directVideoCodec to videoCodecs - Array.Resize(ref videoCodecs, (videoCodecs?.Length ?? 0) + 1); + Array.Resize(ref videoCodecs, videoCodecs.Length + 1); videoCodecs[^1] = directVideoCodec; }