Merge videos in Ubuntu

There are numerous video editors that can help us merge two or more video files. So, let’s say we want to create a story from different video clips we have. We may try to combine them in such a way that it creates an impact on the viewers. In Ubuntu, we can easily combine different video clips through a command-line utility ffmpeg. In this article, we cover how to merge videos in Ubuntu.

So, if your work requires you to just combine video clips then ffmpeg can get you the results in no time. But, first, we have to install a package: ffmpeg. If you already have the package installed then skip the installation section covered next.

Note: Following operations require you to have superuser privileges. In case you don’t have one then, we advise you to contact your System Administrator for assistance.

Install ffmpeg in Ubuntu

The package is available through the standard Ubuntu repository. Therefore, first, update the repository to ensure we get to have the latest version of the package. Open a terminal and issue the following –

sudo apt update

Next, to install ffmpeg –

sudo apt install ffmpeg

Merge videos in Ubuntu

Once the package gets installed. Now, what we do is, create a text file that contains the list of video clips we want to merge. For instance, the following five files are part of the text file – merge.txt

file video1.mp4
file video2.mp4
file video3.mp4
file video4.mp4
file video5.mp4

Now, merge them in a single video file: finalvideo.mp4

So, the command to get the merged video will be:

ffmpeg -f concat -i merge.txt -c copy finalvideo.mp4

Running the command would get us the merged video file: finalvideo.mp4 in the current directory itself.

In conclusion, we have covered how to merge videos in Ubuntu.

Additional Info:

At times, we get a video file that doesn’t have the audio. The audio file is provided to us separately. Even for such cases, we can merge them as one entity.

ffmpeg -i inputvideo.mp4 -i inputaudio.mp3 -c copy finalvideofile.mp4

Similar Posts