Add proper packet duration extraction to MPEG-TS demuxer

This commit is contained in:
Vanilagy
2026-01-15 16:33:17 +01:00
parent 8fea9671ea
commit 54dfa75a7e
5 changed files with 502 additions and 249 deletions
+37 -3
View File
@@ -14,10 +14,44 @@
source: new Mediabunny.BlobSource(file),
});
const videoTrack = await input.getPrimaryVideoTrack();
const sink = new Mediabunny.EncodedPacketSink(videoTrack);
const track = await input.getPrimaryVideoTrack();
const sink = new Mediabunny.EncodedPacketSink(track);
console.log(await sink.getKeyPacket(Infinity));
const packet = await sink.getPacket(12.5);
console.log(packet, await sink.getNextPacket(packet))
/*
let currentPacket = await sink.getFirstPacket();
while (currentPacket) {
console.log(currentPacket);
currentPacket = await sink.getNextPacket(currentPacket);
}
//const secondPacket = await sink.getNextPacket(firstPacket);
//const thirdPacket = await sink.getNextPacket(secondPacket);
//const fourthPacket = await sink.getNextPacket(thirdPacket);
//const fifthPacket = await sink.getNextPacket(fourthPacket);
//const sixthPacket = await sink.getNextPacket(fifthPacket);
//const seventhPacket = await sink.getNextPacket(sixthPacket);
//const eighthPacket = await sink.getNextPacket(seventhPacket);
//const ninthPacket = await sink.getNextPacket(eighthPacket);
//const tenthPacket = await sink.getNextPacket(ninthPacket);
console.log(firstPacket, secondPacket, thirdPacket, fourthPacket, fifthPacket, sixthPacket, seventhPacket, eighthPacket, ninthPacket, tenthPacket);
const packets = [firstPacket, secondPacket, thirdPacket, fourthPacket, fifthPacket, sixthPacket, seventhPacket, eighthPacket, ninthPacket, tenthPacket];
const videoDecoder = new VideoDecoder({
output: (frame) => console.log(frame.timestamp, frame),
error: console.error,
});
videoDecoder.configure(await videoTrack.getDecoderConfig());
for (const packet of packets) {
//videoDecoder.decode(packet.toEncodedVideoChunk());
}
*/
/*