Skip to content

Instantly share code, notes, and snippets.

@Saccarab
Created June 9, 2019 08:54
Show Gist options
  • Select an option

  • Save Saccarab/c8e0540e8a9ba26c771c2808c804e066 to your computer and use it in GitHub Desktop.

Select an option

Save Saccarab/c8e0540e8a9ba26c771c2808c804e066 to your computer and use it in GitHub Desktop.
fluent-ffmpeg merge audio with video
const command = ffmpeg()
const commandArray = []
command.addInput(`./best.mp4`)
command.addInput(`./best2.wav`)
commandArray.push(`[1]volume=0.1[a1]`)
command.addInput(`./voiceover.mp3`)
commandArray.push(`[2]volume=0.9[a2]`)
let ffmpegKeys = '[a1][a2]amix=inputs=2[a]'
commandArray.push(ffmpegKeys)
command.complexFilter(commandArray)
command.addOptions(['-map 0:v', '-map [a]', '-c:v copy'])
.format('mp4')
.on('error', (error) => {
console.log(error)
})
.on('end', function() {
console.log('Merging finished !');
})
.save('./merged.mp4');
@osamwelian3
Copy link

@luciano-repetti did you figure out your setup? Am running a similar setup trying to merge audio and video streams from ytdl and streaming back to client.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment