Repository navigation
Description
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
- Build a short MKV with one video and one AAC audio track, for example from the lavfi
testsrc2andsinesources. - Set the languages in place with
mkvpropedit: videoengwith IETFen, audiofrewith IETFfr-CA. - Write it with FFmpeg, for example
-map 0 -c copy -f matroska. mkvmerge -Jon the output reportslanguageasengandfre, andlanguage_ietfasnullon 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
mkvpropeditpass 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
[-]Restore the IETF Language That the Lossless Timestamp Repair Drops[/-][+]Restore IETF Language Tags After Every FFmpeg or HandBrake Rewrite[/+]Restore IETF Language Tags After Every FFmpeg or HandBrake Rewrite (#…