The Free Software Media System - Server Backend & API
fix: discard webm if there is an unsupported codec
Dmitry Lyzo39088b5ad29c
diff --git a/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs b/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.csindex 629c300603..1ec0622f84 100644--- a/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs+++ b/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs@@ -30,6 +30,8 @@ namespace MediaBrowser.MediaEncoding.Probingprivate const string ArtistReplaceValue = " | ";private readonly char[] _nameDelimiters = { '/', '|', ';', '\\' };+ private readonly string[] _webmVideoCodecs = { "vp8", "vp9" };+ private readonly string[] _webmAudioCodecs = { "opus", "vorbis" };private readonly ILogger _logger;private readonly ILocalizationManager _localization;@@ -114,7 +116,7 @@ namespace MediaBrowser.MediaEncoding.Probingif (data.Format is not null){- info.Container = NormalizeFormat(data.Format.FormatName);+ info.Container = NormalizeFormat(data.Format.FormatName, info.MediaStreams);if (int.TryParse(data.Format.BitRate, CultureInfo.InvariantCulture, out var value)){@@ -260,7 +262,7 @@ namespace MediaBrowser.MediaEncoding.Probingreturn info;}- private string NormalizeFormat(string format)+ private string NormalizeFormat(string format, IReadOnlyList<MediaStream> mediaStreams){if (string.IsNullOrWhiteSpace(format)){@@ -288,9 +290,20 @@ namespace MediaBrowser.MediaEncoding.Probing{splitFormat[i] = "mkv";}++ // Handle WebM+ else if (string.Equals(splitFormat[i], "webm", StringComparison.OrdinalIgnoreCase))+ {+ // Limit WebM to supported codecs+ if (mediaStreams.Any(stream => (stream.Type == MediaStreamType.Video && !_webmVideoCodecs.Contains(stream.Codec, StringComparison.OrdinalIgnoreCase))+ || (stream.Type == MediaStreamType.Audio && !_webmAudioCodecs.Contains(stream.Codec, StringComparison.OrdinalIgnoreCase))))+ {+ splitFormat[i] = string.Empty;+ }+ }}- return string.Join(',', splitFormat);+ return string.Join(',', splitFormat.Where(s => !string.IsNullOrEmpty(s)));}private int? GetEstimatedAudioBitrate(string codec, int? channels)