1
0
Fork 0
mirror of https://github.com/DanielnetoDotCom/YouPHPTube synced 2025-10-04 02:09:22 +02:00
Daniel Neto 2023-07-03 08:43:01 -03:00
parent cb46edfe52
commit 1aae4c9c1b
35 changed files with 725 additions and 181 deletions

View file

@ -92,7 +92,7 @@ const calculateOffset = function (vttCCs: VTTCCs, cc, presentationTime) {
export function parseWebVTT(
vttByteArray: ArrayBuffer,
initPTS: RationalTimestamp,
initPTS: RationalTimestamp | undefined,
vttCCs: VTTCCs,
cc: number,
timeOffset: number,
@ -107,10 +107,9 @@ export function parseWebVTT(
.replace(LINEBREAKS, '\n')
.split('\n');
const cues: VTTCue[] = [];
const init90kHz = toMpegTsClockFromTimescale(
initPTS.baseTime,
initPTS.timescale
);
const init90kHz = initPTS
? toMpegTsClockFromTimescale(initPTS.baseTime, initPTS.timescale)
: 0;
let cueTime = '00:00.000';
let timestampMapMPEGTS = 0;
let timestampMapLOCAL = 0;
@ -134,8 +133,11 @@ export function parseWebVTT(
calculateOffset(vttCCs, cc, webVttMpegTsMapOffset);
}
}
if (webVttMpegTsMapOffset) {
if (!initPTS) {
parsingError = new Error('Missing initPTS for VTT MPEGTS');
return;
}
// If we have MPEGTS, offset = presentation time + discontinuity offset
cueOffset = webVttMpegTsMapOffset - vttCCs.presentationOffset;
}