Skip to content

Fix DTS repair escalation and idet parse regressions - #844

Merged
ptr727 merged 3 commits into
developfrom
fix/repair-escalation-and-idet-parse
Jul 15, 2026
Merged

Fix DTS repair escalation and idet parse regressions#844
ptr727 merged 3 commits into
developfrom
fix/repair-escalation-and-idet-parse

Conversation

@ptr727

@ptr727 ptr727 commented Jul 15, 2026

Copy link
Copy Markdown
Owner

Follow-ups from the 3.20→3.21 regression diff. Two files-flip-to-failed regressions plus a diagnostics/logging improvement.

1. idet parse robustness (interlace detection)

VC1 - National Lampoon's Christmas Vacation regressed to an Error (Failed to parse idet outputFailed to count interlaced frames), aborting the file before it could be re-encoded.

Root cause (confirmed against ground-truth ffmpeg output): the parser required the three idet stat lines contiguous. The idet command uses InputOptions.Default(), which adds -fflags +genpts; on a source with non-monotonic DTS the -f null muxer emits "non monotonically increasing dts to muxer" warnings interleaved with the idet stats, and a full-file scan decodes enough packets that a warning lands between the stat lines → matches.Count == 0.

Fix: match each stat line independently and take the last of each (robust to interleaving; still selects the final counts over idet's early all-zero pass). Log the raw idet output on a parse failure. An idet failure stays a hard error that aborts the file — it is unexpected, so it should surface as a bug, not be masked. Regression test added with warnings interspersed between the stat lines.

2. DTS repair escalation

Six files that were Repaired, Verified pre-3.21 became RepairFailed (50 First Dates, Kill Bill, Bitrate Love Island, Running Wild, Diplo, 90 Day). A non-monotonic DTS that the lossless audio setts repair couldn't fix (video-stream or post-decode) was marked RepairFailed with no further attempt; a full re-encode fixes these and the pre-3.21 pipeline relied on it.

Fix: the DTS path now escalates through the standard tiers — surgical lossless setts → plain remux → re-encode — marking Repaired on the first tier whose re-verify is clean, RepairFailed only when all fail. Added the missing remux tier to RepairAndReVerify so the DTS and decode-error paths share one surgical → remux → re-encode ladder.

3. Per-file processing time

Time each file's task in the driver and log it on the After line (elapsed before the file name), sharing one HH:mm:ss.fff formatter with the run summary (hours from TotalHours, no multi-day wrap).

Validation

Local build + develop image ffmpeg 8.0.1, --parallel --testsnippets:

  • VC1 clip → ReMuxed, ReEncoded, Verified, no idet failure (was abort).
  • Diplo (post-decode DTS) → Repaired, Verified via setts→remux→re-encode (was RepairFailed).

217 tests pass; build + format clean.

🤖 Generated with Claude Code

ptr727 and others added 3 commits July 15, 2026 08:33
The interlace detector required the three idet stat lines (Repeated
Fields / Single frame / Multi frame) to be a single contiguous block.
ffmpeg interleaves other stderr lines between them: on a source with
non-monotonic DTS the -f null muxer emits "non monotonically increasing
dts to muxer" warnings (idet uses -fflags +genpts), and a full-file scan
decodes enough packets that a warning lands between the stat lines. The
contiguous match then finds nothing, so the parse fails and the whole
file is aborted, skipping the remux/re-encode that would repair it.

Match each stat line independently and take the last of each: robust to
interleaved warnings, and it still selects the final cumulative counts
over idet's early all-zero pass. Log the raw idet output on a parse
failure so any remaining unexpected case is diagnosable rather than
guessed at. An idet failure stays a hard error that aborts the file: it
is unexpected, so it should surface as a bug to fix, not be masked.

Adds a regression test with warnings interspersed between the stat lines.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
A non-monotonic DTS verify failure only tried the lossless audio setts
repair; when that did not apply (a video-stream or post-decode DTS) the
file was marked RepairFailed with no further attempt. A full re-encode
rebuilds the timestamps and does fix these, which the pre-3.21 pipeline
relied on, so several files that used to repair now fail.

Make the DTS path escalate through the standard repair tiers: surgical
lossless setts, then a plain remux, then a re-encode, marking Repaired
on the first tier whose re-verify is clean and RepairFailed only when all
tiers fail. Add the missing remux tier to RepairAndReVerify so both the
DTS and decode-error paths share the same surgical -> remux -> re-encode
escalation.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Time each file's task in ProcessDriver and report it on the "After" line,
with the elapsed before the file name (file name last, being longest).
Share one HH:mm:ss.fff formatter with the run summary so both read the
same; hours come from TotalHours so a multi-day run does not wrap.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 15, 2026 15:49

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses two media-processing regressions introduced in the 3.20 -> 3.21 transition (idet parsing and DTS repair escalation) and adds more consistent per-file timing diagnostics in the processing driver.

Changes:

  • Make ffmpeg idet parsing robust to interleaved stderr output by matching each stats line independently, and log the raw output on parse failure.
  • Escalate non-monotonic DTS repairs through the standard repair tiers (lossless setts -> remux -> re-encode) instead of stopping after setts failure.
  • Add per-file elapsed timing (plus consistent duration formatting) to driver logging, with targeted tests.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
PlexCleaner/FfMpegIdetInfo.cs Reworks idet parsing to tolerate interleaved warnings and improves failure diagnostics.
PlexCleaner/ProcessFile.cs Adds a remux repair tier and escalates DTS repair through remux/re-encode fallbacks.
PlexCleaner/ProcessDriver.cs Times per-file processing and introduces a shared FormatDuration() for consistent elapsed logging.
PlexCleanerTests/FfMpegIdetParsingTests.cs Adds regression coverage for idet output with interleaved non-monotonic DTS warnings and updates parsing assertions.
PlexCleanerTests/ProcessDriverTests.cs Adds unit coverage for FormatDuration() millisecond precision and multi-day hour accumulation.

Comment thread PlexCleaner/ProcessDriver.cs
Comment thread PlexCleaner/ProcessDriver.cs
@ptr727
ptr727 merged commit aa49adc into develop Jul 15, 2026
15 checks passed
@ptr727
ptr727 deleted the fix/repair-escalation-and-idet-parse branch July 15, 2026 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants