The Free Software Media System - Server Backend & API
Apply review suggestions
Shadowghost2403a0a36792
diff --git a/Jellyfin.Api/Helpers/TranscodingJobHelper.cs b/Jellyfin.Api/Helpers/TranscodingJobHelper.csindex 1ba7395508..3bb3ad358f 100644--- a/Jellyfin.Api/Helpers/TranscodingJobHelper.cs+++ b/Jellyfin.Api/Helpers/TranscodingJobHelper.cs@@ -325,7 +325,7 @@ public class TranscodingJobHelper : IDisposableawait DeletePartialStreamFiles(job.Path!, job.Type, 0, 1500).ConfigureAwait(false);if (job.MediaSource?.VideoType == VideoType.Dvd || job.MediaSource?.VideoType == VideoType.BluRay){- var path = Path.Join(job.Path, "/" + job.MediaSource.Id + ".concat");+ var path = Path.Join(job.Path, job.MediaSource.Id + ".concat");File.Delete(path);}}diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.csindex 075e33cb82..3789bcac90 100644--- a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs+++ b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs@@ -943,7 +943,7 @@ namespace MediaBrowser.Controller.MediaEncodingif (state.MediaSource.VideoType == VideoType.Dvd || state.MediaSource.VideoType == VideoType.BluRay){- var tmpConcatPath = Path.Join(options.TranscodingTempPath, "/" + state.MediaSource.Id + ".concat");+ var tmpConcatPath = Path.Join(options.TranscodingTempPath, state.MediaSource.Id + ".concat");_mediaEncoder.GenerateConcatConfig(state.MediaSource, tmpConcatPath);arg.Append(" -f concat -safe 0 ").Append(" -i ")diff --git a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.csindex 347e1de50a..49c81923b4 100644--- a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs+++ b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs@@ -11,6 +11,7 @@ using System.Text.Json;using System.Text.RegularExpressions;using System.Threading;using System.Threading.Tasks;+using Jellyfin.Extensions;using Jellyfin.Extensions.Json;using Jellyfin.Extensions.Json.Converters;using MediaBrowser.Common;@@ -896,7 +897,7 @@ namespace MediaBrowser.MediaEncoding.Encoder// Check for multiple big titles (> 900 MB)var titles = allVobs.Where(vob => vob.Length >= 900 * 1024 * 1024)- .Select(vob => _fileSystem.GetFileNameWithoutExtension(vob).Split('_')[1])+ .Select(vob => _fileSystem.GetFileNameWithoutExtension(vob).AsSpan().RightPart('_').ToString()).GroupBy(x => x).Select(y => y.First()).ToList();@@ -904,12 +905,12 @@ namespace MediaBrowser.MediaEncoding.Encoder// Fall back to first title if no big title is foundif (titles.FirstOrDefault() == null){- titles.Add(_fileSystem.GetFileNameWithoutExtension(allVobs[0]).Split('_')[1]);+ titles.Add(_fileSystem.GetFileNameWithoutExtension(allVobs[0]).AsSpan().RightPart('_').ToString());}// Aggregate all VOBs of the titlesreturn allVobs- .Where(vob => titles.Contains(_fileSystem.GetFileNameWithoutExtension(vob).Split('_')[1]))+ .Where(vob => titles.Contains(_fileSystem.GetFileNameWithoutExtension(vob).AsSpan().RightPart('_').ToString())).Select(i => i.FullName).ToList();}@@ -917,7 +918,7 @@ namespace MediaBrowser.MediaEncoding.Encoderpublic IEnumerable<string> GetPrimaryPlaylistM2TsFiles(string path, uint? titleNumber){var validPlaybackFiles = _blurayExaminer.GetDiscInfo(path).Files;- var directoryFiles = _fileSystem.GetFiles(path + "/BDMV/STREAM/");+ var directoryFiles = _fileSystem.GetFiles(Path.Join(path, "BDMV", "STREAM"));return directoryFiles.Where(f => validPlaybackFiles.Contains(f.Name, StringComparer.OrdinalIgnoreCase))@@ -941,7 +942,6 @@ namespace MediaBrowser.MediaEncoding.Encoderforeach (var path in files){- var fileinfo = _fileSystem.GetFileInfo(path);var mediaInfoResult = GetMediaInfo(new MediaInfoRequest{@@ -961,7 +961,7 @@ namespace MediaBrowser.MediaEncoding.Encoderlines.Add("duration " + duration);}- File.WriteAllLinesAsync(concatFilePath, lines, CancellationToken.None).GetAwaiter().GetResult();+ File.WriteAllLines(concatFilePath, lines);}public bool CanExtractSubtitles(string codec)diff --git a/MediaBrowser.Model/Dlna/StreamBuilder.cs b/MediaBrowser.Model/Dlna/StreamBuilder.csindex f6c930f5c8..ef73096b43 100644--- a/MediaBrowser.Model/Dlna/StreamBuilder.cs+++ b/MediaBrowser.Model/Dlna/StreamBuilder.cs@@ -639,7 +639,6 @@ namespace MediaBrowser.Model.Dlnaif (item.VideoType == VideoType.Dvd || item.VideoType == VideoType.BluRay){isEligibleForDirectPlay = false;- isEligibleForDirectStream = false;}if (bitrateLimitExceeded)diff --git a/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs b/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.csindex 0ec7b368b4..f75de47f30 100644--- a/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs+++ b/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs@@ -328,54 +328,56 @@ namespace MediaBrowser.Providers.MediaInfo{var video = (Video)item;- // Use BD Info if it has multiple m2ts. Otherwise, treat it like a video file and rely more on ffprobe output- if (blurayInfo.Files.Length > 1)+ if (blurayInfo.Files.Length <= 1){- int? currentHeight = null;- int? currentWidth = null;- int? currentBitRate = null;+ return;+ }- var videoStream = mediaStreams.FirstOrDefault(s => s.Type == MediaStreamType.Video);+ // Use BD Info if it has multiple m2ts. Otherwise, treat it like a video file and rely more on ffprobe output+ int? currentHeight = null;+ int? currentWidth = null;+ int? currentBitRate = null;- // Grab the values that ffprobe recorded- if (videoStream is not null)- {- currentBitRate = videoStream.BitRate;- currentWidth = videoStream.Width;- currentHeight = videoStream.Height;- }+ var videoStream = mediaStreams.FirstOrDefault(s => s.Type == MediaStreamType.Video);- // Fill video properties from the BDInfo result- mediaStreams.Clear();- mediaStreams.AddRange(blurayInfo.MediaStreams);+ // Grab the values that ffprobe recorded+ if (videoStream is not null)+ {+ currentBitRate = videoStream.BitRate;+ currentWidth = videoStream.Width;+ currentHeight = videoStream.Height;+ }- if (blurayInfo.RunTimeTicks.HasValue && blurayInfo.RunTimeTicks.Value > 0)- {- video.RunTimeTicks = blurayInfo.RunTimeTicks;- }+ // Fill video properties from the BDInfo result+ mediaStreams.Clear();+ mediaStreams.AddRange(blurayInfo.MediaStreams);- if (blurayInfo.Chapters is not null)+ if (blurayInfo.RunTimeTicks.HasValue && blurayInfo.RunTimeTicks.Value > 0)+ {+ video.RunTimeTicks = blurayInfo.RunTimeTicks;+ }++ if (blurayInfo.Chapters is not null)+ {+ double[] brChapter = blurayInfo.Chapters;+ chapters = new ChapterInfo[brChapter.Length];+ for (int i = 0; i < brChapter.Length; i++){- double[] brChapter = blurayInfo.Chapters;- chapters = new ChapterInfo[brChapter.Length];- for (int i = 0; i < brChapter.Length; i++)+ chapters[i] = new ChapterInfo{- chapters[i] = new ChapterInfo- {- StartPositionTicks = TimeSpan.FromSeconds(brChapter[i]).Ticks- };- }+ StartPositionTicks = TimeSpan.FromSeconds(brChapter[i]).Ticks+ };}+ }- videoStream = mediaStreams.FirstOrDefault(s => s.Type == MediaStreamType.Video);+ videoStream = mediaStreams.FirstOrDefault(s => s.Type == MediaStreamType.Video);- // Use the ffprobe values if these are empty- if (videoStream is not null)- {- videoStream.BitRate = IsEmpty(videoStream.BitRate) ? currentBitRate : videoStream.BitRate;- videoStream.Width = IsEmpty(videoStream.Width) ? currentWidth : videoStream.Width;- videoStream.Height = IsEmpty(videoStream.Height) ? currentHeight : videoStream.Height;- }+ // Use the ffprobe values if these are empty+ if (videoStream is not null)+ {+ videoStream.BitRate = IsEmpty(videoStream.BitRate) ? currentBitRate : videoStream.BitRate;+ videoStream.Width = IsEmpty(videoStream.Width) ? currentWidth : videoStream.Width;+ videoStream.Height = IsEmpty(videoStream.Height) ? currentHeight : videoStream.Height;}}@@ -391,10 +393,7 @@ namespace MediaBrowser.Providers.MediaInfo/// <returns>VideoStream.</returns>private BlurayDiscInfo GetBDInfo(string path){- if (string.IsNullOrWhiteSpace(path))- {- throw new ArgumentNullException(nameof(path));- }+ ArgumentException.ThrowIfNullOrEmpty(path);try{