Unfortunately at the time of writing this Fluent-ffmpeg still does not support custom complex FFMPEG attributes, so the only solutions are either forking it or resorting to ugly "hacks" that kind of defeat the primary purpose of this library (for most cases).
I'm using Fluent-ffmpeg with this "hack" only as a neat wrapper for handling multiple complex FFMPEG processes, with nice output/error/progress parsing.
const fluent = require('fluent-ffmpeg');
const executeFfmpeg = args => {
let command = fluent().output(' '); // pass "Invalid output" validation
command._outputs[0].isFile = false; // disable adding "-y" argument
command._outputs[0].target = ""; // bypass "Unable to find a suitable output format for ' '"
command._global.get = () => { // append custom arguments
return typeof args === "string" ? args.split(' ') : args;
};
return command;
};
executeFfmpeg('-i input.mp4 -i input.mp3 -c copy -map 0:v:0 -map 1:a:0 output.mp4')
.on('start', commandLine => console.log('start', commandLine))
.on('codecData', codecData => console.log('codecData', codecData))
.on('error', error => console.log('error', error))
.on('stderr', stderr => console.log('stderr', stderr))
.run();
NOTE: this solution does not support 'progress' event, but you can do it easily by parsing 'stderr' event with extractProgress method from fluent-ffmpeg/lib/options.js