Skip to content

Commit 44beb99

Browse files
committed
v1.08: Add handling of AC-3 audio codec too...
1 parent a24524e commit 44beb99

File tree

3 files changed

+29
-6
lines changed

3 files changed

+29
-6
lines changed

codecs/codecs.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ export function getFullMIMEString(info) {
122122
case 'aac': codecFrags.add(getMP4ACodecString(stream)); break;
123123
case 'vorbis': codecFrags.add('vorbis'); break;
124124
case 'opus': codecFrags.add('opus'); break;
125+
// I'm going off of what Chromium calls this one, with the dash.
126+
case 'ac3': codecFrags.add('ac-3'); break;
125127
default:
126128
throw `Could not handle codec_name ${stream.codec_name}, ` +
127129
`codec_tag_string ${stream.codec_tag_string} for file ${info.format.filename} yet. ` +

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@codedread/bitjs",
3-
"version": "1.0.7",
3+
"version": "1.0.8",
44
"description": "Binary Tools for JavaScript",
55
"homepage": "https://github.com/codedread/bitjs",
66
"author": "Jeff Schiller",

tests/codecs.spec.js

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,27 @@ describe('codecs test suite', () => {
276276
});
277277
});
278278

279+
describe('MPEG2', () => {
280+
/** @type {ProbeInfo} */
281+
let info;
282+
283+
beforeEach(() => {
284+
info = {
285+
format: { format_name: 'matroska,webm' },
286+
streams: [{
287+
codec_type: 'video',
288+
codec_name: 'mpeg2video',
289+
}],
290+
};
291+
});
292+
293+
it('detects mpeg2video', () => {
294+
expect(getFullMIMEString(info))
295+
.to.be.a('string')
296+
.and.equals('video/webm; codecs="mpeg2video"');
297+
});
298+
});
299+
279300
describe('MP4A / AAC', () => {
280301
/** @type {ProbeInfo} */
281302
let info;
@@ -355,24 +376,24 @@ describe('codecs test suite', () => {
355376
});
356377
});
357378

358-
describe('MPEG2', () => {
379+
describe('AC-3', () => {
359380
/** @type {ProbeInfo} */
360381
let info;
361382

362383
beforeEach(() => {
363384
info = {
364385
format: { format_name: 'matroska,webm' },
365386
streams: [{
366-
codec_type: 'video',
367-
codec_name: 'mpeg2video',
387+
codec_type: 'audio',
388+
codec_name: 'ac3',
368389
}],
369390
};
370391
});
371392

372-
it('detects mpeg2video', () => {
393+
it('detects AC-3', () => {
373394
expect(getFullMIMEString(info))
374395
.to.be.a('string')
375-
.and.equals('video/webm; codecs="mpeg2video"');
396+
.and.equals('audio/webm; codecs="ac-3"');
376397
});
377398
});
378399
});

0 commit comments

Comments
 (0)