Node-fluent-ffmpeg: Concat question.

Created on 6 Feb 2016  路  10Comments  路  Source: fluent-ffmpeg/node-fluent-ffmpeg

How can i achieve a command like this:

ffmpeg -f concat -i mylist.txt -c copy output.mp4

As Described here: https://trac.ffmpeg.org/wiki/Concatenate

I tried several of your examples but they resulted in different commands.

Needs info Question

Most helpful comment

I've found a working solution:

var fs = require('fs');
var fileList = ['part1.mp4', 'part2.mp4']; // files to merge
var listFileName = 'list.txt', fileNames = '';

// ffmpeg -f concat -i mylist.txt -c copy output
fileList.forEach(function(fileName, index){
fileNames = fileNames + 'file ' + '\'' + fileName + '\'\n';
});

fs.writeFileSync(listFileName, fileNames);

var merge = ffmpeg();
merge.input(listFileName)
.inputOptions(['-f concat', '-safe 0'])
.outputOptions('-c copy')
.save('/path/to/merged/file');

All 10 comments

Have you read the documentation ? Which part of your command do you fail to reproduce ?

mergeToFile() can't do it because it is using a complex filtergraph.
Filtering and streamcopy cannot be used together.

The execution of op's command would be very fast, while mergeToFile() is slow, as it involves re-encoding.

Is it a way to produce op's command from mergeToFile() or other API?

Maybe ffmpeg('mylist.txt').inputFormat('concat').writeToFile('output.mp4') should work ?

I've found a working solution:

var fs = require('fs');
var fileList = ['part1.mp4', 'part2.mp4']; // files to merge
var listFileName = 'list.txt', fileNames = '';

// ffmpeg -f concat -i mylist.txt -c copy output
fileList.forEach(function(fileName, index){
fileNames = fileNames + 'file ' + '\'' + fileName + '\'\n';
});

fs.writeFileSync(listFileName, fileNames);

var merge = ffmpeg();
merge.input(listFileName)
.inputOptions(['-f concat', '-safe 0'])
.outputOptions('-c copy')
.save('/path/to/merged/file');

@youran How would you specify the temp folder that is used in merging the videos?

@youran How would you specify the temp folder that is used in merging the videos?

It is not necessary to add a temporary file folder.

.inputFormat('concat') does not work for me ([email protected])
.mergeToFile() of course is not what we want as it REencodes the streams.

What does work is an option closer to original ffmpeg syntax:
.input( 'concat:input1.ext|input2.ext|input3.ext')
.audioCodec('copy')
.videoCodec('copy')
.output('out.ext')
.run();

@didkivskyy this is only outputting input1.ext as out.ext for me -- not the additional files? In my case, I'm trying:

concat:/Users/johnny/Downloads/IMG_0837.MOV|/Users/johnny/Downloads/IMG_0838.MOV|/Users/johnny/Downloads/IMG_0839.MOV

@didkivskyy this is only outputting input1.ext as out.ext for me -- not the additional files? In my case, I'm trying:

concat:/Users/johnny/Downloads/IMG_0837.MOV|/Users/johnny/Downloads/IMG_0838.MOV|/Users/johnny/Downloads/IMG_0839.MOV

@jmonster did you manage to concat all files ? i guess i have same issue with only first file as output and no concatenation of others files

@flenoir I believe I got it working following a completely different example, but I think there was a drawback if the codecs were different that method would fail

I lost interest in the experiment I was doing and didn鈥檛 pursue the issue any farther

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jsamos picture jsamos  路  6Comments

Laurian picture Laurian  路  4Comments

geraldoramos picture geraldoramos  路  3Comments

xyk2 picture xyk2  路  3Comments

odigity picture odigity  路  4Comments