Skip to content

Commit

Permalink
Fix codec parsing for AVC streams
Browse files Browse the repository at this point in the history
  • Loading branch information
Qizot committed Jan 4, 2024
1 parent 4cd3e5a commit 959ce19
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/utils/mp4-tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,10 @@ function parseStsd(stsd: Uint8Array): { codec: string; encrypted: boolean } {
case 'avc2':
case 'avc3':
case 'avc4':
// profile + compatibility + level
codec += '.' + toHex(stsd[111]) + toHex(stsd[112]) + toHex(stsd[113]);
// fourcCC starts at index 8, data takes 86 bytes until avcC box
// avcC box's header is 8 bytes and we ignore 'configurationVersion' (one byte)
// (total offset: 8 + 86 + 8 + 1 = 103): profile + compatibility + level
codec += '.' + toHex(stsd[103]) + toHex(stsd[104]) + toHex(stsd[105]);
break;
case 'mp4a': {
const codecBox = findBox(sampleEntries, [fourCC])[0];
Expand Down

0 comments on commit 959ce19

Please sign in to comment.