mirror of
https://github.com/arcodange-org/mediabunny.git
synced 2026-09-28 19:33:51 +02:00
Migrate Matroska demuxer to new packet system
This commit is contained in:
+33
-1
@@ -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')),
|
||||
|
||||
Reference in New Issue
Block a user