Skip to content

Commit

Permalink
Use input timescale when remuxing inband captions (#5675)
Browse files Browse the repository at this point in the history
Fixes #5669

(cherry picked from commit cb3351e)
  • Loading branch information
robwalch committed Jul 18, 2023
1 parent d0e6702 commit 1dd623c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/remux/mp4-remuxer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1110,7 +1110,7 @@ export function flushTextTrackUserdataCueSamples(
// using this._initPTS and this._initDTS to calculate relative time
sample.pts =
normalizePts(
sample.pts - (initPTS.baseTime * 90000) / initPTS.timescale,
sample.pts - (initPTS.baseTime * inputTimeScale) / initPTS.timescale,
timeOffset * inputTimeScale
) / inputTimeScale;
}
Expand Down
20 changes: 13 additions & 7 deletions src/utils/texttrack-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,19 @@ export function addCueToTrack(track: TextTrack, cue: VTTCue) {
}
} catch (err) {
logger.debug(`[texttrack-utils]: ${err}`);
const textTrackCue = new (self.TextTrackCue as any)(
cue.startTime,
cue.endTime,
cue.text
);
textTrackCue.id = cue.id;
track.addCue(textTrackCue);
try {
const textTrackCue = new (self.TextTrackCue as any)(
cue.startTime,
cue.endTime,
cue.text
);
textTrackCue.id = cue.id;
track.addCue(textTrackCue);
} catch (err2) {
logger.debug(
`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${err2}`
);
}
}
}
if (mode === 'disabled') {
Expand Down

0 comments on commit 1dd623c

Please sign in to comment.