Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Combine mkv's in Windows (automated, not using a GUI)

From time to time I receive several mkv's from a server I have. These mkv's are all part of the same recording, but they come in 1 minute chunks, and I don't want to have to take the time to stitch them together manually each time. Can this be done via an automated process in Windows?

EDIT: See my answer below for the solution that worked for me. The post by Endoro also looks promising.

like image 693
austinthemassive Avatar asked Mar 23 '23 23:03

austinthemassive


2 Answers

I can give you an example:

@echo off &setlocal enabledelayedexpansion
cd /d "%sourcefolder%"
set "line="
for %%a in (*.mkv) do set line=!line! +"%%~a"
mkvmerge -o "output.mkv" %line:~2%
like image 169
Endoro Avatar answered Apr 01 '23 05:04

Endoro


As I continued researching, I discovered a download page that also contained a review of mkvtoolnix (http://www.fosshub.com/MKVToolNix.html) that referred to some cmd commands he tested along with the standard GUI test. using the "mkvmerge --help" command, I was able to determine the appropriate command to stitch mkv files together. It looked something like this:

C:\Program Files (x86)\MKVToolNix>mkvmerge file1.mkv + file2.mkv --output C:\Users\User1\mkvfolder\combined.mkv

This stitched two mkv files together (that were located in the MKVToolNix folder), and puts the combined.mkv file in a different directory. It seemed to me that changing the source directories for either of the original mkv's (file1.mkv, file2.mkv) should be possible as well, so I next tried this:

C:\Program Files (x86)\MKVToolNix>mkvmerge file1.mkv + C:\Users\User1\Documents\file2.mkv  --output C:\Users\User1\mkvfolder\combined.mkv

The above code merged file1.mkv (which I had placed in the mkvtoolnix directory) with file2.mkv (which I had located in a different directory), and placed the merged file (combined.mkv) in a third directory. The merged file ran cleanly in vlc, with no hiccups at the stitchpoint.

TL DR: go to http://www.fosshub.com/MKVToolNix.html, download MKVToolNix, and use the command line to merge mkv's.

like image 22
austinthemassive Avatar answered Apr 01 '23 05:04

austinthemassive