…o timestamps widely
There are MPEG TS files where subtitle packets are multiplexed with
audio and video packets properly, meaning that packets that are supposed
to be shown/played together are also stored next to each other. However,
the timestamps in the PES streams have huge differences. For example,
the first timestamps for audio and video packets are around 00:11:08.418
whereas the timestamps for corresponding subtitle packets start at
This workaround attempts to detect such situations. In that case
mkvmerge will discard subtitle timestamps and use the most recent audio
or video timestamp instead.
The prior implementation checked each subtitle timestamp against the
last audio or video timestamp seen. If it differed too much, the
subtitle timestamp was set to that last timestamp.
The problem with such an approach is its coarseness. It also disregards
the relative difference between subtitle timestamps.
The new implementation works differently. The first time a big
difference between subtitle and audio/video timestamps is detected, the
difference will be stored. This difference will then be applied to all
subtitle timestamps. This keeps the relative difference between subtitle