All pastes #609219 Raw Edit

Something

public text v1 · immutable
·published 2007-07-08 19:13 UTC
rendered paste body
This guide is intented to replace several of the more outdated tutorials covering this subject, and will hopefully enable you to make great quality x264 encodes to share with us all. The reason I'm writing this for MeGUI, is that it is more powerful than StaxRip, which offers a gentle introduction to the world of x264 encoding, but has ceased development and is pretty limited in general.

With video encoding, there are so many variables and different methods, everyone has their own preferred method, and I offer this one with no claims of it being the best or anything like that. I present this guide aiming to lead you through the basics of x264 encoding, and hope that you will use it as a stepping stone to more complicated methods of encoding once you familiarise yourself with things.

If you have any questions or problems, don't pm me specifically, use the forums, there are many more users able to help, several of them very experienced and knowledgable, so make full use of the great community we have here at x264.eu.


What you will need:
# MeGUI (Use one of the download mirrors at the bottom of the page)
# Microsoft .NET Framework 2.0
# AVI Synth
# DVD Decrypter (alternatives to DVD Decrypter are listed in the DVD Decrypter section below).
# MKVToolnix for MKV muxing only.
# YAMB for mp4 muxing.

# If you are planning to use AAC, you may want to download NeroDigitalAudio.zip (keep following the links to get the download started).

(NB. All images are clickable thumbnails)

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

What to do

DVD Decrypter

Firstly, goto "Tools > Settings" and then navigate to the "IFO Mode" tab, where you should change the "File Splitting" drop down menu option to None as shown below:



Next you need to rip the DVD to your hard drive, so open up DVD Decrypter, select IFO mode (Mode > IFO or press i). You should something similar to this:



Box 1 refers to the drive you are ripping from, only important if you have multiple drives.

Box 2 indicates where the movie is to be ripped to on your hard drive, and below the drive's capacity and free space is indicated. To change the destination folder, click the folder icon and select an appropriate folder, I suggest you make a folder on a drive with plenty of free space and use sensible names for any folders.

The arrow 3 pointing to "VTS_06 - PGC 1 [03:13:59]" indicates the ProGram Chain you are ripping, and the length of it in square brackets. By defualt, DVD Decrypter selects the longest PGC on the disc, in many cases this is the PGC you want, but always check the length of it with the length of the movie in question.

If you have a couple of very long PGCs in the same VTS set you probably have a multiangle or a seamless branching disc. In this case you should be careful to select the correct PGC, and should preview the extracted files before committing to a lengthy encode (eg, you can get the theatrical edition and a director's cut on the same disc).


Once you have everything sorted, click the big button and wait while the DVD is ripped to your hard drive.

Note: If you find the DVD you have won't rip using DVD Decrypter, then you will have to use a different program, DVDFab Decrypter and RipIt4Me are 2 programs capable of handling newer protections DVD Decrypter can't.


MeGUI



When you first run MeGUI, be sure to apply all updates (the program should automatically inform you of any available updates after a few seconds), remembering to import the profiles (will be a popup appear, forgetting to do so is troublesome and a somewhat common mistake) and restarting MeGUI if necessary. When updating, you will probably get a message about the Nero AAC encoder, or lack of, simply ignore future updates for this (right click), and download the NeroDigitalAudio.zip file (link above). If you do download the Nero AAC files, I suggest you extract them to a folder such as "...MeGUItoolsneroaac", and then manually tell MeGUI where the Nero AAC encoder files are (Tools > Settings > Program Paths > neroAacEnc").

Once that's done, you can being the encoding process, firstly you should create a D2V file, so click the link under the "Tools" menu.



You will then get a "DGIndex Project Creator" window as shown above, first click the [...] box (number 1) and select the .vob input file. Next you can either demux all audio tracks (number 2), or select only the one you want, normally you should just extract all streams. Leave the output location alone and hit the "Queue" button (number 3).

The window should auto close (unless you unticked the "and close" box, if so close the window yourself), so now click on the "Queue" tab and hit start, upon doing so DGIndex should start demuxing the files, so just sit tight and wait til it's finished.

Audio Encoding

Now you have demuxed the audio streams, it's time to decide whether you will use the original AC3 audio track, or re-encode it to AAC.

AC3 is the original format and requires no extra encoding or modification in order to use, but is large in comparison to AAC (meaning a smaller video bitrate). AAC results in lower file sizes (allowing for a higher video bitrate for a target filesize) and is much better than MP3. None of the other formats are worth considering, as AAC is much better than MP3, and DTS is stupidly large, and a complete waste of space, Vorbis (AKA OGG) is comparable to AAC, but much less popular.

If you choose to use the original AC3 stream, the proceed directly to the video encoding part further down. If instead you chose AAC, then you have to make a decision on quality and thus filesize of the encoded file. Firstly, select the input AC3 stream (box 1), making sure you get the correct one, the output file should automatically be defined correctly (box 2) so no need to alter that.



Next you need to check the encoder you wish to use, "ND AAC" being Nero Digitals encoder and the suggested one. Then you need to select the audio profile (box 3) and whether you wish to use 5.1 (if available from the source) or 2.0 channels. For 5.1 channels, you should be using "NDAAC-LC-MultiChannel-192Kbps" which will give you comparable quality to the original 5.1 AC3 stream at a smaller filesize, and for 2.0 channels use "NDAAC-LC-96Kbps". If you wish to alter any settings further, then click the "Config" button.

Once you are done click "Enqueue" and start the job going, and then just sit and wait for the encoding process to complete before moving on to the video encoding (unless you aren't aiming for a specific filesize, then you can move on).

If you wish to include a second audio track, say for directors commentary or an alternate language (for a foreign language film, it may be wise to include both the original language and English if available), you can add a second audio encoding job by switching to the second radio button (box 4).


Video Encoding

Onto the all important video encoding section, and I'd again like to emphasise that this guide isn't going to deal with anything more than the basics, as it's an extremely open-ended subject and you could write endless essays on it.


AviSynth Script Generation

Firstly you need to create an AviSynth script, so goto "Tools > AviSynth Script Creator" and you'll get a popup like this:



You should load the .d2v file first, so click box 1 and select the .d2v file you created earlier.

A pop up window with the movie video showing will appear, allowing you to crop the video, so check the box to the left of number 3. You should now proceed to adjust the values in each of the boxes to the right, with the top box for the cropping at the top of the picture, the white area being the cropped region. You should scan through several scenes by moving the slider at the bottom of the preview window to check the cropping is correct, I suggest you pay particular attention to the lighter scenes as it's easier to tell where the black border starts and ends.

Once you have cropped the video, you should decide whether to use anamorphic encoding or not. Anamorphic encoding "stretches" the video, allowing for a higher resolution, for more information please see this webpage for further information about how it works, or carry out a google search. I'd suggest against using anamorphic encoding for 1 CD rips (700meg) as the encode will suffer as a result. If you are using anamorphic encoding, check box 2, which will automatically change the vertical resolution in line with the horizontal one.

If you aren't using anamorphic resolution, you should now select the correct resolution, I suggest you use 640 by the suggested horizontal resolution (tick the box "Suggest Resolution").


Now move to the "Filters" tab (5), which looks like this:



First click button 1, as it will determine the nature of the source, whether it is interlaced, progressive or a hybrid of both. If you are encoding anime video, you should check the box before running the analysis pass.

Ideally you are looking for Progressive, as this requires no further work and can be encoded as it is. For Interlaced, Hybrid or the other options, you should use the deinterlace fitler MeGUI suggests (box 2).

Before you ask me any further questions about interlaced sources, I have little experience with them being in a PAL country and 99% of my DVDs being progressive, so please don't address any such questions at myself specifically, please use the Encoding Questions forum and other more knowledgable users will get back to you.

Next you should choose the resize and noise filters you require (boxes 3 and 4 respectively). Softer resize filters can improve the compressibility of the video but can reduce the quality; sharper filters can do the opposite. Neutral bicubic or lanczos are 2 suggested filters.

Enable denoising (noise filter, box 4) and pick the appropriate level. Denoising reduces noise, which arguably makes the image look better (less flickering), and definitely compresses better (less flickering = lower complexity). You have to just learn what each filter level corresponds to, there's no easy way to explain when to use which for denoising. You should always use at least minimal, as you can't see a difference between minimal and none, and the compressibility improves slightly.

Now click save and the window should close itself.


Profile Selection and Bitrate Calculation

Next you need to select the profile you wish to use for encoding. If you are aiming for a specific filesize upon completion (ie, you wish to have a 1/2 CD rip), you should use one of the HQ profiles, which are designed to hit a desired bitrate (and thus filesize) but are fairly slow (HQ-Insane will result in fairly insane encode times, true to it's name). For constant quality (ie, you don't care about filesize) you should choose one of the CQ profiles.

I use HQ-Slower or HQ-Slowest (depending on the source) as I aim for a specific filesize for each rip, but feel free to change the profile to suit your needs, experiment as to which gives the best results in an acceptable timelimit, as the HQ profiles can take many hours, especially if you haven't got a dual core CPU. For reference, my Athlon X2 3800+ (stock speeds) takes on average maybe 10 hours for an encode using HQ-Slower, the Core2Duo chips will be faster, and a single core will be slower. Don't be surprised if you get an ETA (expected time of arrival, when it will complete each pass) of 20+ hours, it's not a mistake.

A short description of each profile from the creator of them, well worth a read.

Once you have decided upon the profile you wish to use, you should proceed to calculate the bitrate for your encode, "Tool > Bitrate Calculator", which will bring up this popup window:



You should now select the audio stream you are going to use, either the original AC3 or the encoded AAC file (must have finished encoding), so click select in box 1.

Next change the container to MKV in box 2, you can use MP4 if you wish or have specific needs (hardware), but I recommend MKV for the majority of users, and if you are using AC3 you will need to use MKV, as MP4 doesn't properly support AC3 audio streams.

Now you need to decide upon a bitrate for your movie. For those who are aiming for a specific filesize, you should select the desired option from the "Storage Medium" dropdown menu in box 3, with the filesize in MB being displayed in the box above. Pay close attention to the "Average Bitrate" value in box 4, as this will go a large way to determining the quality of your final file. You should ideally choose a filesize that results in a bitrate of above 1000, obviously the higher the better, but everyone has different needs as to the filesize they want, so use the filesize/bitrate that is best for you.

Once you have decided upon that, you should be back at the main MeGUI window, looking something like this:



You should make sure box 1 has the correct container selected, and if you need access to any of the more advanced profile options, you should click config (box 2) and make changes as you wish, but as I've mentioned, this guide covers only the basics so I won't go into these options.

Once you are satisfied everything is ready to go, hit "Enqueue" (box 3) and switch to the Queue tab (box 4) and click "Start" to start encoding.

You should get a popup window like so:



The blue box highlights the approximate encoding time left, but this won't be accurate for a while, and is only for the first pass of the 2 (for HQ profiles). Like previously mentioned, don't be surprised to see long encoding times, that screenshot is from the second pass of a HQ-Slowest encode and is fairly typical for my encodes/system.

You can now either leave MeGUI as it is, or you can send it to the system tray (View > Minimise to Tray), you can get it back by double clicking the small icon which looks like this: or you can bring up the progress window from "View > Show Progress".


Muxing the output files

Once everything has finished encoding, you now need to "mux" the separate video and audio streams together to create one file, initially I suggested using the adaptive muxer within MeGUI, but it doesn't like certain combinations of audio/video formats, so it is better to use one of 2 options depending on the container you are using.

MKV files

First make sure you have downloaded and installed mkvtoolnix (link at the top), now start up the program (mkvmerge GUI) which looks like this:



First you should select the input files you will use, the video and audio streams you have encoded previously, do this by clicking "Add" (box 1) and selecting the files.

Now specify an output filename for your muxed file in box 2. Make sure it isn't the same as any existing files, as you don't want to accidentally overwrite anything.

If you have an x264 video stream (in mkv) and an AAC stream (in MP4), mkvmerge will specify an extension of .mka, which you should change to mkv.

If you are still living in the world of CD backups, or for some other strange reason require the output file split into 700meg files, switch to the "Global" tab (box 1 below):



Check the tickbox "Enable splitting...." (in box 2, upper right corner) and in "...after this size:" (box 3) select 700MB from the drop down menu.

You can now proceed to "Start Muxing" so click the button and wait while mkvmerge muxes your file. Once it's done you should have a single output file, ready for use.

MP4 Files

For MP4 muxing, you will need YAMB (link at the top), which looks like so:



Procedure is similar to above, but with fewer options, so select your input files (box 1) and specify the output filename (box 2), making sure not to overwrite anything.

Then hit "Mux"and wait for your output file to be created.

For anyone wanting to split the output file into CD sized files, you need to first mux and then split the muxed file, you can't do it in one step. If you want to split, switch to the "Splitting and Joining" tab, select your muxed file (box 1), select option "Split by size:" (box 2), make sure it's set to 700MB and click "Split" (box 3).



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

Hopefully this guide will serve as an introduction to x264 encoding using MeGUI, and use this as a stepping stone to more advanced topics like custom quant matrices and so on, but like I've said, such topics won't be covered here.

I will try to add links later for more specific advanced topics, but for now here are 2 useful links:

Doom9.org - The place for all video related discussion.
MeGUI Wiki - A good MeGUI wiki for general reference.

-------------------------------------------------------------------------
More advanced topics

# Custom Quantization Matrices
What is a Quantization Matrix?
If you want to squeeze more quality out of your encodes, you can use a customised quantization matrix (or just quant matrix), which can be tuned depending on the settings you are using. If you are interested as to what a quant matrix actually does, try reading through the link above.

Here are 2 good links to start you off, be sure to read through what each matrix is tuned for and use where appropriate:
Sharktooth's custom matrix
*.mp4 guy's custom matrices

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

Comments and constructive criticism are welcome (please point out any mistakes you spot), but keep posts sensible and on-topic for the benefit of everyone.


This guide was written by mig for x264.eu, and I request that you seek permission from myself and the staff before posting it elsewhere, thanks.