Migrate Matroska demuxer to new packet system

This commit is contained in:
Vanilagy
2025-12-21 19:46:47 +01:00
parent 6722592e27
commit 3285d5ea7d
4 changed files with 130 additions and 68 deletions
+33 -1
View File
@@ -3,7 +3,7 @@ import { Input } from '../../src/input.js';
import { BufferSource, FilePathSource } from '../../src/source.js';
import path from 'node:path';
import fs from 'node:fs';
import { ALL_FORMATS, MP3, MP4, QTFF } from '../../src/input-format.js';
import { ALL_FORMATS, MP3, MP4, QTFF, WEBM } from '../../src/input-format.js';
import { PacketReader } from '../../src/cursors.js';
import { InputAudioTrack, InputTrack } from '../../src/input-track.js';
import { assert } from '../../src/misc.js';
@@ -113,6 +113,38 @@ test('Fragmented ISOBMFF sync reading', async () => {
expect(count).toBe(120);
});
test('Matroska demuxing', async () => {
using input = new Input({
source: new FilePathSource(path.join(__dirname, '../public/trim-buck-bunny.webm')),
formats: ALL_FORMATS,
});
expect(await input.getFormat()).toBe(WEBM);
const tracks = await input.getTracks();
expect(tracks).toHaveLength(2);
const videoTrack = await input.getPrimaryVideoTrack();
assert(videoTrack);
await testBasicPacketReading(videoTrack);
expect(await input.computeDuration()).toBeCloseTo(5);
});
test('Matroska sync reading', async () => {
using input = new Input({
source: new BufferSource(fs.readFileSync(path.join(__dirname, '../public/trim-buck-bunny.webm'))),
formats: ALL_FORMATS,
});
const videoTrack = await input.getPrimaryVideoTrack();
assert(videoTrack);
const count = testSyncPacketReading(videoTrack);
expect(count).toBe(120);
});
test('MP3 demuxing', async () => {
using input = new Input({
source: new FilePathSource(path.join(__dirname, '../public/AudacityTest1.mp3')),