How to combine/merge mp4 videos with FFMPEG

FFMPEG is a useful library, i would say quite useful to do many things with it like converting videos, resizing videos etc. It can do more than that if used properly. I remember i used it quite heavily for a project where i need to do all sort of things for images and videos and it never fails in any. The other day i was recording some in game videos and the videos were big like 8GB, so the recording application(Nvidia shadowplay) divided into two parts. I assume at the moment it only would go for around 4GB file and the rest it just split it to sequential files. So i thought why not use FFMPEG and merge them together without losing any frames and quality. CAT can be used too for merging in terminal. Enough of talking, lets get into action. Open terminal, if ffmpeg is not installed, install it via zypper, yum etc. You should have Packman repo in openSUSE for this.

sudo zypper in ffmpeg

Now lets say we have 3 files to merge together f1.mp4, f2.mp4, f3.mp4. CD to the dir where the files are and create a txt file:

cd /to/the/dir/of/videos_files

touch files.txt

Add the following to the files.txt in vim or any GUI app.

file f1.mp4

file f2.mp4

file f3.mp4

Lets merge them together:

ffmpeg -f concat -i files.txt -vcodec copy -acodec copy final_file.mp4

And you have a merged file now. 🙂

M M Arif

Founder of www.therandombits.com and anl4u.com. Husband. Father. Senior Software Engineer. Linux enthusiast, using multiple Linux operating systems for personal use and work. A self taught programmer who love to code and share. Fan of open source and community projects.

You may also Like

Leave a reply

Your email address will not be published. Required fields are marked *

×