Converting Blue-Ray/HD-DVD/TS/DVD/AVI To x264(MP4) using MeGUI



Introduction:

In this guide i will discuss how to use MEGui to convert any DirectShow compatible video source to x246 (MP4). With this guide you will be able to convert AVI, DVD, Blue-Ray, HD-DVD, Real Media, or any other video source that can be played via the DirectShow interface (the file plays in Windows Media Player).

Required Softwares:

AnyDVD-HD(Shareware)
AviSynth
EVOdemux
GraphEdit
meGUI
.Net Framework 2.0
Nero Digital Audio Encoder
SubRip
TsRemux

Suggested Softwares:


                                       
a)
K-Lite Mega Codec Pack(FFDShow, Haali Media Splitter, Media Player Classic and Many other codecs are included)

                                       
b) VirtualDubMod (for AVI Sources)

AnyDVD-HD: This is commercial software but one that I would highly recommend. It is the absolute cornerstone to all of the preceding information found in this thread. AnyDVD-HD removes all encryption and copy protection on the fly from your Blu-ray, HD-DVD or DVD as soon as you load a disc into your drive. This application will allow you to rip your movie onto to your Hard Drive.


BD Rebuilder:
An all in one application that re-authors a Blu-ray disc. This application gives you the option to keep the entire disc (menus, extras etc.) or just the main movie. The choices available for your target size are DVD-5, DVD-9 or BD-25.

Download and install AviSynth. If you are a DVD-RB user, it is already there. If not it is required for BD Rebuilder to work. You can download AviSynth from this link.
Unzip the BD-RB.zip file. Put it in a directory of its own. I'd recommend putting it somewhere other than "C:\Program Files" until it has been tested more (because of Vista's virtualization).


Please note:
This is NOT A DECRYPTER. It is a BD Reencoder and reauthoring package. If you are planning to back up discs that are encoded or copy protected using other software (such as AnyDVD-HD) that is a decision you are making independently of BD-Rebuilder and it is assumed you are staying within the laws applicable to you. BD-Rebuilder is meant as a means of backing up copies of discs THAT YOU OWN. It is NOT meant to be used as a means for copyright infringement.
Either copy the disc to be backed up to your hard drive or read it from the original. You will find that BD Rebuilder will work faster from a hard drive.

  • Create a working directory somewhere in your file structure. I use a folder called "D:\WORKING".
  • Run BD Rebuilder. Select the source directory (the one containing the BDMV folder). Also select the WORKING directory.
  • Click on "BACKUP". Then find something else to do... because this is going to TAKE A LONG TIME. My system usually backs up a disc in about 12-16 hours. So you may want to consider running it overnight. Your experience will differ depending upon your computer's CPU and disc speeds. Why does it take so long? Because you are encoding at very high resolutions  and they require a lot of work. Also, BD-RB hasn't been optimized for speed as yet... but in truth the real speed improvements will have to come with updates to X264 and faster processors.
  • How good will it look? My experience is that rebuilding to a dual-layer DVD+R results in a backup that is virtually indistinguishable to the original. DVD-5's will work fine for movie-only encodes... and some full discs. But beauty is in the eye of the beholder and is very subjective. My advice is to try it and see.


Note:
If you are having difficulty reading your source files due to codec issues, you can try demuxing your source file using TsRemux. This can be useful if you want to grab a specific audio track from an HD source.


Testing your configuration:

In order to properly input Blue-Ray/HD-DVD video, your PC must be capable of using DirectShow to play back the M2TS or EVO files. To test this, you can create a simple AVISynth script with Notepad. If you know yours is working, you can skip this step.

Your AVISynth script should have only one line. In this example I'm simply checking to see if the script will play back in Media Player Classic. If you are not familiar with AVISynth, I would suggest you check the GUIDES section as that is another topic. The script in my example needs only one line. This will allow me to verify my AVISynth install is working and that DirectShow can properly decode my source. Open Notepad and use the DirectShowSource command to point to our input file:

DirectShowSource("C:\Media\Video\HP5_PHOENIX\BDMV\STREAM\00000.m2ts",fps=23.976,audio=false)

Note that you could use the above example for your input, but it may not match your source, and of course the input file path wouldn't match your input. Lastly, the frame rate (FPS) may not match your source You would need to correct those three things for your specific input.

In any case, once you have created and saved your sample AVISynth script with Notepad, save it as "test.avs". You can then open it with your player of choice. I prefer Media Player Classic. If your PC is properly configured, you should get video with no audio. Note that it doesn't have to play smoothly as your PC may not be capable of keeping up with 1080p video. Once you have verified that your PC is able to read the input via DirectShowSource, then you are ready to move on to the next step. If your PC will not open the file (you get filter errors with AVISynth), then you have Codec issues. This is not something that a generic guide can help you with as the possibilities are almost endless as to what you may have installed and what order your filters are using. You should post your specific issue in the main forum to resolve those issues. For my test bed, I installed
K-Lite Mega Codec Pack and VirtualDubMod. There were no other codecs installed. I also disabled the Nero Splitter as it overrides the Haali splitter, preventing Haali from being used. This is an example of software causing conflicts.

