How can I execute a custom ffmpeg string command with fluent-ffmpeg

fluent-ffmpeg images to video
fluent-ffmpeg multiple outputs
fluent-ffmpeg multiple inputs
fluent-ffmpeg stream input
node js ffmpeg live streaming
fluent-ffmpeg pipe
fluent-ffmpeg adelay
fluent-ffmpeg screenshot

How can I pass a custom command to fluent-ffmpeg(https://www.npmjs.com/package/fluent-ffmpeg/v/1.7.0)? I just want to pass the command string. Something like

var command = FFmpeg("ffmpeg -i input.mp4 -i input.mp3 -c copy -map 0:v:0 -map 1:a:0 output.mp4")

I've seen the examples provided but seems that ffmpeg knowledge is required as to what is a filer, codec etc...

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

fluent-ffmpeg/node-fluent-ffmpeg: A fluent API to FFMPEG , This library abstracts the complex command-line usage of ffmpeg into a fluent, easy to use node.js module. setFfprobePath(path) Argument path is a string with the full path to the ffprobe binary. You must add an input before calling those, or an error will be thrown. This method enables adding custom audio filters. I am using fluent-ffmpeg node module for getting codec data from a file. It works if I give an output but I was wondering if there is any option to run fluent-ffmpeg without giving to it an output.

You just need to pass it into the outputOptions method.

const ffmpeg = require('fluent-ffmpeg');

ffmpeg()
  .input('input.mp4')
  .input('input.mp3')
  .outputOptions('-c copy -map 0:v:0 -map 1:a:0')
  .save('output.mp4');

api documentation for fluent-ffmpeg, extractProgress (command, stderrLine); function fluent-ffmpeg.utils. input) { var source = (typeof input.source === 'string') ? input.source : 'pipe:0'; _prepare( function(err, args) { if (err) { return emitEnd(err); } // Run ffmpeg self. Specify custom audio filter(s) * * Can be called both with one or many filters, or a filter array. Hi, How do I get the generated command that's being executed by fluent ffmpeg? Is there a function that would return this string? Thanks.

The code below is what you need:

const ffmpeg = require('child_process').exec

ffmpeg("ffmpeg -i input.mp4 -i input.mp3 -c copy -map 0:v:0 -map 1:a:0 output.mp4")

fluent-ffmpeg-extended: Docs, Tutorials, Reviews, Fluent ffmpeg-API for node.js Build Status. This library abstracts the complex command-line usage of ffmpeg into a fluent, easy to use node.js� Fluent ffmpeg-API for node.js . This library abstracts the complex command-line usage of ffmpeg into a fluent, easy to use node.js module. In order to be able to use this module, make sure you have ffmpeg installed on your system (including all necessary encoding libraries like libmp3lame or libx264).

Dušan Brejka's answer did the trick for me.

fluent-ffmeg handles progress with parseProgressLine at https://github.com/fluent-ffmpeg/node-fluent-ffmpeg/blob/12667091eeea09b0d6a55b87eb886aa131178608/lib/utils.js#L20

Here's my take on parsing progress. It also takes care of parsing numeric values.

    function handleProgress(progressLine: string): Record<string, string | number> {
      // Remove all spaces after = and trim.
      // each progress part is a key-value pai. ex: "frame=123", "time=01:23:45.67"
      const progressParts: string[] = progressLine
        .replace(/=\s+/g, "=")
        .trim()
        .split(" ");
    
      // build progress object
      const progress: Record<string, string | number> = {};
      for (const keyValuePair of progressParts) {
        const [key, value] = keyValuePair.split("=", 2);
        if (typeof value === "undefined") return null;
        const valueAsNumber = +value;
        progress[key] = !Number.isNaN(valueAsNumber) ? valueAsNumber : value;
      }
    
      // do something with progress object
      console.log(progress);
      return progress;
    }

Use with:

    executeFfmpeg(cmd)
      // attach handles
      .on("stderr", handleProgress)
      .run()

Generating video previews with Node.js and FFmpeg, Manipulating a video with Node.js alone would be extremely hard, but inside of the program, able to run in many different environments. The library, available on npm, generates the FFmpeg commands for We made a custom demo for . export const getVideoInfo = (inputPath: string) => { return new� I'm trying to do some stuff using fluent-ffmpeg which I have working in command line just fine. basically, I'm merging videos -> extracting audio -> mixing audio with some music -> merge it back part when I'm stuck is after mixing audio I can't marge it back.

ffmpeg Documentation, A stream specifier is a string generally appended to the option name and separated device is either an X11 display name or a DRM render node. A custom channel layout can be specified as a sequence of terms, separated by '+' or '|'. To get more documentation of the libvpx options, invoke the command ffmpeg -h� Hi, On windows I'm having trouble with ffmpeg-fluent. When with ffmpef-fluent I try to use dshow capture device as input, ffmpeg tell me that it doesn't find this device. But when i run exactly the same command directly via command line

How to Build a Simple Video Converter with Node.js, It is located at https://github.com/fluent-ffmpeg/node-fluent-ffmpeg. This package allows us to run FFMPEG commands by calling the built-in functions. npx sequelize-cli --name VideoConversion --attributes filePath:string� Hey, I'm trying to pipe a video stream, but I get this error: Cannot process video: ffmpeg exited with code 1: pipe:1: Invalid argument const command = new ffmpeg({source: url}) .addOption('-bsf:a', 'aac_adtstoasc') .on('error', err => {

ffmpeg and ffprobe in electron, I was recently asked about how to use ffmpeg with the fluent-ffmpeg node It basically allows you to package your app wit a custom version of the V8 the ffmpeg binary and provides an easier interface to run ffmpeg commands But when electron-builder recognizes a Mac computer it recognizes it as the string mac . Another useful feature of FFmpeg is we can easily extract images from a video file. This could be very useful, if you want to create a photo album from a video file. To extract images from a video file, use the following command: $ ffmpeg -i input.mp4 -r 1 -f image2 image-%2d.png. Here,-r - Set the frame rate. I.e the number of frames to be

Comments
  • I have never used it, but it seems to me you need to send the FFmpeg constructor an object as shown on the npm page documentation, or set options with methods. The github page has more documentation. It is not exactly clear what your question is.
  • Thanks! This did the trick for me.