mirror of
https://github.com/arcodange-org/mediabunny.git
synced 2026-09-27 02:43:48 +02:00
Add HLS transcoding example
This commit is contained in:
@@ -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),
|
||||
// ...
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user