mirror of
https://github.com/arcodange-org/mediabunny.git
synced 2026-09-28 11:23:45 +02:00
23 lines
756 B
TypeScript
23 lines
756 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 { assert } from '../../src/misc.js';
|
|
import { AudioSampleCursor } from '../../src/cursors.js';
|
|
|
|
test('MP3 decoding', async () => {
|
|
using input = new Input({
|
|
source: new UrlSource('/AudacityTest1.mp3'),
|
|
formats: ALL_FORMATS,
|
|
});
|
|
|
|
const audioTrack = await input.getPrimaryAudioTrack();
|
|
assert(audioTrack);
|
|
|
|
const cursor = new AudioSampleCursor(audioTrack);
|
|
const sample = await cursor.seekToFirst();
|
|
expect(sample).not.toBe(null);
|
|
expect(sample!.timestamp).toBe(0);
|
|
expect(sample!.duration).toBeCloseTo(1152 / await audioTrack.getSampleRate());
|
|
});
|