Skip to content

Promote Develop to Main for the HandBrake Track Check Fix - #1165

Merged
ptr727 merged 1 commit into
mainfrom
develop
Nov 2, 2026
Merged

ptr727 merged 1 commit into
mainfrom
develop

Conversation

@ptr727

@ptr727 ptr727 commented Nov 2, 2026

Copy link
Copy Markdown
Owner

Promotes develop to main, carrying the fix for a 3.23 regression in HandBrake rewrites. The released 3.23.51 carries the regression.

HandBrake rewrites

  • Accept an Undefined Rewritten Video Language Before Restoring Tags #1164: a HandBrake deinterlace, or the HandBrake fallback of a re-encode repair, no longer fails when the source video track carries a language.
    • HandBrake writes the video track as und. The track check that Restore IETF Language Tags After Every FFmpeg or HandBrake Rewrite #1152 added before restoring the IETF tags compared languages exactly, so it refused every such rewrite and the file ended in error.
    • A rewritten video track with an undefined language now passes, and the restore sets its language. A dropped track, a type change, or any other language mismatch still fails the rewrite.
    • A HandBrake output that drops a track, such as encrypted audio with no decoder, still fails and keeps the original with that track, rather than replacing it.

Verification

  • The full-corpus regression run of develop at 3.23.50 showed every HandBrake rewrite of a file with a tagged video language failing.
  • The fix ran on copies of those corpus files inside ptr727/plexcleaner:latest. Every deinterlace succeeds, track counts hold, video languages are restored, and en-GB and en-US region tags survive the HandBrake run and the subtitle merge.
  • Unit tests cover the undefined video and audio cases, a HandBrake deinterlace output that drops audio, and a verify repair of undecodable audio. Mutation checks show each fails without the guard it covers.

🤖 Generated with Claude Code

…1164)

* Accept an Undefined Rewritten Track Language Before Restoring Tags

HandBrake writes the video track language as und, so the track check
that RestoreLanguageTags() runs before restoring the IETF tags failed
every HandBrake deinterlace or re-encode of a file whose video track
carries a language. The original stayed, and the file ended in error.

A rewritten track whose language is undefined now passes the check,
since the restore that follows sets it. A dropped track, a type
change, or a different defined language still fails the rewrite.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Assert the Undefined Track Gets Its Language Back

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Limit the Undefined Language Exception to Video Tracks

Swapped audio tracks written as und would otherwise take each other's
languages, and only HandBrake's video track is written as und.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Test HandBrake Outputs That Drop an Undecodable Audio Track

A deinterlace whose HandBrake output writes the video as und restores
its language, and one whose output drops an audio track fails with the
original untouched. A verify repair of audio with no decoder, such as
encrypted audio, ends RepairFailed when the HandBrake fallback drops
the track, rather than replacing the original with a file missing it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Prove the Track Check Alone Keeps the Original After a Dropped Track

Let the HandBrake output verify clean in the undecodable audio test,
as real output without that audio does, so the original stays only
because the track check refuses it. Share one helper for writing a
changed sample identify, name the video case undefinedvideo, and drop
the comment that ARCHITECTURE.md already states.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Share the Changed Identify and Sample MkvMerge Fakes Through FakeTools

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Drop the Setup Calls That WriteRewriteIdentify Already Makes

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings November 2, 2026 04:11
@coderabbitai

coderabbitai Bot commented Nov 2, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 38 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: c45582f2-3069-4a45-addf-76b11af101a6
Commits

Reviewing files that changed from the base of the PR and between 7083c9c and 5637b6e.

Files selected for processing: 5
  • ARCHITECTURE.md
  • HISTORY.md
  • PlexCleaner/Convert.cs
  • PlexCleanerTests/FakeTools.cs
  • PlexCleanerTests/ReplaceOriginalTests.cs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

Restore tagged video languages after HandBrake rewrites

🐞 Bug fix 🧪 Tests 📝 Documentation 🕐 20-40 Minutes

Grey Divider

AI Description

