mirror of
https://github.com/arcodange-org/mediabunny.git
synced 2026-09-27 10:53:50 +02:00
Fix OGG Vorbis decoding error for files with empty EOS pages (VLC-encoded)
This commit is contained in:
@@ -499,6 +499,10 @@ class OggAudioTrackBacking implements InputAudioTrackBacking {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (packet.data.byteLength === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const { durationInSamples, vorbisBlockSize } = extractSampleMetadata(
|
||||
packet.data,
|
||||
this.bitstream.codecInfo,
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
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 { AudioBufferSink } from '../../src/media-sink.js';
|
||||
import { assert } from '../../src/misc.js';
|
||||
|
||||
// VLC creates OGG files with an empty EOS page, which previously caused decoding errors
|
||||
test('can decode OGG Vorbis file with empty EOS page', async () => {
|
||||
using input = new Input({
|
||||
source: new UrlSource('/vorbis-eos.ogg'),
|
||||
formats: ALL_FORMATS,
|
||||
});
|
||||
|
||||
const track = await input.getPrimaryAudioTrack();
|
||||
assert(track);
|
||||
|
||||
const sink = new AudioBufferSink(track);
|
||||
const buffers: AudioBuffer[] = [];
|
||||
|
||||
for await (const { buffer } of sink.buffers(4, 10)) {
|
||||
buffers.push(buffer);
|
||||
}
|
||||
|
||||
expect(buffers.length).toBeGreaterThan(0);
|
||||
});
|
||||
Binary file not shown.
Reference in New Issue
Block a user