3

How to use ffmpeg to combine multiple videos to one

 2 years ago
source link: https://ma.ttias.be/use-ffmpeg-combine-multiple-videos/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

How to use ffmpeg to combine multiple videos to one

Mattias Geniar, November 09, 2019

Follow me on Twitter as @mattiasgeniar

Here’s a quick tip on how to combine multiple separate videos into a single one, using ffmpeg.

First, create a text file that has the filenames for all your different fragments.

$ cat files.txt
file 'file 1.mkv'
file 'file 2.mkv'
file 'file 3.mkv'
file 'file 4.mkv'

All the files in files.txt will be concatenated to a single output file. Add/remove lines as needed.

Now, use ffmpeg to combine them all.

$ ffmpeg -f concat -safe 0 -i files.txt -c copy output.mkv
[...]
[matroska,webm @ 0x7fc2cb800600] Auto-inserting h264_mp4toannexb bitstream filter/s speed= 450x
frame=103454 fps=11333 q=-1.0 Lsize=  460025kB time=01:08:58.30 bitrate= 910.6kbits/s speed= 453x
video:398150kB audio:59680kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.479438%

The end result, if this was successful, is an output.mkv file that has all fragments combined.


Want to subscribe to the cron.weekly newsletter?

I write a weekly-ish newsletter on Linux, open source & webdevelopment called cron.weekly.

It features the latest news, guides & tutorials and new open source projects. You can sign up via email below.

No spam. Just some good, practical Linux & open source content.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK