Skip to content

Commit e4b2e75

Browse files
committed
Fix fmp4 track timestamp alignment for non-av tracks (followup video-dev#7126)
1 parent e55fecd commit e4b2e75

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

src/utils/mp4-tools.ts

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -275,22 +275,20 @@ export function parseInitSegment(initSegment: Uint8Array): InitData {
275275
soun: ElementaryStreamTypes.AUDIO as const,
276276
vide: ElementaryStreamTypes.VIDEO as const,
277277
}[hdlrType];
278+
// Parse codec details
279+
const stsdBox = findBox(trak, ['mdia', 'minf', 'stbl', 'stsd'])[0];
280+
const stsd = parseStsd(stsdBox);
278281
if (type) {
279-
// Parse codec details
280-
const stsdBox = findBox(trak, ['mdia', 'minf', 'stbl', 'stsd'])[0];
281-
const stsd = parseStsd(stsdBox);
282-
if (type) {
283-
// Add 'audio', 'video', and 'audiovideo' track records that will map to SourceBuffers
284-
result[trackId] = { timescale, type, stsd };
285-
result[type] = { timescale, id: trackId, ...stsd };
286-
} else {
287-
// Add 'meta' and other track records required by `offsetStartDTS`
288-
result[trackId] = {
289-
timescale,
290-
type: hdlrType as HdlrType,
291-
stsd,
292-
};
293-
}
282+
// Add 'audio', 'video', and 'audiovideo' track records that will map to SourceBuffers
283+
result[trackId] = { timescale, type, stsd };
284+
result[type] = { timescale, id: trackId, ...stsd };
285+
} else {
286+
// Add 'meta' and other track records required by `offsetStartDTS`
287+
result[trackId] = {
288+
timescale,
289+
type: hdlrType as HdlrType,
290+
stsd,
291+
};
294292
}
295293
}
296294
}

0 commit comments

Comments
 (0)