DNA
DNA10mo ago

Convert m3u8 stream to mp4?

Hey. Whats the best /fastest way to convert a m3u8 stream (all files are in a local folder) to a normal mp4 file using deno?
2 Replies
Leokuma
Leokuma10mo ago
The fastest is probably to load all files into memory with Deno.open() or Deno.openSync() and then merge them. But keep in mind the whole entire stream will be loaded into memory If you still had to fetch() the chunks, you would merge them with new Blob([chunk1, chunk2, chunk3]) where each chunk is a Blob, and then you would save the resulting blob to a file But since you already have the files, I guess you can open them and get a Uint8Array from each, merge all the arrays in order and save the resulting Uint8Array to a file which will be the final MP4
DNA
DNA10mo ago
I wasnt sure if this would properly work and i also found another way using ffmpeg, which works perfectly fine Thank you very much though for you help (Code below, if someone else needs it)
const command = new Deno.Command("ffmpeg", {
args: [
//
"-i",
"master.m3u8",
"-c",
"copy",
"-bsf:a",
"aac_adtstoasc",
"video.mp4",
],
cwd: videoLocation,
});

command.outputSync();
const command = new Deno.Command("ffmpeg", {
args: [
//
"-i",
"master.m3u8",
"-c",
"copy",
"-bsf:a",
"aac_adtstoasc",
"video.mp4",
],
cwd: videoLocation,
});

command.outputSync();