Guide for Re-encoding Blu-ray to x264 MKV With MeGUI
May 23, 2009
This guide will show you how to re-encode a Blu-ray movie to a x264 Matroska container (.MKV).
Before starting please note that most computers will take over 32 hours to encode a 1080p movie with the recommended profile here (although you can also do a much faster profile which I will briefly cover). I do not recommend encoding on any laptop/netbook or desktop with lower specs then an Intel 2.4 Ghz Core 2 Duo. On lesser computers you may not be able to multitask or even move your mouse until encoding is complete. It took about 18 hours to encode the movie in this guide at an average of 9.74 FPS on the first pass and 2.78 FPS for the second pass on a Intel Core i7 @ 2.66 Ghz with 12GB of RAM and the HDDs in Raid0. Whatever computer you use, ensure that it has adequate cooling.
You will need:
- A Computer with Windows XP, Windows Vista, or Windows 7 (Windows XP users must have .NET Framework 2.0 installed to use MeGUI, untested in Windows 7 and will remain so until RTM)
- AnyDVD HD, version 6.5.4.0 or above although current version is always recommended to remove the latest BD+ protection
- AviSynth 2.5, (I used version 2.5.8, install first)
- MeGUI latest stable, (install second)
- MKVToolnix for Windows, (install third)
- ffdshow, media decoder and encoder (may not be required in Windows 7, I used the “tryout” December 22, 2008 build)
- eac3to 3.16 (extract to the root of C:\ or another location you will remember)
- Plugins for AviSynth, Mirror 1, Mirror 2, Mirror 3 (extract to Program Files > AviSynth 2.5 > plugins)
- SurCode DVD DTS, DTS audio encoder (not required if the source audio is AC3)
- Blu-ray compatible drive
- Blu-ray Movie
Setup:
Open MeGUI and update everything (an update screen should open on it’s own), when asked to import presets select and import everything. Close MeGUI. It may be a good idea to restart your computer at this time.
Put the Blu-ray disk in your drive.
Step 1:
Rip BD to Harddisk with AnyDVD (ending with step 3).
Step 2:
Open MeGUI.
Go to Menu Bar > Tools > AVS Script Creator.
Input the main movie, found within BDMV > STREAM (normally the largest *.m2ts). A preview window should open — leave it open.
Step 3:
Leaving the preview window open, pull up the “AviSynth script creator” window again. More options should be visible.
Tick “Crop” and then click “Auto Crop” (you may need to manually crop).
Next tick “Resize”, if you know what the true resolution is type it in, if not tick “Suggest Resolution (mod16)” then untick “Suggested Resolution (mod16)”.
Set Input DAR to ITU 16:9 NTSC.
If you want to do a 1080p (source) encode skip to step 4 (which I will be doing), if you want to reduce the resolution to 720p continue with this step.
My movie is 1920 x 816 (see the resize field), so I will use a table to figure out what resolution I must use for a 720p encode.
1080p Resolutions:
AR Resolution
1.333:1 = 1400 x 1080
1.666:1 = 1800 x 1080
1.777:1 = 1920×1080
1.839:1 = 1920 x 1044
1.846:1 = 1920 x 1040
1.853:1 = 1920 x 1036
2.341:1 = 192o x 820
2.352:1 = 1920 x 816 <– this is my source resolution
2.364:1 = 1920 x 812
2.376:1 = 1920 x 808
2.388:1 = 1920 x 804
2.400:1 = 1920 x 800
2.412:1 = 1920 x 796
720p Resolutions:
AR Resolution
1.333:1 = 960 x 720
1.666:1 = 1200 x 720
1.777:1 = 1280 x 720
1.839:1 = 1280 x 696
1.849:1 = 1280 x 692
1.860:1 = 1280 x 688
2.335:1 = 1280 x 548
2.352:1 = 1280 x 544 <– this is what my 720p resolution will be
2.370:1 = 1280 x 540
2.388:1 = 1280 x 536
2.406:1 = 1280 x 532
2.424:1 = 1280 x 528
Once you figure out your new resolution, type it in the resize fields.
Step 4:
Go to the last tab, titled “Edit”, this is where you can add filters such as ’sharpen’. Generally with 1080p encodes you will leave the encode as close to the source as possible.
At the bottom of the textbox write:
ConvertToYV12()
While it is very detailed and complex what this actually does, in short it can improve your encode and make everything a little smoother.
If you first would like to do a sample encode enter the following code at the bottom of the text box:
trim(xxxx,yyyy) # xxxx is the starting frame and yyyy is the ending frame so for 500 frames you will type trim(4736,5236)
Uncheck “On Save close and load to be encoded”, and then save.
If the MeGUI Script Creator and preview windows do not close, you can do so.
Step 5:
Now we get to work with the audio.
To check what audio streams you have to work with, open Command Prompt (Start > All Programs > Accessories).
You must change CMD to use the directory eac3to is in. I extracted eac3to to my C drive so I must type “cd c:\eac3to316″ (316 is the build number).
I placed Bedtime Stories on my desktop in a folder called “bedtime_stories” so I must type “eac3to c:\users\admin\desktop\bedtime_stories0000.m2ts” (please note that this will not work if you have a space in any of the folders or file names).
After processing the streams, eac3to will list them (explained below).

