Add support for live HLS streams, add playlist refresh logic, add live input tracks

This commit is contained in:
Vanilagy
2026-03-12 15:54:19 +01:00
parent ff523c01c8
commit e8df451bf5
23 changed files with 22399 additions and 417 deletions
+36 -8
View File
@@ -11,6 +11,7 @@
document.body.append(fileInput);
fileInput.addEventListener('change', async () => {
/*
const file = fileInput.files[0];
const input = new Mediabunny.Input({
formats: Mediabunny.ALL_FORMATS,
@@ -20,13 +21,47 @@
const audTrack = await input.getPrimaryAudioTrack();
console.log((await audTrack.getDecoderConfig()).description.join(','));
return;
*/
const manifest = new Mediabunny.Input({
entryPath: 'https://s3.amazonaws.com/qa.jwplayer.com/hlsjs/muxed-fmp4/hls.m3u8',
entryPath: 'https://zdf-hls-15.akamaized.net/hls/live/2016498/de/high/master.m3u8',
source: ({ path }) => new Mediabunny.UrlSource(path),
formats: Mediabunny.ALL_FORMATS,
});
const videoTrack = await manifest.getPrimaryVideoTrack();
await videoTrack.hydrate();
const sink = new Mediabunny.EncodedPacketSink(videoTrack);
const firstTimestamp = await videoTrack.getFirstTimestamp();
console.log("FIRST", firstTimestamp)
let last = -Infinity;
for await (const packet of sink.packets()) {
const rel = packet.timestamp - firstTimestamp;
console.log(rel, rel - last);
last = rel;
if (rel >= 10) {
break;
}
}
/*
console.log("here")
const lastPacket = await sink.getPacket(Infinity, { skipLiveWait: true });
const other = await sink.getPacket(lastPacket.timestamp - 5);
for await (const packet of sink.packets(other)) {
console.log(packet.timestamp);
}
console.log("Done")
*/
/*
const tracks = await manifest.getTracks();
//await input.hydrateAllTracks();
@@ -34,11 +69,6 @@
return;
*/
const videoTrack = await manifest.getPrimaryVideoTrack();
const audioTrack = await manifest.getPrimaryAudioTrack();
console.log(await videoTrack.getFirstTimestamp(), await audioTrack.getFirstTimestamp());
/*
for await (using sample of sink.samples()) {
console.log(sample.timestamp);
@@ -105,8 +135,6 @@
}
*/
console.log("Done")
/*
//const secondPacket = await sink.getNextPacket(firstPacket);