Skip to content

Restore IETF Language Tags After Every FFmpeg or HandBrake Rewrite #1148

Closed

Description

@ptr727

Behavior

FFmpeg and HandBrake drop the LanguageIETF element of every track when they write an MKV file. That is #148 and #149. The legacy Language element and the track names survive. A later SetIetfLanguageTags pass has only the ISO 639-2 code left to derive from, so a region or script subtag, such as the CA in fr-CA, cannot come back.

PlexCleaner works around this by restoring each track's IETF tag in place with MkvPropEdit.SetTrackLanguage() after the rewrite. Only some rewrite paths do that.

Rewrite path Tool IETF restored
Convert.ConvertToMkv(), the ReEncode step FFmpeg yes
ProcessFile.DeInterlace() HandBrake yes
ProcessFile.TryLosslessTimestampRepair() and the DtsTimestampRepair plugin FFmpeg setts no
ProcessFile.RemoveClosedCaptions() FFmpeg filter_units no
ProcessFile.RepairAndReVerify(), the re-encode tier FFmpeg, else HandBrake no
Convert.ReMuxToMkv(), the FFmpeg fallback after an MkvMerge failure FFmpeg no

Reproduction

  1. Build a short MKV with one video and one AAC audio track, for example from the lavfi testsrc2 and sine sources.
  2. Set the languages in place with mkvpropedit: video eng with IETF en, audio fre with IETF fr-CA.
  3. Write it with FFmpeg, for example -map 0 -c copy -f matroska.
  4. mkvmerge -J on the output reports language as eng and fre, and language_ietf as null on both tracks.

The loss is in the FFmpeg Matroska muxer, so it does not depend on the codec work. It reproduces on FFmpeg 7.1.5 and on FFmpeg 8.1.2 from the develop Docker image, with a plain stream copy and with a stream copy through the setts or filter_units bitstream filter.

Fix

Restore the IETF tags from the pre-rewrite MkvMergeProps on each path the table marks "no", the same way the ReEncode and DeInterlace steps do.

  • For the lossless timestamp repair, the restore runs after the regression gate and re-verify pass. An in-place header edit leaves the packets alone, so those verdicts still hold. It fits the same post-repair mkvpropedit pass proposed in Decide Whether the Lossless Timestamp Repair Drops Tags Like Every Other Rewrite #1146.
  • For the Convert.ReMuxToMkv() fallback, the input is often not an MKV file and carries no IETF tags, so the restore applies only when it does.
  • A shared helper that every FFmpeg and HandBrake rewrite calls would keep a new path from missing the restore.

Found while testing #1146.

Activity

  1. added
    bug
    on Nov 1, 2026
  2. changed the title [-]Restore the IETF Language That the Lossless Timestamp Repair Drops[/-] [+]Restore IETF Language Tags After Every FFmpeg or HandBrake Rewrite[/+] on Nov 1, 2026
  3. added a commit that references this issue on Nov 1, 2026
    20d692a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions