Skip to content

Instantly share code, notes, and snippets.

@mntone
Created June 9, 2023 02:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mntone/49cc0dd2a08a32d074e8fc5ae426f055 to your computer and use it in GitHub Desktop.
Save mntone/49cc0dd2a08a32d074e8fc5ae426f055 to your computer and use it in GitHub Desktop.
This is to generate MPEG-DASH stream with MP4box on node.js. It's simply approach, but we cannot use webm container. I use ffmpeg for MPD generation now.
function runMP4box(files) {
const args = ['-dash', '2000', ...files, '-segment-name', 'seg', '-out', 'dash/test.mpd']
console.log(args)
const mp4box = spawn('mp4box', args)
return mp4box
}
function runMP4boxAsPromise(files) {
return new Promise(resolve => {
const mp4box = runMP4box(files)
mp4box.on("close", resolve)
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment