How to concat multiple MP4 files using fluent-ffmpeg?

I want to build a function to concat mp4 files using Firebase and fluent-ffmpeg.


version

・fluent-ffmpeg 2.1.2

・Firebase 7.6.0


However, an error will occur after startup.

  • The following is the error content.

Error: ffmpeg exited with code 1: Output with label '/tmp/public/thumbnail/source0000.jpg.mp4' does not exist in any defined filter graph, or was already used elsewhere.

  • Below is the actual code.
const from = concatFilePath.map(function(value){
   return path.join(os.tmpdir(), value);
   });
   const chainedInputs = from.reduce((result, inputItem) => result.input(inputItem), ffmpeg());
   console.log('chainedInputs',chainedInputs);

   chainedInputs
   .on('start', function(commandLine) {
   console.log('Command line: ' + commandLine);
   })
   .complexFilter([
         {
           filter: 'concat',
           options: {
               n: from.length,
               v: 1
           }
         }
        ],from
   )
   .outputOption('-strict -2')
   .output(concatTmpThumbnailPath[0])
   .on('error', function(err, stdout, stderr) {
       console.log('An error occurred: ' + err, stderr);
   })
   .on('end', function() {
       console.log('Processing finished !');
   })
   .videoCodec('copy')
   .run();

concatFilePath

['public/video/source0000.mp4','public/video/source0001.mp4','public/video/source0002.mp4']

concatTmpThumbnailPath

['/tmp/public/concat/source0000.mp4','/tmp/public/concat/source0001.mp4','/tmp/public/concat/source0002.mp4']

Please can you tell me as to what I am missing?

Thank you.