diff --git a/codecs/codecs.js b/codecs/codecs.js index 05a994f..0a96caa 100644 --- a/codecs/codecs.js +++ b/codecs/codecs.js @@ -116,11 +116,11 @@ export function getFullMIMEString(info) { if (stream.codec_type === 'audio') { switch (stream.codec_tag_string) { case 'mp4a': codecFrags.add(getMP4ACodecString(stream)); break; - // TODO: vorbis. - // TODO: opus. default: switch (stream.codec_name) { case 'aac': codecFrags.add(getMP4ACodecString(stream)); break; + case 'vorbis': codecFrags.add('vorbis'); break; + case 'opus': codecFrags.add('opus'); break; default: throw `Could not handle codec_name ${stream.codec_name}, ` + `codec_tag_string ${stream.codec_tag_string} for file ${info.filename} yet. ` + @@ -140,6 +140,7 @@ export function getFullMIMEString(info) { default: switch (stream.codec_name) { case 'h264': codecFrags.add(getAVC1CodecString(stream)); break; + case 'vp9': codecFrags.add(getVP09CodecString(stream)); break; default: throw `Could not handle codec_name ${stream.codec_name}, ` + `codec_tag_string ${stream.codec_tag_string} for file ${info.filename} yet. ` + diff --git a/package.json b/package.json index 106480a..ddd7e14 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@codedread/bitjs", - "version": "1.0.4", + "version": "1.0.5", "description": "Binary Tools for JavaScript", "homepage": "https://github.com/codedread/bitjs", "author": "Jeff Schiller", diff --git a/tests/codecs.spec.js b/tests/codecs.spec.js index e4ca4b8..12592f7 100644 --- a/tests/codecs.spec.js +++ b/tests/codecs.spec.js @@ -214,7 +214,7 @@ describe('codecs test suite', () => { }); }); - describe('VP09', () => { + describe('VP09 / VP9', () => { /** @type {ProbeInfo} */ let info; @@ -268,6 +268,16 @@ describe('codecs test suite', () => { }); }); }); + + it('detects codec_name=vp9 but no codec_tag_string', () => { + info.streams[0].codec_name = 'vp9'; + info.streams[0].codec_tag_string = '[0][0][0][0]'; + info.streams[0].profile = 'Profile 0'; + info.streams[0].level = 21; // 0x15 + expect(getFullMIMEString(info)) + .to.be.a('string') + .and.satisfy(s => s.startsWith('video/webm; codecs="vp09.00.15')); + }); }); describe('MP4A / AAC', () => { @@ -306,4 +316,46 @@ describe('codecs test suite', () => { .and.equals('audio/mp4; codecs="mp4a.40.2"'); }); }); + + describe('Vorbis', () => { + /** @type {ProbeInfo} */ + let info; + + beforeEach(() => { + info = { + format: { format_name: 'matroska,webm' }, + streams: [{ + codec_type: 'audio', + codec_name: 'vorbis', + }], + }; + }); + + it('detects vorbis', () => { + expect(getFullMIMEString(info)) + .to.be.a('string') + .and.equals('audio/webm; codecs="vorbis"'); + }); + }); + + describe('Opus', () => { + /** @type {ProbeInfo} */ + let info; + + beforeEach(() => { + info = { + format: { format_name: 'matroska,webm' }, + streams: [{ + codec_type: 'audio', + codec_name: 'opus', + }], + }; + }); + + it('detects opus', () => { + expect(getFullMIMEString(info)) + .to.be.a('string') + .and.equals('audio/webm; codecs="opus"'); + }); + }); });