How to merge videos using ffmpeg?

by ola.stoltenberg , in category: Other , a year ago

How to merge videos using ffmpeg?

Facebook Twitter LinkedIn Telegram Whatsapp

2 answers

by yvonne.goyette , a year ago

@ola.stoltenberg 

FFmpeg is a powerful tool for manipulating video files. To merge two video files using ffmpeg, you can use the concat demuxer. Here is the general syntax for this operation:

1
ffmpeg -f concat -i input_list.txt -c copy output.mp4


The input_list.txt file should contain a list of the input video files that you want to merge. The format of this file should be:

1
2
file '/path/to/input1.mp4'
file '/path/to/input2.mp4'


You can add as many input files as you want to the input_list.txt file.


For example, to merge two MP4 files called input1.mp4 and input2.mp4, you could use the following command:

1
ffmpeg -f concat -i input_list.txt -c copy output.mp4


Where input_list.txt contains:

1
2
file '/path/to/input1.mp4'
file '/path/to/input2.mp4'


This would create a new video file called output.mp4 that is the concatenation of the two input files.


I hope this helps! Let me know if you have any questions.

by jeremie.rath , 3 months ago

@ola.stoltenberg 

To merge video files using ffmpeg, you can follow these steps:

  1. Make sure you have ffmpeg installed on your computer. You can download it from the official website and install it according to your operating system.
  2. Create a text file named "input_list.txt" and open it with a text editor.
  3. In the "input_list.txt" file, list the video files you want to merge in the order you want them to appear in the final video. Each file should be on a new line and should be preceded by the "file" keyword, followed by the path to the video file. For example:
1
2
file '/path/to/video1.mp4'
file '/path/to/video2.mp4'


  1. Save and close the "input_list.txt" file.
  2. Open the command prompt or terminal on your computer.
  3. Navigate to the folder containing ffmpeg by using the "cd" command. For example:
1
cd /path/to/ffmpeg/folder/


  1. Enter the following command to merge the videos:
1
ffmpeg -f concat -i input_list.txt -c copy output.mp4


In this command, "-f concat" specifies the input format as "concat", "-i input_list.txt" specifies the input file as the "input_list.txt" file you created, "-c copy" tells ffmpeg to copy the streams from the input files without re-encoding, and "output.mp4" is the name of the merged video file you want to create.

  1. Press enter to execute the command. ffmpeg will start merging the videos.
  2. Once the merging process is complete, you will find the merged video file named "output.mp4" in the same folder as the input files.


That's it! You have successfully merged videos using ffmpeg.