AVISynth is a really cool utility, yet it seems
very few people are using it! The reason many haven't started
is probably not because AVISynth is hard to use, but basically
because they downloaded it, double-clicked on each file to try
and get it working only to find that it doesn't seem to do anything!?
So perhaps it may be a good idea if I explained what AVISynth
does and how it can be used!
What can we do with AVISynth?
Lets say you downloaded a weird format video file
and wanted to edit it with VirtualDub or convert it to Mpeg with
Panasonic Mpeg encoder or with some other Mpeg / AVI etc., encoder.
It would normally be impossible to do this because neither VirtualDub
nor Panasonic Mpeg Encoder supports this format. Windows Media
Player, however, is usually able to play just about any file with
no problems. If it cannot play it there will usually be a codec
you can install that will allow Media Player to do so. Well, if
Media Player can play it usually AVISynth will let you open it
in whatever application you need! This even applies to Mpeg-2
files! Yep, that's right! If Media Player can play your Mpeg-2
file then AVISynth will let you open them in almost any video
editing or converting utility!
But that is not all! Before it sends the video to
be opened in VirtualDub (or whatever application you want) it
gives you the option to do all sorts of things to the video! You
can resize it, crop it, sharpen, blend, separate interlaced fields,
delete frames, duplicate frames, add 3:2 pulldown, reweave interlaced
fields, bob deinterlace, convert between YUY2 and RGB and a whole
host of other interesting and useful features!
How does it work?
AVISynth acts as a go-between between your video
file and any video application you wish to use. You install AVISynth
by putting a small .dll program in the Windows System folder.
This is almost like a Windows upgrade, it then intercepts all
files opened that are called something.avs
and then runs them through AVISynth. In turn AVISynth decodes
them using Media Players codec's and sends them to the application
you were opening them with - cool huh!
Basically to do this you need to write a simple
text file saying what file you wish to open (just like making
a .lst file for Mpeg2avi) and rename the text file with an *.avs
extension. Then, when you open this file in VirtualDub or Panasonic
Mpeg Encoder (or whatever application you are using) AVISynth
will take over and covert it for that application.
Don't worry, it may not sound too clear to you right
now, but its not hard and after you have followed my step-by-step
examples you will be able to set it up and open any file in seconds.
So without further delay lets get started.
Lesson 1: DVD to AVI with AVISynth!
Since we are Mpeg-2 obsessed at Digital Digest,
what better than to show you how to open a DVD in VirtualDub.
As you know VirtualDub doesn't support Mpeg-2 and cannot open
or edit Vob files...we will soon change that!
Can you open DVD or Mpeg-2 in Media Player?
As I mentioned, AVISynth can open just about any
file that Media Player can handle. But if you cannot open a Vob
file in Media Player then you will need to install the Ligos and
WinDVD codec's first so Media Player can. This is easy enough
to do:
After you have downloaded and unzipped AVISynth
you should end up with a folder containing the following files:
Cut and paste the first file called avisynth.dll
into your C:\Windows\System folder.
Then double-click on the install.reg
file and the program will be installed. To uninstall it double-click
on the uninstall.reg. To uninstall
you can also delete the avisynth.dll file from your Windows\System
folder but that's up to you.
Cannot find the DLL file?
If you cannot find the avisynth.dll
file then its very likely that windows is hiding it from you.
Windows hides all files that have the DLL extension. in case you
accidentally delete any of them and cause windows to become corrupted!
To view all files you should open windows explorer and
go to:
View > Folder Options...
Hit the View tab button and select the option: Show
all files
This will allow you to see the avisynth.dll file
and place it in the Windows\system folder :). If you are worried
about people accidentally deleting DLL files you can turn the
'hide hidden or system files' option on.
Creating an AVS File
Okay, all the hard work is done! Make a folder on
your main drive (usually C:) and put the Vob file you wish to
open inside it. I have called my folder vobfiles
and the file I'm going to open is called VTS_01_01.Vob.
So open windows notepad (or any text editor) and
type the following into it:
DirectShowSource("C:\vobfiles\VTS_01_01.Vob")
As usual the colours are mine and here to help explain
this line means. The DirectShowSource
is a command that basically means open anything using Media Players
codecs. Then, in brackets and quotation marks, we say what file
we wish to open. In this case I said look for the Vob file in
the folder C:\vobfiles and called
VTS_01_01.Vob.
Save it!
Anyway, save the file as whatever you like but put
the extension. *.avs on it instead
of .txt or .doc
etc. I'm calling my text file movie.avs.
So when I choose Save in notepad I will type the filename
"movie.avs"
make sure you use quotation marks (" ") to force notepad
to save it as avs instead of txt.
Again, it will not work if the text file is called
movie.avs.txt or movie.avs.doc
or something like that.
Opening the File in VirtualDub
Okay, time to open our Vob file. Were are going
to use VirtualDub, but, as I said before almost any program will
open the avs file. Load VirtualDub
and go to:
File > Open
Find the avs file you made:
And this is what you get below - VirtualDub reads
it just like it was an AVI file!
That's right! Has he discovered how much his son
likes apple pie, or has he just learnt about what AVISynth can
do? You decide!
AVISynth doesn't offer the ultimate solution for
DVD conversion. For one thing it cannot handle subtitles or multiangles
directly like Flask Mpeg can. Also, if Media Player cannot open
a Vob file or if it cannot play the sound you will not be able
to get it in VirtualDub either! All in all VirtualDub may not
be as fast or versatile at manipulating Vob files another dedicated
program such as Mpeg2avi because it was designed solely for that
purpose. Nevertheless, have a play and see what you can come up
with :). But don't forget, AVISynth is not just for opening Vob
files it can handle almost any file.
Advanced avs Files
That introduction tells us the basics, but there
is so much more AVISynth can do with these files before
they are given to VirtualDub or whatever application you may want
to open them in. I will not explain every possibility because
that's a mammoth task. Instead, I will explain how to use some
of the basic commands and then you will know how to design your
own better.
Opening ASF and MOV files
Its not an exact science but you can often open
many MOV or ASF files. Both MicroSofts ASF and Apples QuickTime
are generic codecs. This means that different codecs are used
for both ASF and QuickTime files but they are still called ASF
or MOV. What I'm trying to say is you can open some but not others.
To open them you usually need to specify the Framerate. You do
that like this:
If you want to open lots of files so they open as one single
file like making a mpeg2avi .lst file, all you need to do
is add a plus (+) sign and tell it which files to join. For
example, instead of this in out text file:
That would tell AVISynth to open vob files: 01,
02, 03 & 04 as though it were a single file.
Other File Opening Options
DirectShowSource("filename&location").As we have already seen, this command will open just about
any file that Media Player can play. This includes audio files
such as WAV, MP3 etc. For example, you could open just about any
audio file in an audio editing package such as SoundForge even
if SoundForge didn't support that format. Just make an avs text
file like we did before and open it in SoundForge the way you
did VirtualDub. Unfortunately ASF files do not work correctly
and look upside down and ma not have any sound :(.
There is also an experimental Vob opening command called:
VOBVideoSource("filename&location")
But this may or may not work for you so you may
wish to swap DirectShowSource and VOBVideoSource.
AVISynth also offers other AVI opening commands.
The reason for this is because handler may be able to open a certain
file type better or process it faster, or may be supported better
by the application AVISynth is opening it in.
AVISource("filename&location")
AVIFileSource("filename&location")
OpenDMLSource("filename&location")
So between this lot you should be able to open almost anything.
WAVSource("filename&location")
This command is designed for opening wave files.
Video Editing Commands
Once you've decided how you will open the file you can command
AVISynth to do stuff with them beforeit sends them to the application
you wish to open it with. This is very useful if you need to
crop or resize or something like that but the application you
want to open it in doesn't let you. All this crap may sound
a little like we are about to learn a programming language,
but really its just a matter of listing what things you want
done. For example, say we want to open the file but make it
half the size it was originally, we could put:
DirectShowSource("filename&location")
ReduceBy2
That's all we need to do! Save the avs text file as usual and
open it in VirtualDub to see how it looks. You will find that
it opens the video file but at half of its original size!
Okay, lets add to that. Lets say the application you wish to
open the file in prefers the RGB AVI format but your original
file is in YUY2 format we could put:
DirectShowSource("filename&location")
ReduceBy2
ConvertToRGB
This time it will open the file, half its size and change the
format to RGB. Notice also how I have just added this new command
to the last one like a shopping list :). Each command can usually
be just stuck underneath the last and AVISynth will perform
them in that order.
File Command Order
The order in which you ask AVISynth to perform commands can
affect both what the final result looks like and how fast the
option is completed. For example, say we opened a huge 720 x
576 pixel DVD file. We want to sharpen the image and resize
it to 352 x 288 according to a bicubic resize. We could do it
like this:
AVISource("filename&location")
Sharpen(1.0)
BicubicResize(352,240)
But that is a slow way to do it because this way the sharpen
filter comes first in the list. Obviously it takes longer to
sharpen a 720 x 576 image than it takes to sharpen a 352 x 288
image! So instead its better to do it in this order:
AVISource("filename&location")
BicubicResize(352,240)
Sharpen(1.0)
This way the image is shrunk first and then sharpened after.
We can also repeat effects. For example, if you wanted to make
it twice as sharp you could do this:
AVISource("filename&location")
Sharpen(1.0)
Sharpen(1.0)
Note: Not all programs will be able to handle every option
or some repeated sequences of options so its trial and error.
For example, VirtualDub will often crash if you try and feed
it a Vob file with multiple AVISynth alterations added it it.
Frames & Fields
I couldn't finish this article without saying a few words about
AVISynth's Field and Framerate commands. So here are a few that
should help you get started.
Bob
This is one of the easiest ways to solve those NTSC interlace
problems when opening the file in an application that cannot
deinterlace it. You could use:
DirectShowSource("filename&location")
Bob
Simple as that! You may be interested to know that Bob is the
method that PowerDVD uses most often to solve those annoying
interlace combing problems. This will fix all interlaced files
that look corrupted like the following picture:
For more details on interlace problems you could check out
my article on 'NTSC / PAL & Interlace'.
SeparateFields
Another handy little feature that lets you separate the top
and bottom frames of an interlaced picture. If for example you
will be resizing an video file from 576 pixels high to 288 pixels
high or lower an easy way to both speed things up and completely
solve all interlace problems without any loss of detail s literally
to separate fields. This can be done thusly:
DirectShowSource("filename&location")
SeparateFields
This will double the amount of frames in the movie because
its now giving you frame 1 (top field) frame 2 (bottom field).
So a 30fps movie becomes a 60 fps movie. So you may want to
use the SelectEven or SelectOdd commands to fix this. Either
command will select every other frame in the file. So select
odd may just leave you with only bottom or top video fields.
To use it just add SelectOdd to the list, like this:
DirectShowSource("filename&location")
SeparateFields
SelectOdd
This will make the 60 fps back into 30. All these options shouldn't
take very much processing power because AVISynth is only taking
the information from the file in a certain order, it doesn't
need to do heavy calculations on it.
You may be wondering why your movie now looks like a pancake!
This is because it only has half the lines it did originally.
Like I said you intend on resizing the movie anyway and this
solves both interlace problems and cuts down on CPU power because
there is of a picture to resize :). To make the final image
complete we simply use a BilinearResize option like this:
DirectShowSource("filename&location")
SeparateFields
SelectOdd
BilinearResize(384,208)
LEARNING MORE COMMANDS
Want to Learn More about AVISynth commands? Here they all are!
Just click on each one and it will take you to the info found
on the AVISynth's official Webpage: