How to merge multiple videos using fluent-ffmpeg?

We have built our video transcoding pipeline in NodeJS using the fluent-ffmpeg node module, what kind of parameters do I have to pass for merging 2 or more videos into a single mp4 file with fluent-ffmpeg?

fluent-ffmpeg provides mergeToFile API to merge multiple input files into single output files, video resolution, and number audio should be the same in these input files otherwise it will throw an error.

If you are facing any issue with mergeToFile then you can use complexFilter API with custom filters like concat to achieve your goal.


You can also follow this small tutorial:

Step 1: To combine movies using the concat demuxer, first compile a list of the videos you wish to combine into a text file. Here is a video.txt example file. You can add comments to the file, but the demuxer will not use them.

Eg. # videos.txt

file ‘input1.mp4’
file ‘input2.mp4’
file 'input3.mp4
Step 2: Once that is finished, you can execute the following command to merge the movies mentioned in that file in the order they are listed.

$ ffmpeg -f concat -i videos.txt -c copy output8.mp4