aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs
diff options
context:
space:
mode:
authorCody Robibero <cody@robibe.ro>2024-02-28 17:09:23 -0700
committerGitHub <noreply@github.com>2024-02-28 17:09:23 -0700
commitf3c333f4d5bb272b5ffcff29af337ca31e8c374b (patch)
tree008525e157be39a25e013fd3b039d4680760eb68 /MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs
parent54eb81395ef8d3d4cb064b56361ce94fc72b38b5 (diff)
parent4f0f364ac941dc4a856512c9bf0e6b93fdf7b3ab (diff)
Merge branch 'master' into bhowe34/fix-replace-missing-metadata-for-music
Diffstat (limited to 'MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs')
-rw-r--r--MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs23
1 files changed, 20 insertions, 3 deletions
diff --git a/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs b/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs
index 629c30060..317aba418 100644
--- a/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs
+++ b/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs
@@ -30,6 +30,8 @@ namespace MediaBrowser.MediaEncoding.Probing
private const string ArtistReplaceValue = " | ";
private readonly char[] _nameDelimiters = { '/', '|', ';', '\\' };
+ private readonly string[] _webmVideoCodecs = { "av1", "vp8", "vp9" };
+ private readonly string[] _webmAudioCodecs = { "opus", "vorbis" };
private readonly ILogger _logger;
private readonly ILocalizationManager _localization;
@@ -114,7 +116,7 @@ namespace MediaBrowser.MediaEncoding.Probing
if (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.Probing
return 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)
@@ -742,6 +755,10 @@ namespace MediaBrowser.MediaEncoding.Probing
stream.LocalizedExternal = _localization.GetLocalizedString("External");
stream.LocalizedHearingImpaired = _localization.GetLocalizedString("HearingImpaired");
+ // Graphical subtitle may have width and height info
+ stream.Width = streamInfo.Width;
+ stream.Height = streamInfo.Height;
+
if (string.IsNullOrEmpty(stream.Title))
{
// mp4 missing track title workaround: fall back to handler_name if populated and not the default "SubtitleHandler"