Merge pull request #279 from samohovets/bugfix/vorbis-eos

Fix OGG Vorbis decoding error for files with empty EOS pages
This commit is contained in:
David P.
2026-01-13 17:36:09 +01:00
committed by GitHub
3 changed files with 30 additions and 0 deletions
+4
View File
@@ -322,6 +322,10 @@ export class OggDemuxer extends Demuxer {
}
const totalPacketSize = chunks.reduce((sum, chunk) => sum + chunk.length, 0);
if (totalPacketSize === 0) {
return null; // Invalid packet, treat it as end of stream
}
const packetData = new Uint8Array(totalPacketSize);
let offset = 0;
+26
View File
@@ -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.