Skip to content

Commit

Permalink
Add support for more VideoSampleEntry types
Browse files Browse the repository at this point in the history
  • Loading branch information
davemevans committed Jan 29, 2019
1 parent b1a5076 commit b64ccd0
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Currently a limited set of ISOBMFF boxes is supported:

### ISO/IEC 14496-15:2014 (Carriage of network abstraction layer (NAL) unit structured video in ISO base media file format)

* avc1 / encv
* avc1/2/3/4 / hev1 / hvc1 / encv

Support for more boxes can easily be added by adding additional box parsers in `src/parsers`. Some utility functions are included to help with reading the various ISOBMFF data types from the raw file. Also, see the [Box Support page on the Wiki](https://github.com/madebyhiro/codem-isoboxer/wiki/Box-support) for a full list.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
// ISO/IEC 14496-15:2014 - avc1 box
ISOBox.prototype._boxProcessors['avc1'] = ISOBox.prototype._boxProcessors['encv'] = function() {
// ISO/IEC 14496-15:2014 - avc1/2/3/4, hev1, hvc1, encv
ISOBox.prototype._boxProcessors['avc1'] =
ISOBox.prototype._boxProcessors['avc2'] =
ISOBox.prototype._boxProcessors['avc3'] =
ISOBox.prototype._boxProcessors['avc4'] =
ISOBox.prototype._boxProcessors['hvc1'] =
ISOBox.prototype._boxProcessors['hev1'] =
ISOBox.prototype._boxProcessors['encv'] = function() {
// SampleEntry fields
this._procFieldArray('reserved1', 6, 'uint', 8);
this._procField('data_reference_index', 'uint', 16);
Expand All @@ -16,6 +22,6 @@ ISOBox.prototype._boxProcessors['avc1'] = ISOBox.prototype._boxProcessors['encv'
this._procFieldArray('compressorname', 32,'uint', 8);
this._procField('depth', 'uint', 16);
this._procField('pre_defined3', 'int', 16);
// AVCSampleEntry fields
// Codec-specific fields
this._procField('config', 'data', -1);
};
Binary file added test/fixtures/hvc1_init.mp4
Binary file not shown.
29 changes: 29 additions & 0 deletions test/spec/boxes_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,35 @@ describe('avc1 box', function() {
});
});

describe('hvc1 box', function() {
it('should correctly parse the box', function() {
var parsedFile = loadParsedFixture('./test/fixtures/hvc1_init.mp4');
var stsd = parsedFile.fetchAll('stsd');
var box = stsd[0].entries[0];

expect(box.type).toEqual('hvc1');
expect(box.size).toEqual(137);
expect(box.reserved1).toEqual([0, 0, 0, 0, 0, 0]);
expect(box.data_reference_index).toEqual(1);
expect(box.pre_defined1).toEqual(0);
expect(box.reserved2).toEqual(0);
expect(box.pre_defined2).toEqual([0, 0, 0]);
expect(box.width).toEqual(192);
expect(box.height).toEqual(108);
expect(box.horizresolution).toEqual(72);
expect(box.vertresolution).toEqual(72);
expect(box.reserved3).toEqual(0);
expect(box.frame_count).toEqual(1);
expect(box.compressorname).toEqual([0x0B, 0x48, 0x45, 0x56, 0x43, 0x20, 0x43, 0x6F,
0x64, 0x69, 0x6E, 0x67, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]); // length + 'HEVC Coding'
expect(box.depth).toEqual(24);
expect(box.pre_defined3).toEqual(-1);
expect(box.config.byteLength).toEqual(51);
});
});

describe('mp4a box', function() {
it('should correctly parse the box', function() {
var parsedFile = loadParsedFixture('./test/fixtures/240fps_go_pro_hero_4.mp4');
Expand Down

0 comments on commit b64ccd0

Please sign in to comment.