How to join videos in Linux using FFmpeg

Merge Videos on Linux

Many years ago, in times when eMule (aMule on Linux) was the king downloader, I think we were all a little less legal than we are now. Who else for less, we all downloaded a movie from time to time, and sometimes we had to download two 700mb videos (what could fit on a CD). What can we do to reproduce a movie like this? Well, it's very simple: we can reproduce one after the other or, from what this article is about, join videos.

And what is the best way to do it on Linux? Although FFmpeg is also for other platforms, for one reason or another we have it installed on practically any Linux distribution, so it will be the software that we will use. Sure we could take an editor like Kdenlive and put them together, where we could also take away a few seconds that could be repeated at the end of the first and the beginning of the second video, but converting / rendering it would take a long time. With FFmpeg it is less easy, but much faster.

Stitching Videos with FFmpeg - Less Easy, Faster

The steps that we will have to take are the following:

  1. As it is possible, if we do not have it installed, we install FFmpeg. For this we have to install the ffmpeg package, something we can do with commands like sudo apt install ffmpeg, sudo pacman -S ffmpeg o sudo dnf -y install ffmpeg.
  2. With FFmpeg and with all the dependencies that it proposes installed, now we have to take the next step, which is to put the two videos in the same folder.
  3. Now, in the same folder, we have to create a text file with the name (without the quotes) «list.txt».
  4. Inside "list.txt" we have to add the names of the videos (they can be more than two). For example:

file 'part-1.mp4'
file 'part-2.mp4'

  1. We save the file list.txt and exit.
  2. In the last step, we will write a command in the terminal, which will be the following:
ffmpeg -f concat -i lista.txt -c copy -bsf:a aac_adtstoasc nombre_del_video.mp4
  1. We wait a moment and, at the end and in this case, we will have a video with the two parts joined called name_del_video.mp4 in the same folder where we had the two parts.

It is true that it is not the simplest way, partly because it is not so easy to remember the command than to do a couple of clicks in a tool with GUI, but it is very fast, and we can always copy and paste the command every time. we need.


The content of the article adheres to our principles of editorial ethics. To report an error click here!.

Be the first to comment

Leave a Comment

Your email address will not be published.

*

*

  1. Responsible for the data: AB Internet Networks 2008 SL
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.