Learn how to quickly combine two or more videos together using ffmpeg.
Follow this guide, for instructions to easily install ffmpeg. Once you have it installed, you will be able to use ffmpeg via any command line.
Combine two videos
This command will combine two videos together.
ffmpeg -i input1.mp4 -i input2.mp4 -filter_complex "[0:0][0:1][1:0][1:1]concat=n=2:v=1:a=1[outv][outa]" -map "[outv]" -map "[outa]" output.mp4
It assumes you have two videos in the same folder which you would like to combine. The two input videos are called ‘input1.mp4’ and ‘input2.mp4’.
The output video is called ‘output.mp4’.
The ‘filter_complex’ part of the command refers to which video and audio streams to use.
The ‘concat’ part of the command sets the number of input videos, and the number of video and audio streams per input video.
Three videos
Another way to combine two or more videos is to create a list of input videos in a text file, like so:
file 'input1.mp4'
file 'input2.mp4'
file 'input3.mp4'
Assuming the text file is called ‘input.txt’ and the three input videos are in the same folder. Then the command is as follows:
ffmpeg -f concat -i input.txt -c copy output.mp4
This will concatenate the three videos together, and create an output file called ‘output.mp4’.
Conclusion
Thank you for reading this tutorial. Let me know in the comments section if you enjoyed it, or have any questions!
For more ffmpeg knowledge, check out this video compression guide.
Or learn how to create a GIF using ffmpeg here.