0

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

Dean Van Greunen
  • 5,060
  • 2
  • 14
  • 28

1 Answers1

1

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

Alexander Yukal
  • 173
  • 1
  • 9
  • Hi Alex, how would I add a watermark in the bottom right? please look at my code https://pastebin.com/wJ33Na1T the image is of size 96x96 pixels and is of PNG format. – Dean Van Greunen Sep 10 '20 at 11:10
  • Please read the [manual](https://ffmpeg.org/ffmpeg-filters.html#overlay-1) first, also, you can find there for a few [examples](https://ffmpeg.org/ffmpeg-filters.html#Examples-87). Also, you have to be sure that your program has the correct path to your logo. If you using node.js, please check out the [process.cwd()](https://nodejs.org/api/process.html#process_process_cwd). As an example here `overlay=main_w-overlay_w-10:main_h-overlay_h-10` - you can use your own offset instead `10` – Alexander Yukal Sep 10 '20 at 12:29
  • not sure how to include the logo in the output options, the manual is unusable since it doesn't say how to load if via the node fluent-ffmpeg. and I cant find samples online – Dean Van Greunen Sep 10 '20 at 13:11
  • 1
    For the complex filter, you should use [complexFilter](https://github.com/fluent-ffmpeg/node-fluent-ffmpeg#complexfilterfilters-map-set-complex-filtergraph) method, and also you should add your logo by [input](https://github.com/fluent-ffmpeg/node-fluent-ffmpeg#specifying-inputs) method. And [this](https://pastebin.com/10m52zED) is how I solved it. – Alexander Yukal Sep 10 '20 at 14:14