It has been reported that .EVO files from HD-DVD in particular can be problematic for DirectShow decoding. This is most likely due to the splitter that is being used. You can manually demux the file (the splitter would normally do this for you). In any case, If you are having problems with .EVO source files, use the following steps to demux your files and then use GraphEdit to create a DirectShow compatible file.

Demux/Rebuild the EVO with EVOdemux to remove unwanted audio streams and subs then use GraphEdit:
Haali Media Splitter ---> WMVideo Decoder DMO
Once you have built that filter with GraphEdit, save it as video.GRF and make and AviSyth script with Notepad or a similar text editor:

DirectShowSource("C:\FILEPATH\video.GRF",fps=23.9759856527702,audio=false)
ConvertToYV12()



and save that file as a .avs file. If everything has gone well, you should be able to play that .AVS file in your media player.

Configuring MEGUI:

Follow this Guide.

MeGUI itself only accepts input from AVISynth files (.AVS). AVISynth in turn can accept input from a multitude of input sources. I assume the reason for this is just to ensure they have consistent input on a known interface. Makes troubleshooting and coding easier I suspect. No worries if your AVISynth impaired however, as it has a handy AVISynth Script Creator that will do the dirty work for you. Lets get started...

Selecting your input:



To select your input, you must give MEGUI an AVISynth input file to work with. For this example, I'm working on a Blue-Ray rip. You can use almost any type of input however (DVD, AVI, TS, RM, etc). If you drag and drop a source video file onto MEGUI it will typically open the AVISynth Script Creator for you. Under Vista, the drag and drop doesn't function so you always have to browse to your source. For simplicity's sake, I would suggest you just select the AVISynth Script Creator manually from the menus.

The idea here is to browse to your MPEG, AVI, .D2V file, or whatever source your using with the AVISynth Script Creator. From that, an AVISynth script file will be created that will be used as input for MEGUI. Open the AVISynth Script Creator now from the TOOLS menu (Tools -> AVISynth Script Creator). Note that there are Keyboard shortcuts listed next to most of the tools if you like that sort of thing (Control + R).

In the Video Input section, you select your input file. The Script Generator will accept input from any DirectShow compatible source, although the input is filtered to show only the following file types:
D2V Creator (.d2v ) files
mpeg-2 (.m2v, .mpg )
.avi,.mp4,.mkv, .rmvb
VirtualDub frameserver files


You can also just enter an asterisk "*" to force it to show all files. Again I should note that you can technically use any input that can be read via DirectShow ( files like .m2ts, .ts, etc will work as long as you have the necessary codecs installed). This allows you to convert files like Blue-Ray, HD-DVD, HDTV, etc. I would suggest you get a good splitter like Haali Media Splitter. FFDShow has also made huge leaps in quality. Bothe Haali Media Splitter & FFDShow are included in
K-Lite Mega Codec Pack. It's an easy addon that will allow you to decode and play just about any media file type.



For my example, I'm going to browse to my Blue-Ray rip of The Fifth Element. The file has an .M2TS extension, so it's not an 'allowed' input type for MEGUI by default. However I have FFDShow installed and the Haali Media Splitter, meaning the file can be viewed with DirectShow. As you register files with a media player, they may show up in the list. Once you select your source file, assuming it is DirectShow compatible, it should show up in with a preview window. If you do not get a preview window, and you see an error, that would indicate your source isn't setup properly for DirectShow. Post your issue in the main forum in that case.

If your input source is MPEG based (.MPG, .TS, .M2TS, .M2V, etc), and you do not have compatible codec installed, you can use D2V Creator to create a .D2V file which can be read by MEGUI. D2V Creator is one of the Tools that is updated/downloaded automatically by MeGUI. You'll find it in the tools folder of your MeGUI install.

Just Open your MPEG file with D2V Creator and save your project as a D2V file. For my Blue-Ray project, I will use
D2V Creator to extract the audio track from my .M2TS and to read the file since it creates a .D2V file for me. Note I could simply use the .M2TS file directly for video if I chose to since I have FFDShow and Haalie Media Splitter installed.

If your input source is AVI then you can simply select your AVI file directly.

OPTIONS Tab:

Once I select my Source .D2V file in the AVISynth Script Creator screen I see a preview window. The preview window size can be changed by dragging the window edges. Bigger sources makes the window unwieldy so I would suggest you make it small enough so that you can see the MEGUI interface underneath. Leave the preview window open as we'll be modifying some elements on the preview screen.



