fix interlaced check (#2621)

* fix interlaced check

* reset any incorrect interlaced probe results
This commit is contained in:
Jason Dove
2025-11-10 08:39:44 -06:00
committed by GitHub
parent d0505cd5c5
commit b9a73226a8
8 changed files with 13626 additions and 10 deletions
@@ -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,
@@ -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;
}
@@ -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);
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,21 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace ErsatzTV.Infrastructure.MySql.Migrations
{
/// <inheritdoc />
public partial class Reset_InterlacedRatio : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.Sql("UPDATE MediaVersion SET InterlacedRatio = null;");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,21 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace ErsatzTV.Infrastructure.Sqlite.Migrations
{
/// <inheritdoc />
public partial class Reset_InterlacedRatio : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.Sql("UPDATE MediaVersion SET InterlacedRatio = null;");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}
@@ -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