Georgi Koemdzhiev
Georgi Koemdzhiev

Reputation: 11931

How to concatenate all "mkv" files using ffmpeg?

How can I concatenate all of my files in a folder with mkv extension? I know that I can specify specific files using that command:

ffmpeg -i "concat:00019.MTS|00020.MTS|00021.MTS|00022.MTS" output.mp4

but I am not sure how to change it so that it executes the same over a large number of video files. How can I do this?

Upvotes: 9

Views: 20538

Answers (1)

will
will

Reputation: 5071

I've used ffmpeg a couple of times to do this. I mostly use the concatenate to 'edit-out' bad video from a scratched DVD. I rip the good bits and then use concatenate. I find it quite satisfactory.

Here's the recipe iI used.

   ffmpeg  -loglevel info -f concat -safe 0  -i join-Title.ffmpeg -c copy   "Whole Title.mkv"

The file join-Title.ffmpeg looks like this, for 3 snippets ripped from the original DVD.

 ################
 #
 ##  ffmpeg  -loglevel info -f concat -safe 0  -i join-Title.ffmpeg -c copy   "Whole Title.mkv"
 #
 file    '/home/media/title/Title A.mkv'
 file    '/home/media/title/Title B.mkv'
 file    '/home/media/title/Title C.mkv'

This page has a simple explaination for the steps involved.

Upvotes: 23

Related Questions