The Input DAR (Display Aspect Ratio) should be displayed. In my case, my input is 16:9. Directly below that is a checkbox for 'Clever (TM) anamorphic encoding'. This option allows you to simply encode the video as is without any drastic resizing. This is desirable so that you do not have to unnecessarily resize your video. The encoding process will embed the Aspect Ratio of your video when it is encoded so that it is stretched back to the proper proportions during playback. I would highly suggest you select this option. For the Anamorphic option, I always choose "Overcrop to achieve mod 16" to avoid any resizing at all. If your a bit anal about having any of your video cropped, you can choose "Resize to Achieve Mod 16". MEGUI will require that your video's dimensions are divisible by 16. Choose one of those two options (resize to mod 16 or overcrop to mod 16).



Below that, you'll see the 'Auto Crop' button. This function will easily remove any letterboxing that may be present. It will also remove any wasted black or noisy edges on your video. I would suggest you use it every time, even if your video appears to fill the preview with no letterboxing.
(Before Autocrop)


(After Autocrop)



Once you have the preview properly cropped, then click on the FILTERS tab at the top of the MeGUI Avisynth Script Creator window.

FILTERS Tab:


From here you should analyze your source video for interlacing and field order. This is important and not something you should skip. I can't say how many times I've encoded a project that seemed to be entirely progressive only to find a scene that was mixed. Getting the field order right is also important. Note that if your source is Anime/CGI then you should check the option "Source is Anime (isn't detected automatically)" before analyzing your material. Once the analysis is completed you can also choose what Resizing and noise filtering options you want. Since we are using the 'Clever Anamorphic Encoding' option, we won't be resizing anything. This option is applied only if you are actually resizing the video. If you selected "Resize to achieve Mod 16" on the Options tab then I would suggest you select Lanczos4Resize as your resizing option. That would give you the sharpest resize with the least loss of detail. I would suggest you always leave "Minimal Noise" selected, even for 'clean' sources. For older source material, I would suggest you select "Little Noise". Anything beyond that can have a noticeable softening affect which you may find unpleasant. Experiment here to find what you see as acceptable. This setting can have a very beneficial effect on Bit Rate usage even when the noise isn't immediately obvious to you. Below that you also have options for Mpeg2 Deblocking and Colour Correction. The Deblocking option is useful if your source has obvious macroblocking (this would sometimes be the case on previously encoded MPEG material like home burned DVD or SVCD's). The Colour Correction option ensures the colors are calibrated properly. I tend to avoid both of these filters as I have found little use for them.

EDIT Tab

 The EDIT tab allows you to make any final modifications to your AVISynth script before saving it. For instance if you wanted to tweak some of the filter functions, resize it or add an additional filter, etc. You can also add preconfigured text that will always show up here. You'll find those options in your MEGUI settings. If you have no other modifications to enter, you can just click SAVE in the bottom right corner of the AviSynth Script Creator window.

From here you will have a Preview Window and you main MEGUI screen with the Input Source filled in. You can also click the 'Show DAR' option to see what your output video will look like on playback (that options displays your output properly stretched out according to the Display Aspect Ratio).

At this point you can close the preview window.

Choosing your Video Profile:

Choose the Video that fits your needs.



DXVA-HD-Anime_Toons Fast
DXVA-HD-Anime_Toons HQ
DXVA-HD-Fast
DXVA-HD-Balanced
DXVA-HD-HQ
DXVA-HD-Extra Quality
DXVA-HD-Insane
DXVA-SD-Anime_Toons Fast
DXVA-SD-Anime_Toons HQ
DXVA-SD-Fast
DXVA-SD-Balanced
DXVA-SD-HQ
DXVA-SD-Extra Quality
DXVA-SD-Insane


The "DXVA" group presets ensure DXVA hardware compatibility and good compression/quality. The 'FAST' tagged profiles are consistently faster but have a bit lower compression/quality (this is true for other preset groups too). Those presets replace the old HQ and AE ones. The SD and HD tags mean for Standard Def and for High Def. encodings.

Device-Archos605
Device-Cellphones_PDAs-Level1.0
Device-Cellphones_PDAs-Level1.1
Device-Cellphones_PDAs-Level1.2
Device-Cellphones_PDAs-Level1.3
Device-iPhone
Device-iPod 5.5G
Device-iPod
Device-PSP
Device-Zune


The "Device" group presets, is for Portable Devices compatibility.

Standalone-AppleTV
Standalone-AVC-HD
Standalone-PS3-Xbox360
Standalone-PS3-Xbox360_Fast
Standalone-Xbox_HiRes
Standalone-Xbox_LoRes
Standalone-Blu-ray
Standalone-Blu-ray_Fast
Standalone-HD-DVD
Standalone-HD-DVD_Fast


The "Standalone" group presets, ensure compatibility with Stand Alone players and devices.

Unrestricted 1pass ABR
Unrestricted 1pass ABR Fast
Unrestricted 1pass MaxSpeed
Unrestricted 1pass Const. Quality Anime_Toons
Unrestricted 1pass Const. Quality Fast
Unrestricted 1pass Const. Quality Balanced
Unrestricted 1pass Const. Quality Extra Q.
Unrestricted 1pass Const. Quality HQ
Unrestricted 1pass Const. Quality Insane
Unrestricted 1pass Lossless
Unrestricted 2pass Fast
Unrestricted 2pass Balanced
Unrestricted 2pass HQ
Unrestricted 2pass Extra Quality
Unrestricted 2pass Insane
Unrestricted 2pass Anime_Toons Fast
Unrestricted 2pass Anime_Toons Balanced
Unrestricted 2pass Anime_Toons HQ
Unrestricted 2pass Anime_Toons Extra Q.
Unrestricted 2pass Anime_Toons Insane
Unrestricted 2pass QuickTime for Windows


The "Unrestricted" group presets is for people not caring about hardware compatibility and are particularly good for mid-high/high end completely software PC playback (without DXVA videocards). Those ones are good to replace HQ and AE presets too. 1 pass ABR presets are not recommended. Those are there only because the encoder support that mode OR if you need fast encodings and somewhat have bitrate limits, try to not use them. 2pass or other modes will produce way better results. The maxspeed preset uses constant quality and minimum settings.

Additional notes: If you dont know what preset to choose or you're uncertain, use the DXVA HD or SD (depending on the source definition: SD - standard definition, HD - High definition) presets as default encoding presets or Unrestricted 2pass HQ or Balanced.
All anime/toons of all presets groups have Psy-RDO DISABLED and a higher deblocking filter values.
The presets are made for MeGUI however you can port or include them in other encoding GUIs or Apps.


Choosing a video profile may seem a bit daunting considering the options you are presented with. There are a few factors to take into consideration when you do choose one.
What is your target player?
What kind of processing power do you have to encode your media with?
How much time do you want to spend?

 Choose the profile from the Video Profile dropdown, and then click the Config button if you want to Change the Profile Settings.

At this point, you can begin encoding your video if you like, however I would suggest you also setup your Audio option at this point.

For you audio, you can demux it using a variety of methods depending on your source material. For any MPEG-2 type material (.m2v, mpg, .ts), use
D2V Creator to save the audio. For AVI material, use VirtualDubMod and the STREAMS menu to demux your audio. Once you have an audio file, simply use the Audio Input button to select your audio file.



For the Codec select "ND AAC" if you downloaded the Nero Digital Audio codec.
For the Container select "MP4-AAC"
For the Audio Profile, select NDAAC-HE-MultiChannel-128kbps if you downloaded the Nero files, or LAME MP3 *scratchpad* if you did not download the NeroAAC files.
Click the CONFIG button to configure the selected profile.




Select the options as shown. If your audio file needs a delay correction, then place a check in th Delay correction box. If your audio has a negative ( - ) delay correction then place a check next to the minus (-) sign and input the number of milliseconds to offset your audio.

IMPORTANT: If you decide to encode your audio, ensure it has a different filename than your video output!! You can end up overwriting your video with your audio file. The program does not double check this for you so be warned!

If you want to keep your original audio without re-encoding, you can mux your output as an MKV file instead of an MP4 file. If you choose to do that it is not necessary to choose an audio file at this point.

If your ready to go, click the ENQUEUE button in the Video section, and if you are encoding Audio, click the ENQUEUE button in the Audio section. Now click the QUEUE tab at the top of the Main MEGUI window to see your queued workload.

Click START to begin the encoding process.

When your encode is finished, you must then mux your audio in with your video.

TOOLS -> MUXER -> MP4/MKV Muxer

If you chose to encode your audio to MP4 then you should choose the MP4 Muxer. If you chose to keep the original audio, then choose the MKV muxer.

Select your .MP4 Video file for the Video Input
Select your audio input for the Audio Input section.
If you have an OGG compatible chapter file you can select it here. MP4 files support chapter points. If you want to rip these from a DVD you can use DVD Decryptor and select the 'Chapter Information-OGG' option. I haven't figured out how to automatically extract them from Blue-Ray just yet wink.gif

Last but not least, specify your final Output filename in the Output | Muxed Output section and click the QUEUE button.

After a few minutes you should have a completed file.

Note that you must have an MP4 compatible codec installed like
K-Lite Mega Codec Pack, or the freeware FFDShow to play back these files.

Start Ripping & Have Fun


Comments