fluent-ffmpeg / node-fluent-ffmpeg

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

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

Closed DGLcsGaming closed 2 years ago

DGLcsGaming commented 2 years 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 6 months ago

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

klesun commented 6 months ago

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