Monday, September 5, 2022

[SOLVED] fulent-ffmpeg arguments inputs are invalid | nodejs

Issue

how would I write this command

ffmpeg -i input.mov -preset slow -codec:a libfdk_aac -b:a 128k -codec:v libx264 -pix_fmt yuv420p -b:v 2500k -minrate 1500k -maxrate 4000k -bufsize 5000k -vf scale=-1:720 output.mp4

as a node fluent-ffmpeg command?

what I have this

function convert(input, output, callback) {
  ffmpeg(input)
    .output(output)
    .outputOptions(
      "-preset","slow","-codec:a","libfdk_aac","-b:a","128k","-codec:v","-pix_fmt","-b:v","2500k","-vf","scale","\"-1:720\""
    )
    .on("end", function () {
      console.log("conversion ended");
      callback(null);
    })
    .on("error", function (err) {
      console.log("error x: ", err);
      callback(err);
    })
    .run();
}

I get errors saying the arguments are invalid. such as but not limited to:

  • Error: ffmpeg exited with code 1: "-1:720": Invalid argument

and other variations


Solution

Try this one:

.outputOptions([
    "-preset slow",
    "-codec:a libfdk_aac",
    "-b:a 128k",
    "-codec:v libx264",
    "-pix_fmt yuv420p",
    "-b:v 2500k",
    "-vf scale=-1:720"
])

See how to use the outputOptions with arguments here and here an example how to scale



Answered By - Alexander Yukal
Answer Checked By - David Marino (WPSolving Volunteer)