diff --git a/MediaBrowser.MediaEncoding/BdInfo/BdInfoExaminer.cs b/MediaBrowser.MediaEncoding/BdInfo/BdInfoExaminer.cs index 0b17cffb5b..e1a5d1d2bd 100644 --- a/MediaBrowser.MediaEncoding/BdInfo/BdInfoExaminer.cs +++ b/MediaBrowser.MediaEncoding/BdInfo/BdInfoExaminer.cs @@ -1,7 +1,9 @@ using System; using System.Collections.Generic; +using System.Globalization; using System.Linq; using BDInfo; +using Jellyfin.Extensions; using MediaBrowser.Model.Entities; using MediaBrowser.Model.IO; using MediaBrowser.Model.MediaInfo; @@ -104,7 +106,7 @@ public class BdInfoExaminer : IBlurayExaminer BitRate = Convert.ToInt32(videoStream.BitRate), Width = videoStream.Width, Height = videoStream.Height, - Codec = videoStream.CodecShortName, + Codec = GetNormalizedCodec(videoStream), IsInterlaced = videoStream.IsInterlaced, Type = MediaStreamType.Video, Index = index @@ -131,9 +133,10 @@ public class BdInfoExaminer : IBlurayExaminer { var stream = new MediaStream { - Codec = audioStream.CodecShortName, + Codec = GetNormalizedCodec(audioStream), Language = audioStream.LanguageCode, - Channels = audioStream.ChannelCount, + ChannelLayout = string.Format(CultureInfo.InvariantCulture, "{0:D}.{1:D}", audioStream.ChannelCount, audioStream.LFE), + Channels = audioStream.ChannelCount + audioStream.LFE, SampleRate = audioStream.SampleRate, Type = MediaStreamType.Audio, Index = index @@ -146,11 +149,6 @@ public class BdInfoExaminer : IBlurayExaminer stream.BitRate = bitrate; } - if (audioStream.LFE > 0) - { - stream.Channels = audioStream.ChannelCount + 1; - } - streams.Add(stream); } @@ -159,24 +157,26 @@ public class BdInfoExaminer : IBlurayExaminer /// /// The streams. /// The stream index. - /// The stream. - private void AddSubtitleStream(List streams, int index, TSStream textStream) + /// The stream. + private void AddSubtitleStream(List streams, int index, TSStream stream) { streams.Add(new MediaStream { - Language = textStream.LanguageCode, - Codec = NormalizeSubtitleCodec(textStream.StreamType), + Language = stream.LanguageCode, + Codec = GetNormalizedCodec(stream), Type = MediaStreamType.Subtitle, Index = index }); } - private string NormalizeSubtitleCodec(TSStreamType codec) - => codec switch + private string GetNormalizedCodec(TSStream stream) + => stream.StreamType switch { - TSStreamType.INTERACTIVE_GRAPHICS => "igs", + TSStreamType.MPEG1_VIDEO => "mpeg1video", + TSStreamType.MPEG2_VIDEO => "mpeg2video", + TSStreamType.VC1_VIDEO => "vc1", + TSStreamType.AC3_PLUS_AUDIO | TSStreamType.AC3_PLUS_SECONDARY_AUDIO => "eac3", TSStreamType.PRESENTATION_GRAPHICS => "pgssub", - TSStreamType.SUBTITLE => "sub", - _ => throw new ArgumentOutOfRangeException(nameof(codec), $"Invalid stream type for subtitle: {codec}") + _ => stream.CodecShortName }; }