Moderators: Admin Staff, Mod Staff

Stream Extraction Guide - Work in Progress Topic

Stream Extraction Guide - Work in Progress Topic

Postby AGF-Antoine » Mon Aug 29, 2011 3:18 am

This is my Work in Progress Topic for the first new guide I will write, the Stream Extraction Guide. For now I am working on making a list of needed programs and codecs.

Click here to go to the download page.
AviSynth is the main program for using any kind of stream without losing any quality, or lossless as its called usually. It will be the base for the extraction of all the video and audio types I will describe. The main focus of the guide is video ofcourse, since the main goal for the guide is being able to extract video streams for usage in AMV's.

AviSynth is a very advanced video editing program that works with scripts, due to this it might seem hard to use it.
But knowing some of the basic codings of it already helps a lot.
This guide will start with the most basic functions, more specifically, how to open video files in VirtualDub by using Avisynth as the medium.
For starters, scripts can be made with the basic tool WordPad or any other text editor.
It is important to change the extension of those text files to ".avs" which is the file extension for AviSynth.

The first subjects I will be talking about are the harder ones, which are MP4 and MKV. The first step of these are different from each other. But the final step is the same for both and actually almost the same for all video formats.

After doing the extracting of the stream you can open it with another script, there scripts can be opened in VirtualDub and VirtualDubMod, but also in the Adobe programs with a special plugin. Opening them in Adobe is not adviced since it makes the program really slow and it tends to crash alot as well. The best way is to open them in VirtualDub or VirtualDubMod and saving clips in the lossless format Lagarith or Huffyuv, keep in mind this is a huge fileformat, so you should make them as short as possible.

MP4 Stream Extraction:

Click here to go to the download page.
Yamb is the tool that is needed for extracting MP4 streams. Yamb is a GUI, so its pretty easy to use.

Make sure you select MP4Box as well during the installation of Yamb.
If you don't select this, then Yamb will not be able to open .MP4 files.

After installing Yamb you will be able to open the program from your Start Menu.

To extract streams from MP4-files you need to click on "Editing" and then doubleclick on "Click to extract streams from AVI/MP4/MOV/TS files."
In the next menu you will be able to browse for the video file you wish to extract the videostream from.

After you have opened the MP4-file in Yamb you will get a list of the streams present in the MP4-file.
Make sure you select "Extract to Raw Format." in the Options parts, since that gives you the video stream without doing anything to it.

Most of the time the video format in MP4-files is h264 which is shown as an "AVC" file in the program.

MKV Stream Extraction:

Click here to go to the download page.

Click here to go to the download page.
MKVtoolnix and MKVExtractGUI are the tools that are needed for extracting MKV streams.
Both of these need to be combined to get a proper GUI interface for MKV extraction, which makes using it about as easy as using Yamb, mentioned in the MP4 part.

Now to combine the 2 files.
Its quite simple, you need to copy paste the MKVtoolnix files into the MKVExtractGUI directory and it should work.
You can open the program now with "MKVextractGUI.exe".
It doesn't require installing, since it just works standalone.

Now lets get to how you use the program:
Click on the "..." button in the "Input"
Most of the time the video format in MKV-files is h264 which is shown as "V_MPEG4/ISO/AVC" track in the program.
Select the video stream in the stream list and after that click on "Extract".

After this is saved you will have the raw video track from the MKV-file.

After the extraction there comes another step:

Click here to go to the download page.
This program is used to index the raw videostream of x264 and thus make a file AviSynth can read.

Before you can continu further you need to make sure "DGAVCDecode.dll" is present in the same folder as the footage you want to open.
The reason for this is the specifically needed Avisynth script.

The script for this is the following:


Ofcourse you need to replace FILENAME.dga with the .dga file that Yamb made for you.
This script also needs to be present in the same folder as the footage.
After you have saved this file you can open the video in VirtualDub.
Make sure the textfile is saved and closed before trying to open it in VirtualDub.
Otherwise it won't be able to open it because it's in use.

Alternatively you could try DGAVCDecDI, but I have still to try this program myself.
Click here to go to the download page.

After processing:

Click here to go to the download page.

