Skip to content

Commit

Permalink
Merge pull request #2929 from video-dev/bugfix/handle-wrapped-pts-bef…
Browse files Browse the repository at this point in the history
…ore-dts

Fix regression in streams with PTS wrapping prior to DTS
  • Loading branch information
robwalch committed Jul 30, 2020
2 parents eabceb5 + 2848bd3 commit 20cd617
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/remux/mp4-remuxer.js
Expand Up @@ -222,14 +222,14 @@ class MP4Remuxer {
// PTSNormalize will make PTS/DTS value monotonic, we use last known DTS value as reference value
for (let i = 0; i < nbSamples; i++) {
const sample = inputSamples[i];
sample.pts = PTSNormalize(sample.pts - initPTS, nextAvcDts);
sample.dts = PTSNormalize(sample.dts - initPTS, nextAvcDts);
if (sample.dts > sample.pts) {
ptsDtsShift = Math.max(Math.min(ptsDtsShift, sample.pts - sample.dts), -1 * PTS_DTS_SHIFT_TOLERANCE_90KHZ);
}
if (sample.dts < inputSamples[i > 0 ? i - 1 : i].dts) {
sortSamples = true;
}
sample.pts = PTSNormalize(sample.pts - initPTS, nextAvcDts);
sample.dts = PTSNormalize(sample.dts - initPTS, nextAvcDts);
}

// sort video samples by DTS then PTS then demux id order
Expand Down

0 comments on commit 20cd617

Please sign in to comment.