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
  • Loading branch information
robwalch committed Jul 18, 2023
1 parent c36d220 commit cb3351e
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 @@ -1125,7 +1125,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 cb3351e

Please sign in to comment.