Fanedit Forums

Full Version: Captain Khajiit's Basic Guide to Decoding Video and Audio
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6 7
1) Introduction

This guide will tell you what you need to know (and only what you need to know) about decoding video and audio; it will tell you nothing whatsoever about processing them.  It was written for faneditors; consequently, much that other videophiles might wish to know has been purposely omitted.  

N.B.  The guide will assume that you know the difference between progressive and interlaced video.  If you do not know, search the forums or google it.  It will also assume that you have ripped your disc successfully with DVDFab or AnyDVD.

Tools hosts many tools.  It is a safe place from which to download and always keeps its links up to date, so it should be your first port of call.


I always use a 32-bit workflow because the 32-bit versions of tools are usually more up to date, but you can use a 64-bit workflow if you like.  N.B.  You must use like with like i.e. you cannot use the 32-bit version of AviSynth with the 64-bit of DGIndexNV (and vice versa).  If in doubt, keep everything 32-bit and you will not go wrong.

Before you start, you need to learn how to make a basic AviSynth script.  Install the latest version of AviSynth.  Open Notepad. File→Save As... MyScript.avs – do not forget to add .avs to the end.  

Then type your script.



N.B. Remember to use both inverted commas and brackets whatever your source. ("")
2) Demuxing

To demux is to separate video and audio.  You need only two tools to demux: PGCDemux for DVDs and eac3to for BDs and HD DVDs.


Start the program. Click Browse next to Input IFO and try opening each IFO of your ripped DVD in turn until you find the one that gives a runtime that matches your movie.

[Image: pgc.png]

Mode: by PGC
Domain: Titles
Demux video stream: checked
Demux audio streams: checked

Check anything else you want. Fill out your output folder. Process. The result will be an .m2v video file and at least one audio track.


N.B. Make sure that you have the Haali Media Splitter installed first.

I suggest you use the HD DVD/Blu-Ray Stream Extractor GUI, which should have been included in your eac3to download.  If not, you can find it here.  Run it.

[Image: eac3to.png]

  1. Browse for your input folder.
  2. Click Features.
  3. Double-click on the playlist that matches the runtime of your movie.
  4. Check the streams that you want to demux, and choose the output format for each stream.  (The picture above is just an example.  Advice on what to choose follows.)
  5. Fill out your output folder.
  6. Hit Extract.

N.B. With eac3to, you can probably demux and decode your audio in one step.  See section 4.
3) Video

There are three main video codecs that the faneditor might encounter: AVC, VC-1 and MPEG-2. All three are found on Blu-rays and HD DVDs. Detailed information about them is beyond the scope of this guide, but a very brief introduction to each follows.

AVC is also called h.264. The popular encoder x264 uses this codec, so you have probably used it already.

VC-1 was developed by Microsoft. It is part of the WMV family of codecs that are commonly used online.

MPEG-2 needs little introduction because it is the oldest of the three. It is used for DVDs and sometimes for HD content.
3a)  DGIndexNV

The best tool for decoding is DGIndexNV because it can decode all three formats well.  It uses CUDA, so you need an NVIDIA card.  If you have one, you should seriously consider purchasing it.  Please note that you can occasionally encounter glitches with all decoders, no matter how good, but DGIndexNV rarely goes wrong because it is updated regularly.  Good support is available from its author, Donald Graft, aka neuron2, via his forum.

Installation instructions are available on neuron2's website, and the tool comes with a detailed user manual, which you are advised to read; but here are brief notes on how to get started.

  1. Install the program.
  2. Make a “donation” via the website.
  3. Find your machine ID by running the program, going to Help → About DGIndexNV and looking under Donald Graft's name.
  4. Plug your login (user) and machine ID into the license generator to receive a license.
  5. Open Notepad, copy your license in, and save as license.txt in your DGIndexNV project folder.  N.B.  You must use the American spelling of license and not the British/Commonwealth spelling.

You can demux your video to MKV or an elementary stream because DGIndexNV handles both.

File→Save project as...
Input a filename.
Save as type:  DGIndexNV project file (*.dgi)
Hit Save.

Make an AviSynth script.


Open your script in VirtualDub to preview it.  Job done!

If you do not have an NVIDIA card, there are other ways to decode video, but they are not quite as simple.
3b) Decoding AVC with DGAVCDecDI

If you do not have an NVIDIA card, consider investing in DGAVCDecDI, which is also by neuron2. The procedure for installing it is very similar to the one outlined above for DGIndexNV. In fact, you can use the same license. DGAVCDecDI uses DiAVC, so you will need to purchase a separate license for that from schweinsz. Follow the installation instructions for DiAVC very closely.

The good thing is that DGAVCDecDI will decode both progressive and interlaced AVC. You can demux your video to MKV or an elementary stream because DGAVCDecDI handles both. Once it is installed, you follow the same procedure as for DGIndexNV, but your script looks like this.

LoadPlugin("...\DGAVCDecodeDI.dll ")
DGSource("wherever\whatever .dgi")
Open your script in VirtualDub to preview it.
3c) Decoding progressive AVC with FFMpegSource2()

N.B.  L-SMASH-Works is now a better solution than FFMS2().  I'm leaving this section of the guide here because the former uses the latter to decode (and as a fall-back for those who cannot get L-SMASH to work).  Unless you have a particular reason for favoring FFMS2() , proceed to section 3d.

