CONVERTING MKV FILES TO AVI FILES ================================= v1.0 - creaothceann, 2009 I. SOFTWARE II. CONVERTING III. ENCODING NOTES I. SOFTWARE ----------- 1. get AviSynth (http://avisynth.org/) 2. get FFmpegSource (http://code.google.com/p/ffmpegsource/) and put the relevant files (*.dll, *.avsi) into AviSynth's "plugins" directory 3. get DirectVobSub (http://sourceforge.net/projects/guliverkli2/files/DirectShow%20Filters/DirectVobSub%202.39/) and put the DLL into AviSynth's "plugins" directory 4. get MKVToolnix (http://www.bunkus.org/videotools/mkvtoolnix/) and MKVextractGUI (http://coreforge.org/projects/mkvextractgui/) 5. get MPlayer (http://www.mplayerhq.hu/) and/or VirtualDubMod (http://sourceforge.net/projects/virtualdubmod/files/) 6. optionally, download and install the Combined Community Codec Pack (http://cccp-project.net/) if you have not already done so II. CONVERTING -------------- 1. Use MKVextractGUI (it will tell you what files it needs) to extract the subtitles (for example *.ass) from the MKV file. When it has finished, a message box will appear. Remove the text files that were also created. Note: The subtitles can also be extracted from the command line, see the documentation of mkvextract.exe for details. 2. Use MKVextractGUI to extract the fonts (for example *.ttf) from the MKV file. MKVextractGUI might terminate without error message. The fonts can also be extracted from the command line, see the documentation of mkvextract.exe for details. Copy the fonts to your Windows "Fonts" directory ("%WINDIR%\FONTS"). 3. Use MKVextractGUI to extract the audio (for example *.ac3) from the MKV file. Convert it to the WAV file format, for example with Winamp's DiskWriter output plugin. You can open AC3 files in Winamp with the WinampAC3 input plugin (http://ac3filter.net/projects/winampac3). 4. Create a new text file (for example with Notepad) and enter these lines: v = "MySourceFile.mkv" a = "MySourceFile.wav" s = "MySourceFile.ass" FFIndex(v) FFVideoSource(v, fpsnum = 24000, fpsden = 1001) AudioDub(last, WAVSource(a)) VSFilter_TextSub(s) Adjust the file names. The final frame rate will be fpsnum divided by fpsden; usually 24000/1001 produces correct results with the subtitles. Save the file as a plain ANSI text file with the file extension ".avs". 5. Open the AVS file in VirtualDubMod and encode to an AVI file. Make sure you have set the video & audio compression accordingly. Use "fast recompress" to avoid color space conversions. Alternatively, use MEncoder to encode to AVI. This will encode to HuffYUV video and uncompressed audio: mencoder MySourceFile.avs -o MyOutputFile.avi -oac pcm -ovc vfw -xvfwopts codec=ff_vfw.dll:compdata=dialog (MEncoder must be in the %PATH% environment settings.) See the MPlayer/MEncoder documentation for more codecs/DLLs. III. ENCODING NOTES ------------------- VirtualDub operates in RGB color space only, but most distribution video codecs use the YUY2/YV12 color spaces. Use the "fast recompress" option in VirtualDubMod to avoid switching color spaces. Encoding trades CPU workload against disk space. For slow CPUs and for video editing there is currently an optimal solution: FFDShow's "HuffYUV" codec. In VirtualDubMod, go to "Video | Compression..." and select "ddshow Video Codec". Click "Configure" and select the following settings: Encoder: HuffYUV FourCC: HFYU Colorspace: YV12 Predictor: Median Adaptive huffman tables: checked (The MEncoder example above also uses this encoder instead of the built-in codecs.) HuffYUV is a lossless codec and creates very large files - at HD resolutions (1280x960) it can grow to 50 GB and more for half an hour of video. The advantage is that very little CPU load is required, and that every frame is a reference frame (important for video editing). The best lossy codec is probably x264 (i.e. h.264). If file size doesn't matter you can use single-pass encoding with a very high bitrate. For a lower bitrate or smaller file size you can use two-pass encoding; this assigns bits more intelligently than single-pass encoding. In VirtualDubMod, select "x264vfw" as the encoder, and in the "Configure" dialog select the appropriate rate and pass.