Software List- CCCP
- If you'd like to avoid installing CCCP, which is not recommended, you can get the needed filters separately;
- MP4Box (the MP4 multiplexer)
- YAMB (a GUI for MP4Box)
- I myself use the 2.0 preview version, so far I haven't found anything wrong with it
- mkvtoolnix (the MKV muxing/demuxing tool)
- MKVE Wizard (a Wizard tool for extracting streams from MKV files, works like a charm)
- tc2mp4 (used to create a VFR MP4 file)
The following are not needed tools, but might be useful in a few occasions;
- MKVExtractGUI (a GUI for mkvextract found in the mkvtoolnix package)
- MediaInfo (a very useful tool for getting extended information on media files)
Some more software will be needed, depending on the type of file that you'd like to convert, but I'll get to that later on.
Installation Notes
Everything should be pretty straight forward, the only problem might be if you are not installing CCCP but are doing it the alternative way. In this case I won't provide any support and/or extended installation instructions. You're on your own.
Note 1: The MP4Box executable has to be in the same directory as YAMB.
Note 2: You have to set the path of where mkvtoolnix is located for MKVE Wizard under
Settings in order to extract the streams.
Note 3: When downloading tc2mp4, you have to copy the Perl script (found in the 3rd post of the thread on Doom9) and save it in the same directory where you saved the executable file as
tc2mp4.pl. You also have to copy the MP4Box executable into that directory, otherwise it won't work.
Note 4: MKVExtractGUI has to be in the same directory as mkvtoolnix if you downloaded it.
What type of MKV file do I have?
MKV supports many features, like softsubs. These cannot be added to an MP4 file, since they are not supported by the ISO standard. The same goes for Vorbis audio. So some precautions have to be take before you start. It also supports VFR (Variable Framerate), which is slightly trickier to convert into MP4. But I'll get to that later on.
I will group here the different types of MKV file that you can get, and assign different sections of this guide for them. The easiest way to find out basic information about the file is to open it in Media Player Classic and
right-click on the video (or alternatively click on
File in the Menu) ->
Properties -> move to the
Description tab and look in the box at the bottom.
1a) MKV with AAC/MP3 audio, H264/XviD video and no softsubs.
This is the easiest one to convert. Move to section
1a for the steps.
1b) MKV with Vorbis audio, H264/XviD video and no softsubs.
This is fundamentally the same as the above, the only difference is that it contains Vorbis audio, which is not supported by MP4, so it will have to be re-encoded to something like AAC. Move to section
1b for the steps.
2a) MKV with AAC/MP3 audio, H264/XviD video and softsubs.
(Coming Soon?)
2b) MKV with Vorbis audio, H264/XviD video and softsubs.
(Coming Soon?)
The Fun
Section 1a (no re-encoding needed, just some more relatively complex demuxing and muxing)
1) Firstly you will need to demux the video and audio track from the MKV file. I recommend using MKVE Wizard for the easy of use. I'm going to base this on the file that I used for the demonstration earlier on. So you find select the file that you would like to demux in the
Input field, and use the
Output field to find the location where you would like to demux the tracks from the MKV file. There's nothing important on this screen, so click
Next. The next screen should look like the following (note that if the MKV did not have chapters to start with, they will not be listed since they can't be created from thin air and you won't be able to demux them):
Now you should check the tracks that you would like to demux, which in most cases would be the video, audio and chapter (if available) track. Also leave the other options on the right side as they are, unless you know what you are doing. Now click
Next and the tracks will get extracted into the specified directory. After the process is finished you can click
Finish and close the wizard.
2) Now you will have three files (or two if there was no chapter file) in the Output directory that you specified. It should be a *.h264 (for H264 video)/*.avi (for XviD video) and *.aac (for AAC audio)/*.mp3 (for MP3 audio) and *.txt (for the chapter file). Now you have all the files so you are ready for the next step.
3) This step is short. All you need is to obtain a plain video MP4 file from the *.h264 file. For this you will need to use YAMB. Please reference to step 6 for the instructions. But note that at this stage all you need is only video, nothing else.
4) Now you need to extract the timecodes file from the MKV (this step must not be skipped). This can be done by starting up the
mkvextract executable from the mkvtoolnix package from the command prompt. So click on
Start ->
Run (or press the
Windows Key +
R on your keyboard for a shortcut) -> type in "
cmd" (without the quotes of course) and click
OK. Now you will have to start the executable from there, so type in "
mkvextract", hit Enter on your keyboard and it will show all the options. Now to check for the timecodes;
Code:
mkvextract timecodes_v2 <inname> [TID1:out1 [TID2:out2 ...]]
Let's say that you have a file stored under
"C:\Videos\Video01.mkv". You will have to type in
Code:
mkvextract timecodes_v2 "C:\Videos\Video01.mkv" 1:"C:\Videos\Video01_timecode.txt"
and it will extract the timecodes file into
"C:\Videos\" named as
"Video01_timecode.txt". Don't delete this file, you will need it in the next step. And for God's sake, don't even bother amending it.
5) Now comes the hard part. If you tried playing the file that you got from the previous step you might have noticed that it is shorter (or longer?) than the original MKV file. It depends on the source. This little step will fix that (or at least should). Open up the command prompt again, as explained in the previous step. Now you will have to do some navigating. First off you have to note down the full path of the directory where you saved tc2mp4. You will have to navigate to it now. In the command prompt window, type in "
cd "C:\path\to\tc2mp4\"". Just substitute in the location where you saved tc2mp4 on your system. Then hit Enter and your current location should have moved there. Now you can type in "
tc2mp4" and it will show up what the parameters for it are. On my computer it looks like the following;
Now you are ready for the action. Let's say that the video MP4 file was saved under
"C:\Videos\" named as
"Video01.mp4", the command line will look like the following:
Code:
tc2mp4 -i "C:\Videos\Video01.mp4" - o "C:\Videos\Video01_output.mp4" -t "C:\Videos\Video01_timecode.txt"
Now press Enter and the process will start. Make sure that you got the filepaths correct, otherwise it's not going to work and it will throw out an error (184 IIRC). This will take some time (a few minutes at most), depending on the video length and the timecode format. At the end it should throw out an MP4 file, of the same length as the MKV that you started with (if it is a second shorter or longer, then it might get corrected during the next stage. I'm not sure why this happens, so far I haven't done much testing to conclude whether this affects the final audio/video synchronisation by a noticeable margin).
6) Open YAMB, and click on the option to
Mux or to
Create an MP4 File. I will be basing this on the 2.0 Preview version of YAMB. So you select the appropriate choice and the following screen should look like:
Now you are ready to drag & drop the extracted files in that window. Use the new MP4 file that you got from tc2mp4. I recommend adding the video first, then audio and finally the chapters file (in the end you can just move them up and down if needed). If you feel like having a play around with it then you can click on
Properties and fill out the fields for each track, but I won't bother going into explaining it. It's quite simple and easy after all. Set the
Output file and click
Next and the file will get created. Afterwards click
Finish to close YAMB. If you got to this step without any problems and the file plays correctly, then you should be a happy (and tired...and maybe even crazy) bunny. ^^
Section 1b (audio re-encoding needed, otherwise the same as section 1a)
Note that by re-encoding audio you will lose quality.
Additional Software needed:- AviSynth (a frameserving application, in this case it's gonna be used for audio serving though)
- Nero Digital Audio (the encoding application for AAC)
- BePipe & SNG (BePipe is a tool which takes AviSynth audio output and feeds it into a WAV file; SNG is a GUI for the Nero Encoder)
Installation Notes:
Put the BePipe executable into the same directory where you placed the Nero encoder. Also, put the SNG executable in there too, so that you can use the GUI and all the features that it offers.
1) Follow steps 1 to 5 from section 1a to deal with the video stream.
Now you will need to re-encode the Vorbis audio to some other format. In here I will use AAC, however MP4 supports more formats like MP3 and who knows what else. In here I will use AviSynth to feed the audio through DirectShow, BePipe to convert the RAW output into WAV and then NeroEnc to encode it to AAC. It sounds complicated, but it's actually easier than you think. (Maybe there is an easier way, I do it like this so I never bothered looking up alternatives. If you know of something easier/better then please tell me so.)
2) Open up SNG (Simple NeroAaacEnc GUI). Click
Add and find the Vorbis (*.ogg) file that you'd like to encode. Now move to the
Encoder tab. Here you will find some settings. I really don't want to enforce any specific type of settings, but leave the
Advanced features as they are. VBR mode should give better quality than CRB or ABR (though IIRC I read somewhere that ABR gives better results at lower bitrates). Either way you want preferably want to match the same bitrate as of the original Vorbis file to keep roughly the same filesize of the final MP4 file. I'm not really sure of any program that can give you a specific bitrate of a Vorbis file (I just use Winamp for it). So based on that you will have to decide what quality setting to use. Most likely it will be ABR 128kbps and higher (which is VBR quality 0.5? - not 100% sure here). You should leave the rest as it (just to be sure switch over to the
Avisynth tab and make sure that
Normalize is left unchecked) is and click
Encode, which will open up a command prompt where you will be able to see the progress. At the end it will spit out the AAC audio file in an MP4 (or M4A if you checked the option; either way it's the same container just different extension) container.
3) Now you can mux it with the video using YAMB. Just follow step 6 in section 1a. One thing that needs to be noted is that when you drag the encoded AAC audio file to YAMB, more "streams" will appear. Just uncheck the ones that aren't reporting any details/data.
I know. It's somewhat complicated, and for now I don't really see a simpler solution (unless someone feels like writing a script for it). MKV is a bit of a sucker to convert. So I wouldn't recommend doing it either way, unless you really feel like it's worth the trouble and time (not everything can be done with a one-click magic application, that way it wouldn't be so much fun). The rest will be coming up sometime later (mind you I'm in the middle of my exams, right now with some spare time before my next one). Only this took me 5 hours to write up with some testing on my side. >_>