Adjust tfhd size for data offsets
Added 16 bytes to the tfhd to specify some default sample configuration so the data offset calculation in the trun must be adjusted to match. Audio now works for my test file. Copy Uint8Arrays used for deepEqual() tests because phantomjs considers two typed arrays with non-equal offsets to be non-equal.
Showing
3 changed files
with
6 additions
and
4 deletions
... | @@ -539,7 +539,7 @@ traf = function(track) { | ... | @@ -539,7 +539,7 @@ traf = function(track) { |
539 | // the data offset specifies the number of bytes from the start of | 539 | // the data offset specifies the number of bytes from the start of |
540 | // the containing moof to the first payload byte of the associated | 540 | // the containing moof to the first payload byte of the associated |
541 | // mdat | 541 | // mdat |
542 | dataOffset = (16 + // tfhd | 542 | dataOffset = (32 + // tfhd |
543 | 16 + // tfdt | 543 | 16 + // tfdt |
544 | 8 + // traf header | 544 | 8 + // traf header |
545 | 16 + // mfhd | 545 | 16 + // mfhd | ... | ... |
... | @@ -537,7 +537,7 @@ test('generates a moof for audio', function() { | ... | @@ -537,7 +537,7 @@ test('generates a moof for audio', function() { |
537 | deepEqual(moof[0].boxes[1].boxes.length, 3, 'generated three traf children'); | 537 | deepEqual(moof[0].boxes[1].boxes.length, 3, 'generated three traf children'); |
538 | trun = moof[0].boxes[1].boxes[2]; | 538 | trun = moof[0].boxes[1].boxes[2]; |
539 | ok(trun, 'generated a trun'); | 539 | ok(trun, 'generated a trun'); |
540 | deepEqual(trun.dataOffset, data.byteLength + 8, 'calculated the data offset'); | 540 | equal(trun.dataOffset, data.byteLength + 8, 'calculated the data offset'); |
541 | deepEqual(trun.samples, [{ | 541 | deepEqual(trun.samples, [{ |
542 | duration: 9000, | 542 | duration: 9000, |
543 | size: 10 | 543 | size: 10 | ... | ... |
... | @@ -997,7 +997,9 @@ test('generates AAC frame events from ADTS bytes', function() { | ... | @@ -997,7 +997,9 @@ test('generates AAC frame events from ADTS bytes', function() { |
997 | }); | 997 | }); |
998 | 998 | ||
999 | equal(frames.length, 1, 'generated one frame'); | 999 | equal(frames.length, 1, 'generated one frame'); |
1000 | deepEqual(frames[0].data, new Uint8Array([0x12, 0x34]), 'extracted AAC frame'); | 1000 | deepEqual(new Uint8Array(frames[0].data), |
1001 | new Uint8Array([0x12, 0x34]), | ||
1002 | 'extracted AAC frame'); | ||
1001 | equal(frames[0].channelcount, 2, 'parsed channelcount'); | 1003 | equal(frames[0].channelcount, 2, 'parsed channelcount'); |
1002 | equal(frames[0].samplerate, 44100, 'parsed samplerate'); | 1004 | equal(frames[0].samplerate, 44100, 'parsed samplerate'); |
1003 | 1005 | ||
... | @@ -1036,7 +1038,7 @@ test('parses across packets', function() { | ... | @@ -1036,7 +1038,7 @@ test('parses across packets', function() { |
1036 | }); | 1038 | }); |
1037 | 1039 | ||
1038 | equal(frames.length, 2, 'parsed two frames'); | 1040 | equal(frames.length, 2, 'parsed two frames'); |
1039 | deepEqual(frames[1].data, | 1041 | deepEqual(new Uint8Array(frames[1].data), |
1040 | new Uint8Array([0x9a, 0xbc]), | 1042 | new Uint8Array([0x9a, 0xbc]), |
1041 | 'extracted the second AAC frame'); | 1043 | 'extracted the second AAC frame'); |
1042 | }); | 1044 | }); | ... | ... |
-
Please register or sign in to post a comment