Add HLS transcoding example

This commit is contained in:
Vanilagy
2026-04-28 13:54:42 +02:00
parent 3e70e8912b
commit 6182af7c29
5 changed files with 417 additions and 5 deletions
+12 -5
View File
@@ -89,16 +89,23 @@ console.log(writtenFiles);
```ts
const root = await navigator.storage.getDirectory();
const writePromises: Promise<void>[] = [];
const output = new Output({
target: new PathedTarget(
'master.m3u8',
async ({ path }) => {
const handle = await root.getFileHandle(path, { create: true });
const writable = await handle.createWritable();
return new StreamTarget(writable);
},
async ({ path }) => new BufferTarget({
onFinalize: (buffer) => {
writePromises.push((async () => {
const handle = await root.getFileHandle(path, { create: true });
const writable = await handle.createWritable();
await writable.write(buffer);
await writable.close();
})());
},
}),
),
onFinalize: () => Promise.all(writePromises),
// ...
});