1) H.264/AVC this is the video, you can also see that it is 1080 pixels in hight, runs at an average of 24 FPS, and has an aspect ratio of 16:9.
2) DTS Master Audio this is an audio stream, you can see that it has 5.1 channels (used for a 5.1 surround sound system), and has a bitrate of 1509. This is the one we are looking for it can be called many different things, take note whether it is an AC3 stream or not.
3 & 4) AC3 this is another audio stream, Bedtime Stories was released with both French and Spanish languages as extras so this is one of those, bitrate of 640.
5 – 9) These are all subtitles, I’m not entirely sure what they all are although the movie includes English, French and Spanish subs.
Remember the track position of the desired audio stream.
This guide will now split for extracting the audio,
For AC3:
Use the following command:
eac3to “<drive>:\<folders>\<file name>.m2ts” <track>: “<drive>:\<folders>\audio_track<track number>.ac3″
So if I wanted the spoken language for my movie to be French I would write:
eac3to “c:\users\admin\desktop\bedtime_stories0000.m2ts” 3: “c:\users\admin\desktop\bedtime_stories\audio_track3.ac3″
Wait for eac3to to extract your audio (continue with step 6).
For DTS or True-HD:
If the audio is a form of DTS (such as this one) or True-HD you must have SurCode installed before continuing.
Use the following code:
eac3to “<drive>:\<folders>\<file name>.m2ts” <track>: “<drive>:\<folders>\audio_track<track number>.dts” -1536
I will be using:
eac3to “c:\users\admin\desktop\bedtime_stories0000.m2ts” 2: “c:\users\admin\desktop\bedtime_stories\audio_track2.dts” -1536
Wait for eac3to and SurCode to decode the audio to *.wavs, then encode to a *.dts.
Step 6:
Now that we know what format of audio we have we can calculate the bitrate.
Import the AviSynth Script that we just created (under video not audio), a preview window should open — you can close it.
Set the file format to MKV.
To set the bitrate we must go to Menu > Tools > Bitrate Calculator.
For audio type select the format you will be using (AC3 or DTS), for AC3 set the bitrate to 640 and for DTS set it to 1536.
Now you will have to decide on a bitrate. While every movie is different, I normally choose a bitrate anywhere from 9,000 to 14,000 kilobits/second for 1080p and about half that for 720p based on test encodes. This is definitely an art! For Bedtime Stories I found 12,100 kb/s to be good. If this is your first encode I would recommend using a preset of 1 DVD-9.
Click “Apply” (if asked to copy bitrate to video settings hit Yes).
Step 7:
For encoder settings we will create a custom profile, although use “x264: DXVA-HD-Fast” if your computer is slow or you don’t care much about quality and want to shorten the time to encode by about 3x (then skip to step 8).
Set profile to “x264: DXVA-HD-Insane” and click “Config” to change some settings which will speed things up.
Click on the “New” button call this custom profile what you want, I’m going to call mine “Insane Speedified”
Check Turbo, increase Threads to 6, and change the Deblocking Streagth to -3.
Go to the next tab (titled “RC and ME”), increase Number of Reference Frames to 5, uncheck “No Dct Deimation”, change M.E. Algorithm to “Multi hex”, and increase Psy-Trellis Strength to .8.
Next tap (“Advanced”), increase number of B-frames to 5, check B-pyramid, choose “All” for Macroblock Options.
Click “OK”!
You will be asked if you want to update the selected profile click “Yes”.
Step 8:
Now to encode the movie!
Hit Enqueue (the one in the video encoding box), this will queue your movie.
Go to the next tap called Queue, and hit Start.
A new dialog box will open reporting the current speed at which you are encoding along with other helpful info.
Step 9:
At this point you should have an AC3 or DTS audio stream, and an MKV with no audio. We now need to MUX them together into a single MKV.
Open “mkvmerge GUI” (installed with MKVToolnix) and the folder your files for encoding are in.
Drag both streams to the input box in mkvmerge.
Change the file name of the output so it will not overwrite the source.
Hit “Start muxing” and wait a few minutes… Yay! You completed your first encode, you should now be able to play the movie in your favorite media player!
Additional Notes:
Check back for our guide on adding subs to encodes! While you are waiting (it may be a *long* while out), experiment with SubRip to add subtitles to your encode (this can be helpful when the date or location of a scene is not part of the screen but a subtitle).
Post a comment and let us know if you have any tips, questions, or just want to let us know how it went!
Shouts to all of the people and sources who are not listed. I could never have learned how to encode without them!
Check with your governing laws before downloading/installing/enabling/using any of the programs listed here! You assume full responsibility!
AR Resolution
1.333:1 = 960×720
1.666:1 = 1200×720
1.777:1 = 1280×720
1.839:1 = 1280×696
1.849:1 = 1280×692
1.860:1 = 1280×688
2.335:1 = 1280×548
2.352:1 = 1280×544
2.370:1 = 1280×540
2.388:1 = 1280×536
2.406:1 = 1280×532
2.424:1 = 1280×528
1080p Resolutions:
AR Resolution
1.333:1 = 1400×1080
1.666:1 = 1800×1080
1.777:1 = 1920×1080
1.839:1 = 1920×1044
1.846:1 = 1920×1040
1.853:1 = 1920×1036
2.341:1 = 1920×820
2.352:1 = 1920×816
2.364:1 = 1920×812
2.376:1 = 1920×808
2.388:1 = 1920×804
2.400:1 = 1920×800
2.412:1 = 1920×796
Entry Filed under: All. .
15 Comments Add your own
Leave a Comment
Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>
Trackback this post | Subscribe to the comments via RSS Feed



















