fluent-ffmpeg / node-fluent-ffmpeg

A fluent API to FFMPEG (http://www.ffmpeg.org)
MIT License
7.63k stars 873 forks source link

Cant get complexFilter working #1206

Closed gumernus closed 1 year ago

gumernus commented 1 year ago

Version information

Code to reproduce


const command = ffmpeg();

files.forEach(file => {
  command.input(file);
});

command
  .complexFilter([
    {
      filter: 'concat',
      options: { n: files.length, v: 1, a: 1 },
      inputs: files.map((_, i) => `[${i}:v:0]`).concat(files.map((_, i) => `[${i}:a:0]`)),
      outputs: ['v', 'a']
    }
  ])
  .outputOptions([
    '-map', '[v]', '-map', '[a]',
    '-c:v', 'libx264', '-preset', 'ultrafast', '-crf', '23', '-af', 'aresample=async=1'
  ])
  .output(outputFile)
  .on('end', () => {
    console.log(`Video '${outputFile}' successfully rendered`);
  })
  .on('progress', progress => {
    console.log(`${progress.frames} frames done`);
  })
  .on('error', err => {
    console.error(err);
  })
  .run();

Expected results

It should concentate 2 or more videos with the complex filter. I esentially need to recrete this command: ffmpeg -i input1.mp4 -i input2.mp4 -filter_complex "[0:v:0][0:a:0][1:v:0][1:a:0]concat=n=2:v=1:a=1[v][a]" -map "[v]" -map "[a]" output.mp4 but with support for more videos. And it just doesnt work.

Observed results

Error: ffmpeg exited with code 1: Stream specifier ':v:0' in filtergraph description [0:v:0][1:v:0][0:a:0][1:a:0]concat=n=2:v=1:a=1[v][a] matches no streams.

    at ChildProcess.<anonymous> (D:\programing\Bialu\compilation-creator\node_modules\fluent-ffmpeg\lib\processor.js:182:22)
    at ChildProcess.emit (node:events:537:28)
    at ChildProcess._handle.onexit (node:internal/child_process:291:12)