Make sure that you have demuxed your video to MKV (not an elementary stream) with eac3to.  Download the latest version of ffms2.  Inside the folder, you find will find the ffms2.dll and FFMS2.avsi.  Copy both to your AviSynth plugins directory.  Make sure that you have the Haali Media Splitter installed.  Use the following script, adjusting it to fit your directory structure.

Loadplugin("C:\Program Files (x86)\Haali\MatroskaSplitter\avss.dll")
FFmpegSource2(wherever\whatever.mkv", threads=1, seekmode=0)
Assumefps(24000,1001)# assumes a 23.976fps source

FFMS2 is frame accurate, but it occasionally gets the frame-rate wrong.  The last line corrects it.  It assumes a 23.976fps source, which your source probably is if it is progressive AVC.  You might have a rare, pure-24fps BD, in which case use Assumefps(24,1).

Open your script in VirtualDub to preview it.

N.B.  FFMS2() works by making an index.  Sometimes this takes a while, so be patient.
3d) Decoding progressive and interlaced AVC with L-SMASH-Works

L-SMASH-Works can be used to decode progressive AVC and is semi-consistent for interlaced AVC (for which there is no reliable free solution).  Go here and follow the download link, which leads to a Dropbox page.  Obviously, every now and then, there will be updates, and the look of the screenshot below will change a bit; just stick to the latest builds, and you will be fine.As usual, I recommend that you stick to a 32-bit workflow.  Download the L-SMASH-Works package, which is the first of the two entries outlined in red in my screenshot. Unzip the folder. Inside, you will find an AviSynth folder, in which are a number of .dll files.  Copy all apart from LSMASHSource.dll to your AviSynth plugins folder.

[Image: tamuhzL.pnghttp:]

Now, download the statically compiled version of LSMASHSource(), which is the second of the two entries marked in red.  Inside, you will find the version of LSMASHSource.dll that you can copy to your AviSynth plugins folder; however, I recommend that you load it manually.  (See below.)

N.B. You still need to obtain FFMS2(), because L-SMASH uses it for decoding; however, you should not need Haali.  See section 3c for details on how to obtain FFMS2().  You will almost certainly need to install Visual C++ Runtime Libraries 2015 (and possibly 2013 too).


LSMASHVideoSource() is for formats such as mp4, mov and 3GGP. I recommend that you load the plugin manually rather than relying on it to auto-load.  Then load the video as normal.

LoadPlugin("C:\Program Files (x86)\AviSynth\plugins\LSMASHSource.dll")
LSMASHVideoSource("Wherever\Whatever.mp4", threads=1)


LWLibavVideoSource() supports other containers e.g. MKV.

LoadPlugin("C:\Program Files (x86)\AviSynth\plugins\LSMASHSource.dll")
LWLibavVideoSource("Wherever\Whatever.mkv", threads=1)

N.B.  L-SMASH works by making an index.  Sometimes this takes a while, so be patient.  It's not unusual for VirtualDub to throw a Nor Responding error for a while during the creation of the index. Navigate away from it, give it some time, and check back after a few minutes. You should find your video ready and waiting for you when you do.
3e) Decoding VC-1 with the MS WMV DMO Decoder

The MS WMV DMO decoder handles both progressive and interlaced VC-1.

Demux your video to MKV with eac3to.  Install LAV Filters.  Install GraphStudio and run it.

1.(a) Go to Graph → Insert Filter...  (b) Make sure DirectShow Filters are selected, scroll down to Lav Splitter Source and press Insert.  A new menu will pop up.  © Hit Browse and find and select your MKV.  Hit Open and then OK.

[Image: 9lg8rk.png]

2. (a)  Use the drop-down menu in the top-left to change DirectShow Filters to DMO Video Decoder.  (b)  Select WMVideo Decoder DMO and hit Insert.  Close the menu.

[Image: 2d2eqkg.png]

3.  You will see that two boxes have appeared.  

[Image: 2sb4vpc.png]

Move the cursor to the first box, left-click on it, drag the green arrow that appears onto the second box, and release it.  The green arrow should remain to indicate a connection, and the boxes should change color.

[Image: 2j0mi5g.png]

Go to File → Save as Graph (.GRF)...  Choose your file-name.  Save as type:  GraphEdit Files.  Hit Save.

Make an AviSynth script pointing to your graph.  The one below assumes a 23.976fps source.

DirectShowSource("wherever\whatever.grf", fps=23.976, audio=false)

The last line is present only because I do not like the value that DirectShow gives to 23.976fps: 2500000/104271.  I correct it to 24000/1001.

Open your script in VirtualDub to preview it.
3f)  Decoding MPEG-2 with DGIndex

MPEG-2 is old technology.  DGIndex does a good job with SD and HD MPEG-2.

Install DGIndex. Look in your DGIndex directory, find DGDecode.dll, and copy it to your AviSynth plugins directory.

Open your file in DGIndex. File→Open
Video→Field Operation→Honor Pulldown Flags
File→Save Project→Save as Type: DGIndex Project File (*.d2v)

Type the following, adjusting it to fit your directory structure.


Open your script in VirtualDub to preview it.  See the FAQ of my HCenc guide to know where to go from here.
Pages: 1 2 3 4 5 6 7