Encode AHD

download Encode AHD

of 22

Embed Size (px)

Transcript of Encode AHD

  • 8/3/2019 Encode AHD


    AHD Internals Present: How to Encode.

    Last update: 7 September 2011

    Programs: The tools of the trade.

    AnyDVD HD| You can easily find a copy on Demonoid, get the latest version to keep up with changes in


    A decrypting tool for Blu-ray discs, as well as HD-DVD.


    eac3to is a powerful demuxing tool for Blu-ray discs and HD-DVDs. It allows a user to extract chapters,

    video streams, audio streams, and subtitle streams. It can also demux high definition audio, particularly

    TrueHD, into individual wavs for transcoding with other tools, such as DTS-HD Master Audio Suite. A tool

    that every encoder needs.

    Haali Media Splitter

    Used for splitting matroska files into individual streams for ffdshow to decode. Also used by eac3to to

    mux to matroska.

    eac3to Arcsoft decoder

    Only version offers bit-perfect decoding of ALL DTS-HD tracks, including 6.1 DTS-ES.

    has problems with DTS-ES 6.1. These Arcsoft decoders for eac3to will allow you to perform bit-perfect

    decoding of audio tracks - a must. Install with the instructions included in the archive.

    DTS-HD Master Audio Suite| You can easily find a copy on Demonoid.

    DTS-HD MAS is the professional tool used by studios to transcode DTS audio and is therefore the best

    choice for encoding DTS audio at home. It can encode both regular DTS and DTS-HD MA, as well as all

    other forms.

    Oggenc2.87 using aoTuVb6.03

    Extract and put oggenc2.exein the eac3to folder. This will allow you to encode Ogg Vorbis audio. We are

    placing it in the eac3to folder because that will later be added into our PATH variable.


    A powerful tool for creating and editing AviSynth scripts (.avs). Also used for taking proper screenshots of

    encodes and making comparisons between source and encode as well as between two different



    The most full featured GUI for video encoding, contains many different tools and their GUIs - most

    importantly, x264.

    ffdshow tryouts

    The most popular video decoder for encoding, supports AVC, VC-1, and MPEG-2 among others. Not the

    fastest, but is of high quality. If ffdshow does not become your default DirectShowSource decoder,

    useWin7DSFilterTweakerto make it so; it should be straight forward.


    This will allow you to use FFVideoSource. Grab the 32-bit version, which is the second download.

    DGDecNV| Look for: DGDecNV.v2.0.2.8.x86-CRD

  • 8/3/2019 Encode AHD


    DGDecNV is a frame-server for AVC/VC-1/MPEG-2 and indexer - comes with a powerful deinterlacer

    and is faster than using DirectShowSource/ffdshow. Requires a compatible nVidia GPU.


    Used for performing IVTC.


    mkvtoolnix is a package of tools for the container matroska. Most important is the tool, mkvmerge, which

    allows you to mux multiple video, audio, and subtitles streams into one container - chapter support too!

    Comes with a GUI for simple use, as well as a header editor for, well, editing headers (data like titles and


    Adobe Audition| Non-essential.

    Rarely used, the only time you will need this is if you need to cut audio and mkvmerge splitting won't do it

    right (ex. Lord of the Rings and other multi-disc titles).

    1. Ripping your retail disc: Because retail discs are the


    Confirm that AnyDVDHD has removed all protection from the disc. Most important is the removal of

    AACS. However, region coding is a good thing to remove as well. Seeherefor an explanation from

    Wikipedia andherefor a color coded map of regions.

    We will use AnyDVDHD itself to rip the disc. Right click the tray icon and go to Rip Video DVD to


    Ensure the source and destination are correct and begin to rip the disc.

    2. Demux the source: Oh hey look, this info is valid for

    remuxers too!

    Notice: In step one, I used a retail copy of The Dark Knight. In the rest of the guide, I am using a

    downloaded BD.

    The following steps will be using eac3to's command line interface (CLI)

  • 8/3/2019 Encode AHD


    We will begin by adding the path to eac3to to our PATH environment variable usingthese directions.

    Also make sure you have installed the Arcsoft eac3to decodersfrom above.

    Now fire up your command prompt. First, we will ensure everything has been installed properly for eac3to.

    In command prompt, type:

    eac3to -test

    What you want to check for is that eac3to reports ArcSoft DTS Decoder ( works fine and Haali

    Matroska Muxer {version release date} is installed.

    Now that we have verified that eac3to and it's dependencies are installed and working properly, we can

    move on. You should create a directory where you will store all the files. For this guide, we will create a

    folder on our E: drive. Our folder path will be

    E:\Encoding\Mr and Mrs Smith

    Change drives in command prompt by typing


    Now change the current working directory by typing

    cd "E:\Encoding\Mr and Mrs Smith"

    Quick Tip: You can drag and drop a folder from Windows Explorer into command prompt to have

    the full path inserted for you - no typing long paths! Use the up and down arrows to go back and

    forth between previously used commands.

    Now we are ready to begin with eac3to commands. We will begin by analyzing the BD. The syntax is

    eac3to "full/path/to/bd"

    so for this example, we will type

    eac3to "E:\Mr and Mrs Smith 2005 Blu-ray 1080p AVC DTSHDMA 5.1-TTG"

    and eac3to will return with some output that will look similar to this:

    1) 00800.mpls, 00800.m2ts, 2:00:00

    - Chapters, 28 chapters

    - h264/AVC, 1080p24 /1.001 (16:9)

    - DTS Master Audio, English, multi-channel, 48kHz

    - AC3, Portuguese, multi-channel, 48kHz

    - AC3, Spanish, multi-channel, 48kHz

    - AC3, Chinese, multi-channel, 48kHz

    - AC3, Thai, multi-channel, 48kHz

    - AC3, English, stereo, 48kHz

    - AC3, English, stereo, 48kHz

  • 8/3/2019 Encode AHD


    - AC3, English, stereo, 48kHz

    Some Blu-ray discs will have more than one playlist appear, however, this particular BD has only one

    main playlist, and we will select this by using this command:

    eac3to "E:\Mr and Mrs Smith 2005 Blu-ray 1080p AVC DTSHDMA 5.1-TTG" 1)

    and eac3to will output:

    M2TS, 1 video track, 8 audio tracks, 20 subtitle tracks,

    2:00:00, 24p /1.001

    1: Chapters, 28 chapters

    2: h264/AVC, 1080p24 /1.001 (16:9)

    3: DTS Master Audio, English, 5.1 channels, 24 bits, 48kHz(core: DTS, 5.1 channels, 24 bits, 1509kbps, 48kHz)

    4: AC3, Portuguese, 5.1 channels, 448kbps, 48kHz

    5: AC3, Spanish, 5.1 channels, 448kbps, 48kHz, dialnorm:


    6: AC3, Chinese, 5.1 channels, 448kbps, 48kHz

    7: AC3, Thai, 5.1 channels, 448kbps, 48kHz

    8: AC3, English, 2.0 channels, 224kbps, 48kHz, dialnorm:


    9: AC3, English, 2.0 channels, 224kbps, 48kHz, dialnorm:


    10: AC3, English, 2.0 channels, 224kbps, 48kHz, dialnorm:


    11: Subtitle (PGS), English

    12: Subtitle (PGS), Portuguese

    13: Subtitle (PGS), Spanish

    14: Subtitle (PGS), Modern Greek

    15: Subtitle (PGS), Chinese

    16: Subtitle (PGS), Icelandic

    17: Subtitle (PGS), Hebrew18: Subtitle (PGS), Portuguese

    19: Subtitle (PGS), Indonesian

    20: Subtitle (PGS), Korean

    21: Subtitle (PGS), Chinese

    22: Subtitle (PGS), Thai

    23: Subtitle (PGS), Chinese

    24: Subtitle (PGS), Chinese

    25: Subtitle (PGS), Chinese

    26: Subtitle (PGS), Chinese

    27: Subtitle (PGS), Korean

  • 8/3/2019 Encode AHD


    28: Subtitle (PGS), Korean

    29: Subtitle (PGS), Chinese

    30: Subtitle (PGS), Chinese

    We will want to extract the chapters, video stream, main audio stream, commentary tracks, and

    subtitles of our choosing(we will just use English and Spanish in this example). Our command will be:

    eac3to "E:\Mr and Mrs Smith 2005 Blu-ray 1080p AVC DTSHDMA 5.1-TTG" 1) 1:"Mr and Mrs Smith -

    Chapters.txt" 2:source.mkv 3:HDaudio.dtshd 3:dtscore.dts -core 8:commentary1.ac3 9:commentary2.ac3

    10:commentary3.ac3 11:English.sup 13:Spanish.sup

    This will create a chapter file in .txt format, a source.mkv for our video track, DTS-HD MA audio track, the core

    from the DTS-HD track, all three commentary tracks, as well as the English and Spanish SUP (PGS)

    files. When dealing with spaces in filenames, you MUST use quotation marks ("). The file extension for

    DTS-HD MA is .dtshdOR .dtsma. Use the -coreswitch to extract the DTS core from the HD audio. If dealing

    with a TrueHD audio track, the file extension is .thd(if you extract the embedded core as well with .thd+ac3

    extension, understand thatmkvmerge will strip the embedded trackfrom the audio. You should extract the

    embedded track separately and include it if you are remuxing). For encodes to feature DTS audio, you should

    extract TrueHD audio to multiple wavs using

    eac3to /path/to/bd 1) 3:lossless.wavs

    and thenencode a DTS streamusing the DTS-HD Master Audio Suite.

    For more on eac3to, check out theofficial how to use page, and below is a l ist of common extensions.

    AVC (Raw Stream) | .h264

    VC-1 (Raw Stream) | .vc1

    MPEG-2 (Raw Stream) | .m2v

    AVC/VC-1/MPEG-2 | .mkv

    DTS-HD MA | .dtshd OR .dtsma

    DTS | .dts

    TrueHD (MLP only) | .thd

    TrueHD (and embedded AC-3) | .thd+ac3

    AC-3 | .ac3

    LPCM | .pcm OR .lpcm OR .wav

    FLAC | .flac

    Single Channel WAVS | .wavs

    Chapter file | .txt

    PGS Subtitle | .sup

  • 8/3/2019 Encode AHD


    SRT Subtitle | .srt

    ASS/SSA Subtitle | .ass/.ssa

    If you want to encode your commentary track to Ogg Vorbis, extract the commentary to wav using

    eac3to commentary.ac3 commentary.wav

    and then converting the wav to ogg by using

    oggenc2 commentary.wav -q 1.0 -o commentary.ogg

    If you want to convert these PGS (.sup) subtitle files to a text based format like SubRip (.srt), seethis

    guide. Be sure to check out the other subtitle articles in the Wiki for more conversions between different


    This is how my command prompt looks after completing all the steps:

    Microsoft Windows [Version 6.1.7600]

    Copyright (c) 2009 Microsoft Corporation. All rights



    E:\>cd "E:\Encoding\Mr and Mrs Smith"

    E:\Encoding\Mr and Mrs Smith>eac3to "E:\Mr and Mrs Smith

    2005 Blu-ray 1080p AVC

    DTSHDMA 5.1-TTG"

    1) 00800.mpls, 00800.m2ts, 2:00:00

    - Chapters, 28 chapters

    - h264/AVC, 1080p24 /1.001 (16:9)- DTS Master Audio, English, multi-channel, 48kHz

    - AC3, Portuguese, multi-channel, 48kHz

    - AC3, Spanish, multi-channel, 48kHz

    - AC3, Chinese, multi-channel, 48kHz

    - AC3, Thai, multi-channel, 48kHz

    - AC3, English, stereo, 48kHz

    - AC3, English, stereo, 48kHz

    - AC3, English, stereo, 48kHz

  • 8/3/2019 Encode AHD


    E:\Encoding\Mr and Mrs Smith>eac3to "E:\Mr and Mrs Smith

    2005 Blu-ray 1080p AVC

    DTSHDMA 5.1-TTG" 1)

    M2TS, 1 video track, 8 audio tracks, 20 subtitle tracks,

    2:00:00, 24p /1.001

    1: Chapters, 28 chapters

    2: h264/AVC, 1080p24 /1.001 (16:9)

    3: DTS Master Audio, English, 5.1 channels, 24 bits, 48kHz

    (core: DTS, 5.1 channels, 24 bits, 1509kbps, 48kHz)

    4: AC3, Portuguese, 5.1 channels, 448kbps, 48kHz

    5: AC3, Spanish, 5.1 channels, 448kbps, 48kHz, dialnorm:


    6: AC3, Chinese, 5.1 channels, 448kbps, 48kHz

    7: AC3, Thai, 5.1 channels, 448kbps, 48kHz

    8: AC3, English, 2.0 channels, 224kbps, 48kHz, dialnorm:-27dB

    9: AC3, English, 2.0 channels, 224kbps, 48kHz, dialnorm:


    10: AC3, English, 2.0 channels, 224kbps, 48kHz, dialnorm:


    11: Subtitle (PGS), English

    12: Subtitle (PGS), Portuguese

    13: Subtitle (PGS), Spanish

    14: Subtitle (PGS), Modern Greek

    15: Subtitle (PGS), Chinese

    16: Subtitle (PGS), Icelandic

    17: Subtitle (PGS), Hebrew

    18: Subtitle (PGS), Portuguese

    19: Subtitle (PGS), Indonesian

    20: Subtitle (PGS), Korean

    21: Subtitle (PGS), Chinese

    22: Subtitle (PGS), Thai

    23: Subtitle (PGS), Chinese

    24: Subtitle (PGS), Chinese25: Subtitle (PGS), Chinese

    26: Subtitle (PGS), Chinese

    27: Subtitle (PGS), Korean

    28: Subtitle (PGS), Korean

    29: Subtitle (PGS), Chinese

    30: Subtitle (PGS), Chinese

    E:\Encoding\Mr and Mrs Smith>eac3to "E:\Mr and Mrs Smith

    2005 Blu-ray 1080p AVC

  • 8/3/2019 Encode AHD


    DTSHDMA 5.1-TTG" 1) 1:"Mr and Mrs Smith - Chapters.txt"

    2:source.mkv 3:HDaudio.d

    tshd 3:dts.dts -core 8:commentary1.ac3

    9:commentary2.ac3 10:commentary3.ac3 11:E

    nglish.sup 13:Spanish.sup

    M2TS, 1 video track, 8 audio tracks, 20 subtitle tracks,

    2:00:00, 24p /1.001

    1: Chapters, 28 chapters

    2: h264/AVC, 1080p24 /1.001 (16:9)

    3: DTS Master Audio, English, 5.1 channels, 24 bits, 48kHz

    (core: DTS, 5.1 channels, 24 bits, 1509kbps, 48kHz)

    4: AC3, Portuguese, 5.1 channels, 448kbps, 48kHz

    5: AC3, Spanish, 5.1 channels, 448kbps, 48kHz, dialnorm:


    6: AC3, Chinese, 5.1 channels, 448kbps, 48kHz7: AC3, Thai, 5.1 channels, 448kbps, 48kHz

    8: AC3, English, 2.0 channels, 224kbps, 48kHz, dialnorm:


    9: AC3, English, 2.0 channels, 224kbps, 48kHz, dialnorm:


    10: AC3, English, 2.0 channels, 224kbps, 48kHz, dialnorm:


    11: Subtitle (PGS), English

    12: Subtitle (PGS), Portuguese

    13: Subtitle (PGS), Spanish

    14: Subtitle (PGS), Modern Greek

    15: Subtitle (PGS), Chinese

    16: Subtitle (PGS), Icelandic

    17: Subtitle (PGS), Hebrew

    18: Subtitle (PGS), Portuguese

    19: Subtitle (PGS), Indonesian

    20: Subtitle (PGS), Korean

    21: Subtitle (PGS), Chinese

    22: Subtitle (PGS), Thai23: Subtitle (PGS), Chinese

    24: Subtitle (PGS), Chinese

    25: Subtitle (PGS), Chinese

    26: Subtitle (PGS), Chinese

    27: Subtitle (PGS), Korean

    28: Subtitle (PGS), Korean

    29: Subtitle (PGS), Chinese

    30: Subtitle (PGS), Chinese

    Creating file "Mr and Mrs Smith - Chapters.txt"...

    v02 Extracting video track number 2...

  • 8/3/2019 Encode AHD


    a09 Extracting audio track number 9...

    s13 Extracting subtitle track number 13...

    a08 Extracting audio track number 8...

    a03 Extracting audio track number 3...

    s11 Extracting subtitle track number 11...

    a10 Extracting audio track number 10...

    a03 Extracting audio track number 3...

    a03 Extracting DTS core...

    v02 Muxing video to Matroska...

    a10 Removing AC3 dialog normalization...

    a08 Removing AC3 dialog normalization...

    a09 Removing AC3 dialog normalization...

    a03 Creating file "HDaudio.dtshd"...

    a03 Creating file "dts.dts"...

    a08 Creating file "commentary1.ac3"...a10 Creating file "commentary3.ac3"...

    a09 Creating file "commentary2.ac3"...

    s11 Creating file "English.sup"...

    s13 Creating file "Spanish.sup"...

    Added fps value (24 /1.001) to MKV header.

    Video track 2 contains 172616 frames.

    Subtitle track 11 contains 946 captions.

    Subtitle track 13 contains 867 normal and 13 forced


    eac3to processing took 42 minutes, 13 seconds.


    E:\Encoding\Mr and Mrs Smith>

    3. Preparing your AviSynth script... and so it begins.

    Below are three (3) options for loading your source file. Choose anyone (1).

    The instructions below are using DirectShowSource.

    Open up AvsPmod. Drag and drop your source.mkv to create the first line. By default, it will read


    Delete the last parentheses and append:

    , fps=23.976, convertfps=true).AssumeFPS(24000,1001)

    so that the first line reads something like

  • 8/3/2019 Encode AHD


    DirectShowSource("E:\Encoding\Mr and Mrs Smith\source.mkv", fps=23.976,


    substituting 23.976 for the framerate of your source if not 23.976, and 24000,1001 as well - other

    common framerates are 24.000 and 25.000. In AssumeFPS, the first number is the numerator and the

    last is the denominator, 24000/1001 is approximately equal to 23.976. For 24 and 25 fps source material,

    simply use 24 or 25 as the numerator and 1 as the denominator.

    The instructions below are using ffvideosource.

    Open up AvsPmod. Drag and drop your source.mkv to create the first line. By default, it will read


    Change DirectShowSource to FFVideoSource and press F5 to refresh. It will appear that AvsPmod

    has frozen, THIS IS NORMAL, this is when your source mkv is being indexed. It will take a good while to

    index, depending on the source.

    The instructions below are using DGSource.

    Launch DGIndexNV. Drag and drop your source mkv onto the program window. Choose to crop if a

    window appears saying that the source stream specifies cropping. Go to File > Save Projector hit F4.

    Open up AvsPmod. Drag and drop your newly created .dgi f ile to create the first l ine. By default, it will



    Change DirectShowSource to DGSource.

    The following instructions apply to all methods.

    Deinterlacing wrote:

    If you are dealing with one of those rare interlaced BDs (or not so rare if a BBC production), you will need to

    perform deinterlacing within your AviSynth script, so that your encode is progressive. Seethis linkto read about

    interlace dectection and methods of deinterlacing. Underneath the following spoiler is a deinterlacing guide

    written by Donald A. Graft. Note that those instructions are not dependent on the usage of AviSource(). You

    will need to download the appropriate fil ters for this guide (those mentioned).

    Decomb Plugin for Avisynth

    (Version 5.2.3)


  • 8/3/2019 Encode AHD


    by Donald A. Graft

    Table of Contents



    Step 1. Determine and Set the Field Order

    Step 2. Set up Pattern Guidance If Appropriate

    Step 3. Set up Postprocessing


    Step 4. Setting Up Decimation



    This document is a tutorial for Decomb. It provides a cookbook procedure for applying Telecide() and

    Decimate() correctly to process a given clip. It doesn't cover FieldDeinterlace() as that is fairly easy to figure out

    from the Decomb Reference Manual.

    Please refer to the accompanying Decomb Reference Manual for a detailed description of Decomb and it



    Telecide() recovers progressive frames (by finding and aligning matching fields). Do not use Telecide() on

    streams that do not contain telecined progressive frames, such as pure interlaced video.

    Step 1. Determine and Set the Field Order

    It is essential to set the field order properly for correct rendering. The field order is obtained from Avisynth and

    can be set using the AssumeTFF() or AssumeBFF() functions in your script before invoking Telecide(). Set

    AssumeTFF() for top field first; use AssumeBFF() for bottom field f irst. Because setting it correctly is so

    important, you are strongly encouraged not to make assumptions about the field order of a clip, but rather to

    verify the field order using the following procedure.

    To determine the field order, make an Avisynth script that serves the raw clip without any processing. If it were

    an AVI, then just AviSource() would be used. For our examples, we'll use AviSource(). Add a script line to

    separate the fields using top field first, as follows:



  • 8/3/2019 Encode AHD


    Now serve the script into VirtualDub and find an area with motion. Single step forward through the motion. Note

    whether the motion progresses always forward as it should, or whether it jumps back and forth as it proceeds.

    For example, if the field order is wrong, an object moving steadily from left to right would move right, then jump

    back left a little, then move right again, etc. If the field order is correct, it moves steadily to the right.

    If the motion is correct with AssumeTFF().SeparateFields(), then your field order is top field first and you must

    use AssumeTFF(). If the motion is incorrect, then your field order is bottom field first and you must use

    AssumeBFF(). If you want to double check things, you can use AssumeBFF.SeparateFields() to check correct

    operation for bottom field first.

    Let's assume we have a top field first clip in the following steps. You would of course use the correct field order

    for your clip. So far, then, our script is as follows:




    Step 2. Set up Pattern Guidance If Appropriate

    Often you know from the nature of a clip what telecining pattern (if any) is used and therefore what the pattern

    of field matches should be. Telecide()'s pattern guidance feature uses that information to improve the field

    matching. Pattern guidance is controlled by the optional guide parameter. It has 4 possible values: guide=0

    means disable pattern guidance; guide=1 means use 3:2 pulldown guidance (24fps->30fps); guide=2 means

    use 2:2 guidance (PAL); and guide=3 means use 3:2:3:2:2 guidance (25fps->30fps).

    First decide if your source clip is PAL. If it is, and if it has progressive content, you can almost invariably set

    guide=2 to use PAL pattern guidance. Of course, if your clip does not have progressive content, it will not help

    you, and you shouldn't be using Telecide() at all! So for PAL, we can skip to Step 3 with our script looking this

    so far:




    If we have an NTSC 29.97fps or 30fps source clip, things are trickier. First we have to determine whether the

    clip contains 3:2 pulldown material. There are several tests we can apply. First, serve the clip raw (no Decomb

    or other processing) into VirtualDub. Then step through the frames in motion areas. If you see a repeating

    pattern of 3 clean frames followed by 2 interlaced frames, that is 3:2 pulldown. Typically, movies will use 3:2


    Looking for the 3:2 pattern as described above is not foolproof, because for animations there are duplicate

    frames that can make it hard to see a clear 3:2 pattern.

    Second, you can serve the following script into VirtualDub and see what Telecide() reports about i t (remember

  • 8/3/2019 Encode AHD


    to use the correct field order as you determined it above).




    Serve this into VirtualDub and step through several typical sections of your clip. If Telecide() reports "in-pattern",

    or "in-pattern*", then it is locking onto 3:2 pulldown. If it reports "out-of-pattern" or continuously jumps in and out

    of pattern lock, then it is not locking onto a consistent 3:2 pattern.

    If you determine that your clip has a lot of 3:2 content, then you should go ahead and set guide=1. If there is not

    a lot of 3:2 content, or you have any doubts about the nature of the clip, then you should set guide=0. We will

    assume that we have a lot of 3:2 content for the next steps. Therefore, our script so far looks like this:




    Step 3. Set up Postprocessing

    Postprocessing is the process by which frames that come out of the field matching process still combed can be

    detected and deinterlaced. The postprocessing modes are controlled by the post parameter: post=0 means

    disable postprocessing; post=1 means calculate the metrics but don't deinterlace; post=2 means calculate the

    metrics and deinterlace accordingly; and post=3 means calculate the metrics, deinterlace accordingly, and

    show a deinterlacing motion map for frames that are detected as combed. There are two more advanced

    modes as well; please refer to the reference manual for details.

    We will adopt a standard procedure for setting up postprocessing. First, we will enable the metrics and show

    them as follows (note we are carrying forward previously determined settings -- you would use the ones you

    earlier determined for order and guide):




    Serve this into VirtualDub and play through the clip while examining frames and the displayed vmetric values.

    The value that applies to the frame as matched is the one in brackets that starts with "chosen=", e.g.,

    "[chosen=27]". Let's just call that the vmetric value. Any vmetric value greater than vthresh defines the frame as

    interlaced. You want to find the vthresh value that correctly distinguishes combed frames from non-combed

    frames for your clip. You'll easily be able to identify the frames thought to be combed because a) the vmetric

    value will be greater than vthresh, b) the progressive/interlaced indicator will say interlaced, and c) the frame

    will have a white deinterlacing motion map overlayed on it. There's no way you'll miss them!

    Your chosen vthresh may not be perfect and if it is not you should err on the side of caution. It's better to catch

  • 8/3/2019 Encode AHD


    some progressive frames than to miss some combed ones.

    Let's suppose that our vthresh value that distinguishes combed from non-combed frames is 30. Now create the

    following script with post=2 (carry over your determined previous settings, as always):




    Serve this and play it into VirtualDub. As you step through you should see the progressive frames passing

    through untouched while the combed ones ones are deinterlaced.

    If you are not happy with the deinterlacing of the combed frames and want them "hit a l ittle harder", you can

    reduce the dthresh parameter. Also, if you prefer interpolation to blending for the combed areas, you can

    change the blend parameter. Refer to the reference manual for the proper use of these parameters.

    Our script so far then is:




    There are two more important things to say about postprocessing before we move on. First, there is a subtle

    difference between post=2 and post=4 which might affect you. The reference manual describes the differences

    in detail. Setting post=2 will often avoid making gross frame blends at scene changes, but i t can make

    deinterlaced video sequences jerky. Setting post=4 retains the smoothness of deinterlaced sequences, but

    may make frame blends at scene changes.

    Second, you may find that you need different vthresh values for different parts of your clip. If so, use Telecide's

    manual override capability to specify values for different frame ranges as needed. Refer to the reference

    manual for details.


    As a side effect of performing field matching for 3:2 pulldown, Telecide() emits duplicate frames and leaves the

    clip at its original frame rate. Decimate() detects and removes these duplicates and sets the frame rate down


    Step 4. Set up Decimation

    If your clip is PAL, you do not require decimation and you are finished!

    If your clip has 3:2 pulldown, you will need to decimate the clip. Simply add a call to Decimate(). Our final script

    then looks like this:

  • 8/3/2019 Encode AHD






    One thing to be aware of is that you may not always want to decimate 30fps material. For example, if your clip

    is a hybrid of 3:2 progressive and normal interlaced video, if you decimate it you'll make the video portions jerky.

    Often with such clips it is better to leave them at their original frame rate by omitting Decimate().


    This manual has described only the basic parameters and procedures required to quickly master Decomb.

    There are many more parameters that you can use to adapt to unusual and difficult situations. Please refer to

    the Decomb Reference manual to begin exploring this additional functionality.

    Here is one example of a refinement so you'll understand what I am talking about: Suppose you have a noisy

    off-air capture and you are experiencing matching failures. You can add some extra noise tolerance to

    Telecide() by increasing the value of the nt parameter. You will find many such little gems in the Reference

    Manual. It makes great bathtub reading.

    If you are using DGDecNV, you can use the function deinterlace=1 to enable single rate deinterlacing

    or deinterlace=2to enable double rate deinterlacing. If dealing with an HDTV stream in a TS container (as they

    always come in TS unless remuxed), you will be using single rate deinterlacing in nearly ALL cases. You will

    also need to perform IVTC once you have deinterlaced with DGDecNV, but only if the FPS is 29.97 (IVTC is not

    necessary for sources such as 1080i50, where the native framerate is 25p but was encoded as 1080i50 for

    Blu-ray compatibility). Do this by adding TFM().TDecimate. as a new line, before any crop, resize, or other

    processing. Your script may look like

    DGSource("E:\Encoding\HDTV\source.dgi", deinterlace=1)


    Crop(0, 140, -0, -140)

    Spline36Resize(1280, 534)

    and result in a final FPS of 23.976 (audio will still sync because during playback, your player performs all these

    steps behind the scenes).

    Now we are going to crop the video if necessary. Cropping removes the black borders found on Blu-ray

    discs and HDTV transport streams to preserve aspect ratio. If your video is truly full 16:9, then skip this

    step. Otherwise, continue reading. Cropping is made very easy in AvsPmod. Go to Tools > Crop Editor.

    Adjust the values for cropping until all black bars have been removed. You should skip around scenes to

    find a relatively bright frame so that you can see the black bars well defined. Should you overcrop, any

    part of the frame that is lost will become inverted in color. Only crop vertically OR horizontally - doing both

  • 8/3/2019 Encode AHD


    will cause media players to stretch the picture when being displayed on an HDTV. If there are one or two

    black pixels on the left or right of the picture and you have already cropped vertically (same applies if

    cropping vertically leaves one pixel of black - you should always crop in multiples of two to maintain

    mod2), you can use theFillMargins filterto fill it in. So now the second line of your script should look

    something like this:

    Crop(0, 140, -0, -140)

    FillMargins wrote:

    Extract the files to the plug-in directory of AviSynth (C:\Program Files (x86)\AviSynth

    2.5\plugins OR C:\Program Files\AviSynth 2.5\plugins | x64 and x86, respectively).

    Syntax: FillMargins(left, top, right, bottom)

    Please add FillMargins command after cropping and resizing.

    Example script:

    DirectShowSource("E:\Encoding\Mr and Mrs Smith\source.mkv", fps=23.976,


    Crop(0, 140, -0, -140)

    Spline36Resize(1280, 534)


    We will now resize the video, if we are encoding 720p. Go to Tools > Resize Calculator.... Adjust the

    slider until the horizontal resolution is 1280 (if you cropped vertically) or until the vertical resolution is 720

    (if you cropped horizontally). Click apply and AvsPmodshould append a third line to your script that looks

    something like:

    Spline36Resize(1280, 534)

    There are multiple resize filters that you can choose from, readthisfor more info.

    Spline36Resize wrote:

    Spline36Resize(1908, 800, 6, 140, -6, -140)

    is the same as:

    Crop(6, 140, -6, -140)


    Your script should now read similar to this (assuming no deinterlacing):

  • 8/3/2019 Encode AHD


    Using DirectShowSource wrote:

    DirectShowSource("E:\Encoding\Mr and Mrs Smith\source.mkv", fps=23.976,


    Crop(0, 140, -0, -140)

    Spline36Resize(1280, 534)

    Using FFVideoSource wrote:

    FFVideoSource("E:\Encoding\Mr and Mrs Smith\source.mkv")

    Crop(0, 140, -0, -140)

    Spline36Resize(1280, 534)

    Using DGSource wrote:

    DGSource("E:\Encoding\Mr and Mrs Smith\source.dgi")

    Crop(0, 140, -0, -140)

    Spline36Resize(1280, 534)

    Go to File > Save Scriptor CTRL+S to save your new Avisynth script - save it in your encoding folder.

    More on AviSynthinternal filtersandexternal filters(external links).

    4. Testing and the final encode: The meat and potatoes.

    To perform a test encode, you will need to append the following l ine to the end of your script:


    This will select 24 frames from every 1440 frames to encode, which should give you a good

    representation of the entire source, so that you can see how x264 wil l behave in dif ferent scenes. This

    also happens to be 1 second for every 1 minute of footage, meaning that the final size of your test will be

    1/60 of the final size of the encode (good way to estimate final size when using the CRF method of

    encoding). You can choose to use more or less than 24 frames, depending on the length of your source.

    selectrangeevery wrote:

    Syntax: SelectRangeEvery(clip clip [, int every] [, int length] [, int offset] [, bool audio])

    SelectRangeEvery(1440,24,2400)will select 24 frames from every 1440 frames beginning at frame 2400.

  • 8/3/2019 Encode AHD


    Open up MeGUI, we will first adjust MeGUI settings. Go to Options > SettingsOR Ctrl+S, and in

    the Maintab, set Default PrioritytoLow (it does not make the encoding process any faster by setting to

    very high). In the Extra configtab, in the Auto Updatesection, choose Use development update

    server and check Always backup files when needed (development update server will keep you with

    the latest version of each tool - I have personally not run into any issues related to using the development

    server, but if using the stable server gives you peace of mind, go ahead). In the External Program

    Settings, check X264: enable 64 bit mode if you have a 64 bit OS and CPU.

    In the Inputtab of MeGUI, under Video Encoding, browse to your Avisynth script, from here on referred to

    as "encode.avs", and open. A video preview window will open up, go ahead and close it - it is a helpful

    reminder if you have left OSD on in ffdshow however. In the output section, set your output filename to

    something like "Mr and Mrs Smith 720p TEST 1", where you can easily recognize what is what. Obviously,

    change the number at the end with each test, so that you don't overwrite previous tests.

    Set Encoding Settingsto x264: *scratchpad*and click config.

    For a full list of options, what they do, how they behave, and what our recommendations are, seehere. To learn

    about reading the x264 stats output, seethis.

    Recommended starting settings for testing:

    Live Action wrote:

    x264 --level 4.1 --pass 2 --bitrate 10000 --stats ".stats" --deblock -3:-3 --min-keyint 24 --bframes 16 --b-adapt 2

    --ref 4 --qpmin 10 --qpmax 51 --vbv-bufsize 30000 --vbv-maxrate 38000 --qcomp 0.7 --rc-lookahead 60

    --aq-mode 2 --aq-strength 0.75 --merange 64 --me umh --direct auto --subme 10 --trellis 2 --output "output"


    2D/3D Animation wrote:

    x264 --level 4.1 --crf 16 --min-keyint 24 --bframes 16 --b-adapt 2 --ref 4 --qpmin 10 --qpmax 51 --vbv-bufsize

    30000 --vbv-maxrate 38000 --qcomp 0.7 --rc-lookahead 60 --aq-strength 0.6 --merange 64 --me umh --direct

    auto --subme 9 --trellis 0 --output "output" "input"

    Settings to play with (seesettings glossaryfor more information):

  • 8/3/2019 Encode AHD








    --me (only raise from umh to esa or tesa, NEVER LOWER)

    --rc-lookahead (only INCREASE)

    Achieving AHD Gold + DXVA status requires the following:

    AHD Gold

    CABAC = 1

    ref = 4 (ref=9 if 720p) | Can be different and still achieve AHD Gold if compliant with DXVA rules

    analyse = 0x3:0x113 (for DXVA compliance - disable P4x4 macroblocks) or 0x3:0x133 (not DXVA)

    subme = 7 or higher (internal standards require 9 or 10, generally 9 only if trellis is disabled; see trellis.

    subme=11 is new and if you have the CPU for it, go for it.)

    me_range = 16 or higher (internal standards have it as usually me_range=64, although it can vary from

    me_range=24 to me_range256 depending on the me algorithm used (64+ with umh, 48+ with esa, 32+

    with tesa, 24+ if with testing it proves to be fine with tesa)

    trellis = 1 or 2, or deadzone is 10,10 or lower (always use trellis=2, unless dealing with animation, in

    which case you can either leave trellis=2 or set trellis=0 and adjust deadzones to 10 on both inter and

    intra levels; try 8;6)

    bframes = 3 (Raise --bframes until the last percent is below 5% for the most significant compression. In

    this example, use --bframes 7).

    x264 [info]: consecutive B-frames: 0.8% 1.4% 7.2% 23.0% 19.4% 43.4% 3.6% 1.3%

    rc = 2_passes or crf (final bitrate should not exceed 65% of the source bitrate for 1080p (75% absolute

    hard max, if dealing with an especially compressed or grainy source), and no more than 40% for 720p

    unless absolutely necessary)


    analyse = 0x3:0x113 | Like previously stated, disable P4x4 macroblocks.

    720p encodes:

    ref= 09 (max. resolution = 1280x728)

    ref= 10 (max. resolution = 1280x654)

    ref= 11 (max. resolution = 1280x594)

  • 8/3/2019 Encode AHD


    ref= 12 (max. resolution = 1280x546)

    1080p encodes:

    ref= 4 (max. resolution = 1920x1092)

    ref= 5 (max. resolution = 1920x872)

    ref= 6 (max. resolution = 1920x728)

    Remember: The goal of encoding is to preserve as much detail as efficiently as

    possible, i.e. attaining transparency without an excess of bits.

    When you have found the settings that work best, delete the line that starts with selectrangeevery() from

    your AviSynth script and save. Reload the script in MeGUI to ensure that it was saved properly, and

    begin your final encode. Make sure your final file name does not overwrite your source! Ensure that

    there is enough disk space for the encode to complete!

    5. Take comparison screens: Transparency is the name of

    the game.

    Open up AvsPmodagain. Have your encoding script open and then open up a new tab using CTRL+N.

    Drag and drop your finished encode onto the new tab. Edit to ffvideosource if you encoded using

    ffvideosource or DGSource. If you are using DirectShowSource, be sure the append the additional

    commands like in the original script. If you used DirectShowSource, and in turn, ffdshow, go to video

    decoder configuration in the ffdshow folder in your start menu > OSD > check Current

    frameand Frame type(as well as OSD) > and Apply. You may adjust the horizontal and vertical

    position if you wish for the OSD to appear on the source screens if you had to crop. OSD on source

    screens are not necessary.

    OSD with ffvideosource requires that you append this line to the end of your script:

    ffinfo(cfrtime=false, vfrtime=false)

  • 8/3/2019 Encode AHD


    If for some reason your encode is either 1 frame more or less than the source when you load it in

    AvsPmod, you can use the Trimcommand to shave off a frame from either the source script or the

    encode script. The Trim command is


    and keep in mind that there IS a frame 0.

    Use the slider to jump around the video and to look for a frame that will be a good indication of overall

    quality. Try to find frames with faces as well as frames with a large background. When framecounts

    match in AvsPmod, using the scroll wheel on your mouse will flip between the two scripts and

    frames. Right Click > Save image as... and select a save destination.

    6. Muxing: We can rebuild him, we have the technology.

    Fire up mkvmerge GUI. Go to File > Options. Under mmg, check Disable header removal

    compression for audio and video tracks by default. IMPORTANT! - By removing header removal

    compression, you are increasing playback capabilities on certain hardware players. For any

    picture based subtitle tracks, i.e. PGS (SUP) or VobSub (IDX/VOB), you must disable compression for

    each track manually.

    Drag and drop your encode.mkv, audio tracks, and subtitles into the input filessetion of mkvmerge.

    Go Tracks, chapters, and tagsand highlight the first track. Under General track options, set language (to

    whatever is correct), set default to yes (for the main audio track if you have commentaries - set

    commentary to default NO), and DO NOT force any tracks. If no track is set to be the default track

    then mkvmerge will promote the first track of each type that it finds to be the default track.

    In the Global Tab, load your chapter file.

    Now set an ouput filename and select a location and start muxing.

    Last edited byDeadlybart356[PM]2 months, 4 weeks ago

  • 8/3/2019 Encode AHD


    Educate yourself.Remote Remuxing|Encoding

    Contribute.Updated!Join decibeL.| Coming soon... | Simply seed, seed, seed.

    Don't PM for reseed or invites.