Fix some demuxer bugs that occurred on files by FFmpeg, fix packet marking logic

This commit is contained in:
Vanilagy
2026-01-15 08:51:07 +01:00
parent 0719a17c85
commit 8fea9671ea
2 changed files with 37 additions and 9 deletions
+20 -1
View File
@@ -1,6 +1,6 @@
import { expect, test } from 'vitest';
import { Input } from '../../src/input.js';
import { FilePathSource, ReadableStreamSource } from '../../src/source.js';
import { FilePathSource, ReadableStreamSource, UrlSource } from '../../src/source.js';
import path from 'node:path';
import fs from 'node:fs';
import { Readable } from 'node:stream';
@@ -450,3 +450,22 @@ test('MPEG-TS with unknown file size (ReadableStreamSource)', async () => {
expect((videoTrack._backing as unknown as MpegTsTrackBacking).referencePesPackets.length)
.toBeGreaterThanOrEqual(10);
});
test('MPEG-TS transmuxed by FFmpeg', async () => {
using input = new Input({
source: new UrlSource('https://pub-cf9fcfcb5c0a44e9b1bb5ff890e041ae.r2.dev/trim-buck-bunny-ffmpeg.ts'),
formats: ALL_FORMATS,
});
const videoTrack = await input.getPrimaryVideoTrack();
assert(videoTrack);
const audioTrack = await input.getPrimaryAudioTrack();
assert(audioTrack);
const videoPacketStats = await videoTrack.computePacketStats();
const audioPacketStats = await audioTrack.computePacketStats();
expect(videoPacketStats.packetCount).toBe(121);
expect(audioPacketStats.packetCount).toBe(235);
});