diff options
Diffstat (limited to 'MediaBrowser.MediaEncoding/BdInfo')
| -rw-r--r-- | MediaBrowser.MediaEncoding/BdInfo/BdInfoDirectoryInfo.cs | 13 | ||||
| -rw-r--r-- | MediaBrowser.MediaEncoding/BdInfo/BdInfoExaminer.cs | 76 |
2 files changed, 46 insertions, 43 deletions
diff --git a/MediaBrowser.MediaEncoding/BdInfo/BdInfoDirectoryInfo.cs b/MediaBrowser.MediaEncoding/BdInfo/BdInfoDirectoryInfo.cs index fca17d4c05..dc20a6d631 100644 --- a/MediaBrowser.MediaEncoding/BdInfo/BdInfoDirectoryInfo.cs +++ b/MediaBrowser.MediaEncoding/BdInfo/BdInfoDirectoryInfo.cs @@ -1,3 +1,4 @@ +using System; using System.IO; using System.Linq; using BDInfo.IO; @@ -58,6 +59,8 @@ public class BdInfoDirectoryInfo : IDirectoryInfo } } + private static bool IsHidden(ReadOnlySpan<char> name) => name.StartsWith('.'); + /// <summary> /// Gets the directories. /// </summary> @@ -65,6 +68,7 @@ public class BdInfoDirectoryInfo : IDirectoryInfo public IDirectoryInfo[] GetDirectories() { return _fileSystem.GetDirectories(_impl.FullName) + .Where(d => !IsHidden(d.Name)) .Select(x => new BdInfoDirectoryInfo(_fileSystem, x)) .ToArray(); } @@ -76,6 +80,7 @@ public class BdInfoDirectoryInfo : IDirectoryInfo public IFileInfo[] GetFiles() { return _fileSystem.GetFiles(_impl.FullName) + .Where(d => !IsHidden(d.Name)) .Select(x => new BdInfoFileInfo(x)) .ToArray(); } @@ -84,10 +89,11 @@ public class BdInfoDirectoryInfo : IDirectoryInfo /// Gets the files matching a pattern. /// </summary> /// <param name="searchPattern">The search pattern.</param> - /// <returns>All files of the directory matchign the search pattern.</returns> + /// <returns>All files of the directory matching the search pattern.</returns> public IFileInfo[] GetFiles(string searchPattern) { return _fileSystem.GetFiles(_impl.FullName, new[] { searchPattern }, false, false) + .Where(d => !IsHidden(d.Name)) .Select(x => new BdInfoFileInfo(x)) .ToArray(); } @@ -96,8 +102,8 @@ public class BdInfoDirectoryInfo : IDirectoryInfo /// Gets the files matching a pattern and search options. /// </summary> /// <param name="searchPattern">The search pattern.</param> - /// <param name="searchOption">The search optin.</param> - /// <returns>All files of the directory matchign the search pattern and options.</returns> + /// <param name="searchOption">The search option.</param> + /// <returns>All files of the directory matching the search pattern and options.</returns> public IFileInfo[] GetFiles(string searchPattern, SearchOption searchOption) { return _fileSystem.GetFiles( @@ -105,6 +111,7 @@ public class BdInfoDirectoryInfo : IDirectoryInfo new[] { searchPattern }, false, searchOption == SearchOption.AllDirectories) + .Where(d => !IsHidden(d.Name)) .Select(x => new BdInfoFileInfo(x)) .ToArray(); } diff --git a/MediaBrowser.MediaEncoding/BdInfo/BdInfoExaminer.cs b/MediaBrowser.MediaEncoding/BdInfo/BdInfoExaminer.cs index 8ebb59c59e..6ca994fb7e 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; @@ -60,21 +62,20 @@ public class BdInfoExaminer : IBlurayExaminer var sortedStreams = playlist.SortedStreams; var mediaStreams = new List<MediaStream>(sortedStreams.Count); - foreach (var stream in sortedStreams) + for (int i = 0; i < sortedStreams.Count; i++) { + var stream = sortedStreams[i]; switch (stream) { case TSVideoStream videoStream: - AddVideoStream(mediaStreams, videoStream); + AddVideoStream(mediaStreams, i, videoStream); break; case TSAudioStream audioStream: - AddAudioStream(mediaStreams, audioStream); + AddAudioStream(mediaStreams, i, audioStream); break; - case TSTextStream textStream: - AddSubtitleStream(mediaStreams, textStream); - break; - case TSGraphicsStream graphicStream: - AddSubtitleStream(mediaStreams, graphicStream); + case TSTextStream: + case TSGraphicsStream: + AddSubtitleStream(mediaStreams, i, stream); break; } } @@ -86,7 +87,7 @@ public class BdInfoExaminer : IBlurayExaminer if (playlist.StreamClips is not null && playlist.StreamClips.Count > 0) { // Get the files in the playlist - outputStream.Files = playlist.StreamClips.Select(i => i.StreamFile.Name).ToArray(); + outputStream.Files = playlist.StreamClips.Select(i => i.StreamFile.FileInfo.FullName).ToArray(); } return outputStream; @@ -96,18 +97,19 @@ public class BdInfoExaminer : IBlurayExaminer /// Adds the video stream. /// </summary> /// <param name="streams">The streams.</param> + /// <param name="index">The stream index.</param> /// <param name="videoStream">The video stream.</param> - private void AddVideoStream(List<MediaStream> streams, TSVideoStream videoStream) + private void AddVideoStream(List<MediaStream> streams, int index, TSVideoStream videoStream) { var mediaStream = new MediaStream { BitRate = Convert.ToInt32(videoStream.BitRate), Width = videoStream.Width, Height = videoStream.Height, - Codec = videoStream.CodecShortName, + Codec = GetNormalizedCodec(videoStream), IsInterlaced = videoStream.IsInterlaced, Type = MediaStreamType.Video, - Index = streams.Count + Index = index }; if (videoStream.FrameRateDenominator > 0) @@ -125,17 +127,19 @@ public class BdInfoExaminer : IBlurayExaminer /// Adds the audio stream. /// </summary> /// <param name="streams">The streams.</param> + /// <param name="index">The stream index.</param> /// <param name="audioStream">The audio stream.</param> - private void AddAudioStream(List<MediaStream> streams, TSAudioStream audioStream) + private void AddAudioStream(List<MediaStream> streams, int index, TSAudioStream audioStream) { 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 = streams.Count + Index = index }; var bitrate = Convert.ToInt32(audioStream.BitRate); @@ -145,11 +149,6 @@ public class BdInfoExaminer : IBlurayExaminer stream.BitRate = bitrate; } - if (audioStream.LFE > 0) - { - stream.Channels = audioStream.ChannelCount + 1; - } - streams.Add(stream); } @@ -157,31 +156,28 @@ public class BdInfoExaminer : IBlurayExaminer /// Adds the subtitle stream. /// </summary> /// <param name="streams">The streams.</param> - /// <param name="textStream">The text stream.</param> - private void AddSubtitleStream(List<MediaStream> streams, TSTextStream textStream) + /// <param name="index">The stream index.</param> + /// <param name="stream">The stream.</param> + private void AddSubtitleStream(List<MediaStream> streams, int index, TSStream stream) { streams.Add(new MediaStream { - Language = textStream.LanguageCode, - Codec = textStream.CodecShortName, + Language = stream.LanguageCode, + Codec = GetNormalizedCodec(stream), Type = MediaStreamType.Subtitle, - Index = streams.Count + Index = index }); } - /// <summary> - /// Adds the subtitle stream. - /// </summary> - /// <param name="streams">The streams.</param> - /// <param name="textStream">The text stream.</param> - private void AddSubtitleStream(List<MediaStream> streams, TSGraphicsStream textStream) - { - streams.Add(new MediaStream + private string GetNormalizedCodec(TSStream stream) + => stream.StreamType switch { - Language = textStream.LanguageCode, - Codec = textStream.CodecShortName, - Type = MediaStreamType.Subtitle, - Index = streams.Count - }); - } + TSStreamType.MPEG1_VIDEO => "mpeg1video", + TSStreamType.MPEG2_VIDEO => "mpeg2video", + TSStreamType.VC1_VIDEO => "vc1", + TSStreamType.AC3_PLUS_AUDIO or TSStreamType.AC3_PLUS_SECONDARY_AUDIO => "eac3", + TSStreamType.DTS_AUDIO or TSStreamType.DTS_HD_AUDIO or TSStreamType.DTS_HD_MASTER_AUDIO or TSStreamType.DTS_HD_SECONDARY_AUDIO => "dts", + TSStreamType.PRESENTATION_GRAPHICS => "pgssub", + _ => stream.CodecShortName + }; } |