1. Guide for Unprotected Blu-ray ISO Playback with PowerDVD « RIBO Labs | May 23, 2009 at 1:03 pm
[...] Guide for Re-encoding Blu&hellip | May 23, 2009 at 12:59 [...]
2.
Scott | June 4, 2009 at 7:19 pm
So, how much space is saved after this process??
3.
Scotty | June 4, 2009 at 7:31 pm
> So, how much space is saved after this process??
I take it you are talking about source file size vs encode file size?
On average I find the encode will be 1/3rd the size of the source with no visible loss. Of course this greatly depends on the movie itself and what bitrate you use.
4.
Mart | June 16, 2009 at 10:54 am
Good guide, thanks.
One point about DTS tracks. If the audio track is DTS-HD/DTS-MA you can simply extract the core DTS track using the ‘-core’ switch in place of ‘-1536′ in the eac3to commands. This also has the advantage of not requiring Surcode.
I’m using this guide to encode video suitable for playback on PS3, so I’m selecting the profile in MeGUI ‘Standalone-PS3-Xbox360′. I wonder if there are more tweaks I can make to this profile to improve quality for PS3, ignoring the ability to playback on Xbox360 – does anyone know?
5.
Bas | July 5, 2009 at 4:02 am
Great tutorial thx, it helped me out a lot.
Mart thx also for sharing the tip about the DTS track.
6.
Lex80 | July 23, 2009 at 3:46 pm
Nice guide mate.
But about DTS-HD Master Audio,
is better just extract the core?
I have Surcode and Arcsoft,
so the programs are not a problem..
I’m asking for better quality?
I’m a bit n00bs, so I’m confused..
Thanks in advance!
7.
camon | July 29, 2009 at 3:41 am
If instead of DTS was TrueHD what should we put a the bitrate option. Should we put -1536. I’m a bit confused how can we calculate that or if that’s a standard
8.
Beatslars | August 3, 2009 at 10:38 am
The final process only encoded 30 seconds of video. What do I do?
9.
gremlin | August 6, 2009 at 3:54 pm
Beatslars
It sounds like you may have applied the optional step to make a sample of the video. Check to make sure that the “trim(xxxx,yyyy)” is not in the script.
Great guide. I had been using xvid for HD movies but x264 is much better. I think megui gives some of the best results although it takes double the time other programs I’ve used to encode x264 do (I guess that’s how it gives us such great results
).
10.
gremlin | August 6, 2009 at 5:37 pm
For those wondering about whether to use -1536 or -core to make a DTS track this guide should be useful:
http://en.wikibooks.org/wiki/Eac3to/How_to_Use
Like Mart said only use -core when the source audio file is DTS-HD/MA. Otherwise use -1536 or -768 depending on what the source bitrate is. Keep in mind converting to a bitrate higher than the source will loose quality.
11.
Chad Jacobson | August 25, 2009 at 3:10 am
Hello there,
Before my question, I want to offer serious thanks for taking all the time and effort you have to simplify the blu-ray re-encoding process. I’ve followed your directions to the letter, but when I start a job in the Queue, the MeGUI status window pops on and then immediately off and the job fails. After this failure, the end of my log entry reads as follows…”Standard error stream: C:\Program Files (x86)\megui\tools\x264\x264.exe: unrecognised option ‘–no-mbtree’. Any help or ideas would be profoundly appreciated. Thanks in advance for your time and attention.
12.
Kardargo | August 29, 2009 at 12:13 pm
Had the same probblem. error no-mbtree.
Try to replace the x264.exe with the most recent one that you can download from their site.
If that doesn’t work, here is another way to worj around the problem.:
In the encoding-profile enable mbtree in the advanced settings. Save the profile. Next just create your queue-jobs for encoding as you normally would. Dont start the job, but close megui.
In the megui-folder there is a folder named jobs. In it are the xml-files for the queued jobs (2 if your using 2-pass encoding)
Edit the xml-files, find the tag for mbtree and change the value within the tag from false to true.
Start Megui and go to the queue-tab. If you now start the jobs, things should work.
13.
Chad Jacobson | August 29, 2009 at 2:21 pm
Thanks so much Kardargo for your feedback! Since my last posting, somehow I’ve managed to get things to work. Wasn’t easy, but your suggestion to swap the x264.exe was indeed related to the solution. Ironically, what I discovered was only the latest 32-bit x264 makes things work on my 64-bit system. All this time I assumed the x64 version wasn’t a problem. Just finished my first encode with no errors. Thanks for taking the time to respond.
Best,
CJ
14.
Boz | August 30, 2009 at 4:17 am
A few notes.
Even though I agree and personally use DTS 1.5mbps in my MKVs simply because people will not hear the difference between 1.5mbps and DTS-MA audio streams (same goes with DD+ above 640kbps) because there’s only a certain level of quality we can hear, the overage in bitrate on DTS-MA and TrueHD is really kind of pointless. There’s a really great article about it where guys from Home Theater magazine visited Dolby and DTS labs and conducted blind test on DTS and DD vs DTS-MA and TrueHD.
http://www.hemagazine.com/node/Dolby_TrueHD_DTS-MA_versus_Uncompressed_PCM
The interesting part is that it’s not really shocking.
With this being said, and if you simply don’t accept the compromise the best possible size vs quality ratio including later ability to re-encode into something else I would suggest MKV + FLAC combo.
The reason is, you don’t need expensive SurCode DTS Pro encoder (FLAC will be generated with eac3to). Once you are done with transcoding the video only to drastically lower the size (do not transcode audio because it takes a lot of time) you should merge the streams with MKVMerge (MKVToolnix).
You will get mkv h264 video (my suggestion is to keep it between 18-20mbps bitrate) and FLAC which is lossless.
This combo is perfect and more or less future proof. You can re-encode audio into something else later if you need to.
15.
Beatslars | September 3, 2009 at 1:45 pm
I’m having a problem with the MKVMerge, it says I have:
————
encountered broken or unparsable data in this AVC/h.264 video track. Either your file is damaged (which mkvmerge cannot cope with yet) or this is a bug in mkvmerge itself. The error message was:
————-
I can’t seem to figure out what’s wrong, oh and when I ran command prompt I had to rip AC3, there’s was the video option to extract or the audio option which was a RAW/PCM.