Alternatively you could try VirtualDubMod:
Click here to go to the download page.
It essentially offers the same options, but slightly differently named.
Both VirtualDub and VirtualDubMod can be used for opening the scripts from AviSynth. Photoshop is able to directly open the scripts with a plugin. But programs like Sony Vegas can only open video files, so for those you need to reincode them to a file format they can open. For these there are the lossless codecs Lagarith and Huffyuv. I personally use Lagarith since its slightly better, but there are known problems with using Lagarith on Microsoft Windows Vista and 7.

For the guide I will be using VirtualDub since its more stable to use.

VirtualDub will be able to open AviSynth scripts after AviSynth is installed.
It will recognize .avs-files as video-files, so they can be opened like a regular video.

So to open video's and scripts, click on "File" and then on "Open video file..." in the dropdown menu.

After opening the video-file or AviSynth script, you should first change some stuff about the saved file.
First things first, be sure to select Full Processing Mode when your goal is making Lagarith clips.
Click on "Video" and then on "Compression...", this will take you to the codec options.
If you have installed the Lagarith codec, it should be on the list of codec options as "Lagarith lossless codec".

The next step is important if you wish to save some HD-space.
Click on Audio and then on "No audio" in the dropdown menu.
If you do this then the clips will only contain the video, saving the space audio would take.
When you load an AviSynth script made with the video stream extraction way, this step isn't really needed.
Since it already is just a video stream, without audio. But I still select "No audio" to just be sure.

After doing this we can get around to creating the clip itself.
You can move through the video file with either the directional arrows or clicking on the timeline with the mouse cursor.
The clicking on the timeline is great to get to the part of the video the clip is at.
With the directional arrows you go frame by frame.
Keep in mind it might need a little loading due to video being very heavy to work with, especially for older PC's like my own.

Now to select the clip itself.
For the first frame of the clip you click on "Edit" and then on "Set selection start" on the dropdown menu.
For the last frame of the clip you click on "Edit" and then on "Set selection end" on the dropdown menu.
And there it is, your Lagarith clip is ready to be saved.
To do so, click on "File" and then on "Save as AVI..." on the dropdown menu.
Be sure to make multiple small clips instead of 1 big one with footage in it that you don't need.
Since Lagarith is a huge format, you don't want to waste useless HD space nor extra strain on your PC when editing with them.

Be sure to check the clip after saving it, since there can always occur encoding errors.
If you get such error, you can just try to save the file again and repeat the checking of the clip.


Click here to go to the download page.
Lagarith is a lossless video codec, it's best to save clips you make in this format and also make a save of a completed AMV to have it in max quality.
You should have alot of free HD space, since its takes up a lot of HD space.
To install the Lagarith codec rightclick on "lagarith.inf" and click on "Install".
After you've done this it should appear in the codec options of programs like VirtualDub, Sony Vegas and Adobe Premiere.

Note to self: Take into account the colorspace used, If not done correctly, you could "still" lose quality, due to the implicit colorspace conversion. (Thanks Lexica-chan).

Click here to go to the download page.

Click here to go to the download page.
Its important to use WMV9 VCM instead of the other WMV9 codecs, since the other ones tend to leave a small yellow line on a side of the video.

The following script can be made in AviSynth:


Real Alternative:
Click here to go to the download page.
The following script can be made in AviSynth:


QuickTime Alternative:
Click here to go to the download page.
The following script can be made in AviSynth:


Click here to go to the download page.
The following script can be made in AviSynth:


The following script can be made in AviSynth:


While making this simple script allows opening .wmv videos in VirtualDub, there is a known issue with it.
It doesnt allow you to select the start and ending of clips exactly usually.
If that happens, its best to either do the entire video in Lagarith first.
After that open the Lagarith save of the entire video in VirtualDub, but change the save way to Direct stream copy.
This is done in "Video" and then selecting "Direct stream copy" in the dropdown menu.

Notes to self:
Note to self: Should also add extracting audio streams + Audacity stuff <--- WAV, FLAC, AAC, AC3, APE etc handling?

Note to self: OGG / OGM, MP3
User avatar
AnimeGirls Fan
AnimeGirls Fan
Posts: 1695
Joined: Mon Jul 10, 2006 7:27 am
Location: The World of AnimeGirls

Return to Guides

Who is online

Users browsing this forum: No registered users and 1 guest