Files
mediabunny/test/browser/read-mp4.test.ts
T
0f9dc1f91b Fix tenc fallback for encrypted ISOBMFF files (#470)
* fix tenc fallback

* Add test case

---------

Co-authored-by: Vanilagy <[email protected]>
2026-08-24 14:12:04 +02:00

28 lines
848 B
TypeScript

import { expect, test } from 'vitest';
import { Input } from '../../src/input.js';
import { UrlSource } from '../../src/source.js';
import { ALL_FORMATS } from '../../src/input-format.js';
import { AudioSampleSink } from '../../src/media-sink.js';
import { assert } from '../../src/misc.js';
test('Encrypted MP4 without senc', async () => {
using input = new Input({
source: new UrlSource('/639955605-b752f7ad-7ce8-43c2-8ae9-88e74c6ae696.mp4'),
formats: ALL_FORMATS,
formatOptions: {
isobmff: {
resolveKeyId: () => 'aabbccddeeff00112233445566778899',
},
},
});
const audioTrack = await input.getPrimaryAudioTrack();
assert(audioTrack);
// Test that it can decode
const sink = new AudioSampleSink(audioTrack);
using firstSample = await sink.getSample(0);
assert(firstSample);
expect(firstSample.timestamp).toBe(0);
});