You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Decide Whether the Lossless Timestamp Repair Drops Tags Like Every Other Rewrite #1146
Every step that rewrites a file writes its output through MkvMerge with MkvMergeBuilder.InputOptions.Default(), which drops global tags, track tags, attachments, and buttons whatever RemoveTags says. That keeps a tool from adding tags during processing.
The lossless timestamp repair is the one rewrite that skips that pass. TryLosslessTimestampRepair() runs FfMpeg.SetTimestamps() (-map 0 -c copy with the setts bitstream filter) to a .tmp14 file, then moves it over the original after the regression gate and a clean re-verify. No Convert.ReMux() runs in between. The DtsTimestampRepair plugin calls the same method.
So with RemoveTags off, the repaired file keeps its tags and attachments and can carry the tags the FfMpeg Matroska muxer writes. In the plugin path no RemoveTags() runs afterwards, so that holds even with RemoveTags on.
Reproduction shape
Set RemoveTags to false.
Process an MKV file that carries a title tag and has non-monotonic DTS on an audio stream only, so VerifyAndRepair() takes the lossless tier.
The repaired file keeps the title tag and gains FfMpeg's muxer tags.
Decision needed
Whether the lossless repair gets an MkvMerge pass, for example Convert.ReMux() after SetTimestamps() and before TimestampRepairRegressionGate(). That needs a real-media check that the MkvMerge pass keeps the repaired timestamps, and that the regression gate and re-verify judge the remuxed output. Otherwise the exception stays as documented in ARCHITECTURE.md "Remux and Container Steps".
The test clip is synthetic. It is 10 seconds of H.264 video and AAC audio from the lavfi testsrc2 and sine sources. A setts expression gives the audio track three duplicate DTS. mkvpropedit then adds the following in place, without a remux:
a segment title
a global COMMENT tag
a track tag on the audio track
a text attachment
chapters
track languages with IETF tags, and an audio track name
I ran the exact SetTimestamps() command line on FFmpeg 7.1.5 and on FFmpeg 8.1.2 from the develop Docker image. The results are the same on each.
Does setts Add Tags
Yes. The current command keeps every source tag, the title, and the attachment. It also adds a global ENCODER tag and a DURATION tag on every track. So mkvmerge -J reports global and track tags after every lossless repair, even for a source with no tags.
Can the Same Command Remove Them
Only partly.
Extra output arguments
Title, global tags, ENCODER
Attachment
Source track tags
DURATION tags
Track language
none (current)
kept
kept
kept
added
kept
-map -0:t -map_metadata:g -1 -fflags +bitexact
removed
removed
kept
added
kept
-map -0:t -map_metadata -1 -fflags +bitexact
removed
removed
removed
added
reset to und
The Matroska muxer writes DURATION on any seekable output. ffmpeg -h muxer=matroska lists no option to turn it off, other than -live 1, which also changes cues and duration.
FFmpeg reads source track tags into the same stream metadata that holds the language. Dropping the tags drops the language with them.
So one FFmpeg command cannot produce tag-free output, and a second pass is needed.
Gate Interaction
The streamhash muxer emits a line for each attachment, such as 2,t,MD5=..., and GetStreamHashes() keeps it. So removing the attachment in the setts command changes the stream count, and TimestampRepairRegressionGate() rejects a good repair. The same holds for an MkvMerge remux before the gate, as the issue suggests. A pass that drops attachments has to run after the gate, or the gate has to compare only video, audio, and subtitle streams.
Second Pass on the setts Output
Pass
Video and audio streamhash
Audio non-monotonic DTS
Result
mkvpropedit --tags all: --delete title
identical to source
0
no tags, no title, attachment kept
MkvMerge with the InputOptions.Default() and GlobalOptions.Default() flags
identical to source
0
no tags, no attachment, title kept
Both kept the repaired timestamps on this clip. The mkvpropedit pass edits headers in place and leaves the packets alone. So the gate and re-verify verdicts on the setts output still hold after it. A remux rebuilds the timestamps, so the gate and re-verify would have to judge its output.
Recommendation
Keep the setts command as it is. After the gate, the re-verify, and the move succeed, run an in-place mkvpropedit pass inside TryLosslessTimestampRepair(), so the plugin path gets it too. For parity with the MkvMerge rewrites, that pass deletes all tags and attachments and keeps the segment title and track names. MkvPropEdit.ClearTags() also deletes the title and track names, so it does more than the other rewrites do.
The same test found that setts drops the IETF language of every track. That is #1148, and its restore fits the same mkvpropedit pass.
Activity
ptr727 commentedon Nov 1, 2026
Test Results
The test clip is synthetic. It is 10 seconds of H.264 video and AAC audio from the lavfi
testsrc2andsinesources. Asettsexpression gives the audio track three duplicate DTS.mkvpropeditthen adds the following in place, without a remux:COMMENTtagI ran the exact
SetTimestamps()command line on FFmpeg 7.1.5 and on FFmpeg 8.1.2 from thedevelopDocker image. The results are the same on each.Does
settsAdd TagsYes. The current command keeps every source tag, the title, and the attachment. It also adds a global
ENCODERtag and aDURATIONtag on every track. Somkvmerge -Jreports global and track tags after every lossless repair, even for a source with no tags.Can the Same Command Remove Them
Only partly.
ENCODERDURATIONtags-map -0:t -map_metadata:g -1 -fflags +bitexact-map -0:t -map_metadata -1 -fflags +bitexactundDURATIONon any seekable output.ffmpeg -h muxer=matroskalists no option to turn it off, other than-live 1, which also changes cues and duration.So one FFmpeg command cannot produce tag-free output, and a second pass is needed.
Gate Interaction
The
streamhashmuxer emits a line for each attachment, such as2,t,MD5=..., andGetStreamHashes()keeps it. So removing the attachment in thesettscommand changes the stream count, andTimestampRepairRegressionGate()rejects a good repair. The same holds for an MkvMerge remux before the gate, as the issue suggests. A pass that drops attachments has to run after the gate, or the gate has to compare only video, audio, and subtitle streams.Second Pass on the
settsOutputstreamhashmkvpropedit --tags all: --delete titleInputOptions.Default()andGlobalOptions.Default()flagsBoth kept the repaired timestamps on this clip. The
mkvpropeditpass edits headers in place and leaves the packets alone. So the gate and re-verify verdicts on thesettsoutput still hold after it. A remux rebuilds the timestamps, so the gate and re-verify would have to judge its output.Recommendation
Keep the
settscommand as it is. After the gate, the re-verify, and the move succeed, run an in-placemkvpropeditpass insideTryLosslessTimestampRepair(), so the plugin path gets it too. For parity with the MkvMerge rewrites, that pass deletes all tags and attachments and keeps the segment title and track names.MkvPropEdit.ClearTags()also deletes the title and track names, so it does more than the other rewrites do.The same test found that
settsdrops the IETF language of every track. That is #1148, and its restore fits the samemkvpropeditpass.