Apply review suggestions

This commit is contained in:
Shadowghost 2023-02-05 17:24:13 +01:00 committed by Shadowghost
parent 979964ef4b
commit 2403a0a367
5 changed files with 51 additions and 53 deletions

View File

@ -325,7 +325,7 @@ public class TranscodingJobHelper : IDisposable
await 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);
}
}

View File

@ -943,7 +943,7 @@ namespace MediaBrowser.Controller.MediaEncoding
if (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 ")

View File

@ -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 found
if (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 titles
return 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.Encoder
public 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.Encoder
foreach (var path in files)
{
var fileinfo = _fileSystem.GetFileInfo(path);
var mediaInfoResult = GetMediaInfo(
new MediaInfoRequest
{
@ -961,7 +961,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
lines.Add("duration " + duration);
}
File.WriteAllLinesAsync(concatFilePath, lines, CancellationToken.None).GetAwaiter().GetResult();
File.WriteAllLines(concatFilePath, lines);
}
public bool CanExtractSubtitles(string codec)

View File

@ -639,7 +639,6 @@ namespace MediaBrowser.Model.Dlna
if (item.VideoType == VideoType.Dvd || item.VideoType == VideoType.BluRay)
{
isEligibleForDirectPlay = false;
isEligibleForDirectStream = false;
}
if (bitrateLimitExceeded)

View File

@ -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)
var videoStream = mediaStreams.FirstOrDefault(s => s.Type == MediaStreamType.Video);
// Grab the values that ffprobe recorded
if (videoStream is not null)
{
currentBitRate = videoStream.BitRate;
currentWidth = videoStream.Width;
currentHeight = videoStream.Height;
}
// Fill video properties from the BDInfo result
mediaStreams.Clear();
mediaStreams.AddRange(blurayInfo.MediaStreams);
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++)
{
currentBitRate = videoStream.BitRate;
currentWidth = videoStream.Width;
currentHeight = videoStream.Height;
}
// Fill video properties from the BDInfo result
mediaStreams.Clear();
mediaStreams.AddRange(blurayInfo.MediaStreams);
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++)
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
{