MKV [Demuxing , Encoding and Muxing] Tutorial

Zeeshan Quireshi

C# Be Sharp !
Well guys as Matroska(MKV) is getting popular by the day and with most HD Content being distributed in the MKV Container I’m writing this tutorial to help those who want to work with MKV or want to convert them to something else(MP4 here) .

Software You’ll Need:

1. MKVToolNix - *www.bunkus.org/videotools/mkvtoolnix/downloads.html

2. H.264 Info - *sourceforge.net/project/showfiles.php?group_id=138139&package_id=225029

3. MeGUI - *sourceforge.net/projects/megui

Part 1 : Demuxing an MKV into elementary streams

1. Start MKVMergeGUI from the MKVToolNix Installation Folder

2. Drag and Drop your MKV Video file to the “Input Files” container .

3. Notice the Streams you want to extract .

*farm3.static.flickr.com/2146/2124961454_cebe61547e_o.png

4. Now open a Command Prompt from
Start->Program Files->accessories->Command Prompt

5. Change to the directory where you have MKVToolNix installed

6. Now to demux the file you’ll use a program called mkvextract .

7. On the command prompt , type this code:

mkvextract tracks <Full MKV Path> 1:<Full path where you want to store your Extracted Video> 2:<Full path where you want to store your Extracted Audio>

Note: The most simple way to enter path of a file in CMD is to just drag and drop it into the Prompt and it’s path will automatically be added .

*farm3.static.flickr.com/2169/2124187061_ede9f20f26_o.png

8. This will extract the Video and Audio streams separately in the locations C:\Video.264 c:\Audio.aac

Part 2: Encoding the Video and Audio

1. Open up H264Info

*farm3.static.flickr.com/2337/2124961202_ef9d79403c_o.png

2. Load the file using the input button and then change the Profile Level of the file to 4.1 , this will make sure that the H.264 Video plays well on most HD Players and the Xbox 360 as well .

3. Save the output as video-4.1.264

4. Now if you want to encode the audio then encode it to whatever format you like using any encoder like dBPoweramp or whichever encoder you like . we’ll leave the audio encoding part here as AAC works fine .

Part 3: Muxing into an MPEG-4 File

1. Now , to combine these streams into s single MP4 file we’ll have to Multiplex it.

2. Fire up MeGUI

3. Go to Tools->MP4 Muxer

*farm3.static.flickr.com/2109/2124961578_88cf0769e3_o.png

4. Now set the Video Input , the Frame Rate , the Audio Input and Finally select the Output Destination .

5. The resultant file is a fully standards compliant mp4 file and will play in any player that supports H.264 and AAC .
 

nish_higher

Wise Old Owl
can u tell me---what was the need of converting video.264 to video-4.1.264 when in the 3rd step u r using video.264

am i missing something


eDit---

tried and this error popped up

Processing ended at 18:26:11

------------------------------------------------------

Log for job job1

Job commandline: "C:\Program Files\megui\tools\mp4box\mp4box.exe" -add "F:\video-4.1.264" -add "F:\audio.aac" -fps 23.976 -tmp G:\ -new "G:\Transformers.mp4"
AVC-H264 import - frame size 1024 x 432 at 23.976 FPS
Import results: 206453 samples - Slices: 2523 I 112051 P 91879 B - 208857 SEI - 2404 IDR
Stream uses B-slice references - max frame delay 2
AAC import - sample rate 11025 - MPEG-2 audio - 3 channels
Error importing F:\audio.aac: Bad Parameter

------------------------------------------------------

End of log for job1
------------------------------------------------------
 
Last edited:
OP
Zeeshan Quireshi

Zeeshan Quireshi

C# Be Sharp !
nish_higher said:
can u tell me---what was the need of converting video.264 to video-4.1.264 when in the 3rd step u r using video.264
Well the Xbox 360 and most "normal" HD Players do not suport Level 5.1 H.264 Content , so changing the Level to 4.1 Makes it compatible with most the H.264 Players out there .

Also , level 5.1 means having a Bitrate of greater than 240 mb/s which is much much greater than the 36 mb/s which the HD-DVD and Blu-ray support , so even the most advanced optical technologies today can only support a maximum of Level 4.1 H.264 Content , so that's why we make it sure than the Level Rating of the content is changed to 4.1 or lower .

as for the Error , i think you've misspelled the filename .
 

sushtsi

Right off the assembly line
Thanks for the info!

How do I go about doing this for a file with AC3 audio?

Ive tried with several different videos but always get the same error.

This is the log from MeGUI

Log for job job2
Job commandline: "C:\Program Files\megui\tools\mp4box\mp4box.exe" -add "C:\video41.264" -add "C:\audio.ac3" -fps 23.976 -tmp C:\ -new "C:\video41-muxed.mp4"
AVC-H264 import - frame size 1280 x 528 at 23.976 FPS
Import results: 198866 samples - Slices: 2279 I 71772 P 124815 B - 200966 SEI - 2100 IDR
Stream uses B-slice references - max frame delay 2
Unknown input file type
Error importing C:\audio.ac3: Corrupted Data in file/stream


Does the ac3 file need to be converted to another format? I am planning to reburn this to watch on an HD-DVD standalone player and would like to keep the multi-channel audio

Thanks,

Sachin
 

Salman82

Right off the assembly line
Well I've tried almost "EVERYTHING" to split my 8GB MKV (of Transformers 2) cuz its heavy to play with any player.

Anywayz.......I'm still unable to split using "MKVtoolnix" software, I've tried every option every tutorial on NET.....but useless, every time it exports a SINGLE FILE of 8mb thats it.
No error nothing else ..... !

CAN ANYONE HELP ME WITH THIS ???

Please I will appreciate it .... as I've spent more than 3 hours messing with dat F****g software MKVToolnix.

PLEASE HELP !!!!!!!!!!!!
-----------------------------------------
Posted again:
-----------------------------------------
Well I've tried almost "EVERYTHING" to split my 8GB MKV (of Transformers 2) cuz its heavy to play with any player.

Anywayz.......I'm still unable to split using "MKVtoolnix" software, I've tried every option every tutorial on the NET.....but useless, every time it exports a SINGLE FILE of 8mb thats it.
No error nothing else ..... !

CAN ANYONE HELP ME WITH THIS ???

Please I will appreciate it .... as I've spent more than 3 hours messing with dat F****g software MKVToolnix.

PLEASE HELP !!!!!!!!!!!!
 
Last edited:
Top Bottom