diff --git a/ErsatzTV.Core/FFmpeg/FFmpegLibraryProcessService.cs b/ErsatzTV.Core/FFmpeg/FFmpegLibraryProcessService.cs index cda60f977..107b035dc 100644 --- a/ErsatzTV.Core/FFmpeg/FFmpegLibraryProcessService.cs +++ b/ErsatzTV.Core/FFmpeg/FFmpegLibraryProcessService.cs @@ -222,7 +222,11 @@ public class FFmpegLibraryProcessService : IFFmpegProcessService }; }); - ScanKind scanKind = await ProbeScanKind(ffmpegPath, videoVersion.MediaItem, cancellationToken); + ScanKind scanKind = ScanKind.Progressive; + if (playbackSettings.Deinterlace) + { + scanKind = await ProbeScanKind(ffmpegPath, videoVersion.MediaItem, cancellationToken); + } var ffmpegVideoStream = new VideoStream( videoStream.Index, diff --git a/ErsatzTV.Core/FFmpeg/FFmpegPlaybackSettingsCalculator.cs b/ErsatzTV.Core/FFmpeg/FFmpegPlaybackSettingsCalculator.cs index 1f0ebab8b..4fefed49c 100644 --- a/ErsatzTV.Core/FFmpeg/FFmpegPlaybackSettingsCalculator.cs +++ b/ErsatzTV.Core/FFmpeg/FFmpegPlaybackSettingsCalculator.cs @@ -165,8 +165,7 @@ public static class FFmpegPlaybackSettingsCalculator result.PadAudio = true; result.NormalizeLoudnessMode = ffmpegProfile.NormalizeLoudnessMode; - result.Deinterlace = ffmpegProfile.DeinterlaceVideo == true && - videoVersion.VideoScanKind == VideoScanKind.Interlaced; + result.Deinterlace = ffmpegProfile.DeinterlaceVideo == true; break; } diff --git a/ErsatzTV.FFmpeg/Pipeline/PipelineBuilderBase.cs b/ErsatzTV.FFmpeg/Pipeline/PipelineBuilderBase.cs index 703248bfb..c4ad848d3 100644 --- a/ErsatzTV.FFmpeg/Pipeline/PipelineBuilderBase.cs +++ b/ErsatzTV.FFmpeg/Pipeline/PipelineBuilderBase.cs @@ -250,7 +250,7 @@ public abstract class PipelineBuilderBase : IPipelineBuilder _watermarkInputFile.IsSome, _subtitleInputFile.Map(s => s is { IsImageBased: true, Method: SubtitleMethod.Burn }).IfNone(false), _subtitleInputFile.Map(s => s is { IsImageBased: false, Method: SubtitleMethod.Burn }).IfNone(false), - desiredState.Deinterlaced, + desiredState.Deinterlaced && videoStream.ScanKind is ScanKind.Interlaced, desiredState.BitDepth == 10, false, videoStream.ColorParams.IsHdr); diff --git a/ErsatzTV.Infrastructure/Metadata/LocalStatisticsProvider.cs b/ErsatzTV.Infrastructure/Metadata/LocalStatisticsProvider.cs index e09b982df..4cf827e94 100644 --- a/ErsatzTV.Infrastructure/Metadata/LocalStatisticsProvider.cs +++ b/ErsatzTV.Infrastructure/Metadata/LocalStatisticsProvider.cs @@ -309,17 +309,21 @@ public partial class LocalStatisticsProvider : ILocalStatisticsProvider var stats = new IdetStatistics(); - var singleMatch = SingleFrameRegex().Match(idet.StandardOutput); - if (singleMatch.Success) + //_logger.LogDebug("StdErr: {Match}", idet.StandardError); + + var singleMatch = SingleFrameRegex().Matches(idet.StandardError).LastOrDefault(); + if (singleMatch?.Success == true) { + _logger.LogDebug("Matched single frame: {Match}", singleMatch.Value); stats.SingleTff = int.Parse(singleMatch.Groups[1].Value, NumberFormatInfo.InvariantInfo); stats.SingleBff = int.Parse(singleMatch.Groups[2].Value, NumberFormatInfo.InvariantInfo); stats.SingleProgressive = int.Parse(singleMatch.Groups[3].Value, NumberFormatInfo.InvariantInfo); } - var multiMatch = MultiFrameRegex().Match(idet.StandardOutput); - if (multiMatch.Success) + var multiMatch = MultiFrameRegex().Matches(idet.StandardError).LastOrDefault(); + if (multiMatch?.Success == true) { + _logger.LogDebug("Matched multi frame: {Match}", multiMatch.Value); stats.MultiTff = int.Parse(multiMatch.Groups[1].Value, NumberFormatInfo.InvariantInfo); stats.MultiBff = int.Parse(multiMatch.Groups[2].Value, NumberFormatInfo.InvariantInfo); stats.MultiProgressive = int.Parse(multiMatch.Groups[3].Value, NumberFormatInfo.InvariantInfo); @@ -699,10 +703,10 @@ public partial class LocalStatisticsProvider : ILocalStatisticsProvider [GeneratedRegex(@"\[SAR\s+([0-9]+:[0-9]+)\s+DAR\s+([0-9]+:[0-9]+)\]")] private static partial Regex SarDarRegex(); - [GeneratedRegex(@"Single frame detection: TFF: (\d+) BFF: (\d+) Progressive: (\d+)")] + [GeneratedRegex(@"Single frame detection: TFF:\s+(\d+) BFF:\s+(\d+) Progressive:\s+(\d+)")] private static partial Regex SingleFrameRegex(); - [GeneratedRegex(@"Multi frame detection: TFF: (\d+) BFF: (\d+) Progressive: (\d+)")] + [GeneratedRegex(@"Multi frame detection: TFF:\s+(\d+) BFF:\s+(\d+) Progressive:\s+(\d+)")] private static partial Regex MultiFrameRegex(); private class IdetStatistics