fluent-ffmpeg / node-fluent-ffmpeg

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

Invalid argument when using fluent-ffmpeg to concatenate two video files #1197

Closed DGLcsGaming closed 1 year ago

DGLcsGaming commented 1 year ago

Version information

So I'm trying to use fluent-ffmpeg to concatenate (using concat demuxer) two .mp4 videos files (identical video/audio formats) but I'm getting this error:

Error: ffmpeg exited with code 1: ":../../input.txt": Invalid argument

Code to reproduce

const ffmpeg = require('fluent-ffmpeg');
.
.
const mergeVideoImageWithOriginalVideo = (imageVideo) => {
  return new Promise((resolve, reject) => {
    const command = new ffmpeg();
    command
      .input(`"../../${imageVideo.replace('./', '')}"`)
      .inputFormat('concat')
      .inputOptions(['-safe 0'])
      .outputOptions(['-c copy'])
      .on('start', function (ffmpegCommand) {
        console.log(ffmpegCommand);
      })
      .on('progress', function (data) {
        /// do stuff with progress data if you want
      })
      .on('end', function () {
        resolve();
      })
      .on('error', function (error) {
        return reject(new Error(error));
      })
      .save(`"../../${imageVideo.replace('txt', 'final.mp4').replace('./', '')}"`)
      .run();
  });
};

The contents of input.txt:

file 'video.image.mp4'
file 'video.mp4'

The output of console.log(ffmpegCommand) is:

ffmpeg -f concat -safe 0 -i "../../input.txt" -y -c copy "../../video.final.mp4"

Expected results

Concatinate both video files into a video.fina.mp4

Observed results

The weird thing is when I run that exact command (using CMD) in the same directory that I'm running this nodejs script it works.

klesun commented 1 month ago

Hi. Did you find out why it did not work in the end?

klesun commented 1 month ago

Related: https://github.com/fluent-ffmpeg/node-fluent-ffmpeg/issues/1012 Guess it can only be done with command line...