• Allow HandBrake video tracks written as und to pass validation and regain their original
 language tags.
• Continue rejecting dropped tracks and undefined audio languages before replacing the original
 file.
• Add regression tests for deinterlacing and failed repairs involving undecodable audio.
Diagram

graph TD
  A["HandBrake rewrite"] --> B["Identify output"] --> C{"Tracks match?"}
  C -- "Yes, including und video" --> D["Restore tags"] --> E["Replace original"]
  C -- "No" --> F["Keep original"]
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Apply the exception only at HandBrake call sites
  • ➕ Confines the relaxed check to the tool known to write video language as und.
  • ➖ Requires tool-specific validation behavior outside the shared restoration path.

Recommendation: Keep the shared track validator's video-only exception. Restoration already has the original language, and the count, number, and type checks still protect against dropped or misidentified tracks. The HandBrake-specific alternative offers tighter scoping but adds complexity without changing those safeguards.

Files changed (5) +165 / -14

Bug fix (1) +4 / -1
Convert.csAccept undefined rewritten video language during track validation +4/-1

Accept undefined rewritten video language during track validation

• Allows a video track reported with an undefined language to match its original before language tags are restored. Audio and subtitle languages still require an exact match, as do track number and type.

PlexCleaner/Convert.cs

Tests (2) +159 / -12
FakeTools.csSupport customized fake MkvMerge identify responses +19/-2

Support customized fake MkvMerge identify responses

• Adds a helper to mutate sample identify data and an option to serve a custom identify response before the default response. This lets tests give rewritten outputs different tracks from the source.

PlexCleanerTests/FakeTools.cs

ReplaceOriginalTests.csCover HandBrake language restoration and dropped-track failures +140/-10

Cover HandBrake language restoration and dropped-track failures

• Tests acceptance and restoration of undefined video language while rejecting undefined audio and dropped tracks. End-to-end fake-tool cases check deinterlace success, preservation of the original on a dropped audio track, and failed repair state for undecodable audio; test configuration is restored after each run.

PlexCleanerTests/ReplaceOriginalTests.cs

Documentation (2) +2 / -1
ARCHITECTURE.mdDocument the undefined-video exception +1/-1

Document the undefined-video exception

• Clarifies that an undefined language on a rewritten video track passes validation because tag restoration sets its language afterward.

ARCHITECTURE.md

HISTORY.mdRecord the HandBrake language restoration fix +1/-0

Record the HandBrake language restoration fix

• Notes that HandBrake deinterlace and re-encode no longer fail solely because they write the video language as 'und'.

HISTORY.md

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

Tip of the day
💡 Did you know, you can copy the agent prompt from any finding and feed it to your IDE agent

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

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.

🟢 Approval recommended

No active blocking issues remain; the change includes regression coverage for accepted undefined video languages and continued rejection of dropped or mismatched tracks, with only non-blocking comment nits noted.

No open issues 🎉

What changed in this PR

Promotes develop to main with the HandBrake track-validation fix. Rewritten video tracks reported with an undefined language are accepted and restored, while dropped or mismatched tracks remain rejected.

Changes:

  • Allow undefined rewritten video languages during track matching.
  • Add regression coverage for HandBrake deinterlace and repair scenarios.
  • Update test helpers and document the corrected behavior.
  • Two non-blocking comment-clarity nits were identified in test comments.

This pull request is ready to be approved.

File Summary
PlexCleanerTests/​ReplaceOriginalTests.cs Adds regression coverage for undefined video languages, dropped tracks, and original-file preservation.
PlexCleanerTests/​FakeTools.cs Adds reusable identify-data mutation and conditional fake-tool response helpers.
PlexCleaner/​Convert.cs Accepts undefined rewritten video languages before restoring original tags.
HISTORY.md Records the HandBrake language-restoration fix.
ARCHITECTURE.md Documents the updated rewrite validation and language-restoration behavior.

Review effort: Lite

@ptr727
ptr727 merged commit 561f4f6 into main Nov 2, 2026
24 checks passed
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