Avisynth

 

 

Introduction

Avisynth is a very useful utility created by Ben Rudiak-Gould.  It provides many options for joining and filtering videos.  What makes Avisynth unique is the fact that it is not a stand-alone program that produces output files.  Instead, Avisynth acts as the "middle man" between your videos and video applications.

Basically, Avisynth works like this:  First, you create a simple text document with special commands, called a script.  These commands make references to one or more videos and the filters you wish to run on them.  Then, you run a video application, such as VirtualDub, and open the script file.  This is when Avisynth takes action.  It opens the videos you referenced in the script, runs the specified filters, and feeds the output to video application.  The application, however, is not aware that Avisynth is working in the background.  Instead, the application thinks that it is directly opening a filtered AVI file that resides on your hard drive.


What Can Avisynth Do?

There are five main reasons why you would want to use Avisynth:

1)  Join Videos:  Avisynth lets you join together any number of videos, including segmented AVIs.  You can even selectively join certain portions of a video or dub soundtracks.

2)  Filter Videos:  Many video processing filters are built in to Avisynth.  For example, there are filters for resizing, cropping, and sharpening your videos.

3)  Break the 2 GB Barrier:  Avisynth feeds a video to a program rather than letting the program directly open the video itself.  Because of this, you can usually use Avisynth to open files larger than 2 GB in programs that don't natively support files of that size.

4)  Open Unsupported Formats:  Avisynth can open almost any type of video, including MPEGs and certain Quicktime MOVs.  However, when Avisynth feeds video to a program, it looks just like a standard AVI to that program.  This allows you to open certain video formats in programs that normally wouldn't support them.

5)  Save Disk Space:  Avisynth generates the video that it feeds to a program on the fly.  Therefore, no temporary or intermediate videos are created.  Because of this, you save disk space.


Basic Usage of Avisynth

Before you begin, you need to download and install Avisynth as described in my Software page.

As I mentioned in the introduction, Avisynth is invoked and controlled through text files called scripts.  The scripts, which have the extension '.avs', can be created and edited using a program like Windows Notepad.  By inserting certain lines of text into the script file, you can control what Avisynth does.  Here is a short and very basic guide to creating and using Avisynth scripts:

1)  Run Windows Notepad or the text editor of your choice.

2)  To open a single video, insert the following line of text:

DirectShowSource("c:\Path_And_Filename.avi")

Of course, you have to replace "Path_And_Filename.avi" with the actual path and file name of your video.  The DirectShowSource(...) part of the command means that Avisynth will use the DirectShow architecture to open the video.  This is the same thing that Windows Media Player uses to open a video.  Therefore, Avisynth should be able to open almost any type of video that Windows Media Player can open.

3)  To open and join multiple videos, instead add this line of text:

DirectShowSource("c:\Path_And_Filename1.avi")+DirectShowSource("c:\Path_And_Filename2.avi")

Once again, you must replace "Path_And_Filename" with the actual paths and file names of your videos.  If you wish to join 3 video segments, simply add "+DirectShowSource("c:\Path_And_Filename3.avi")" to the same line of text.  You can string together as many videos as you like by adding any number of "+DirectShowSource(...)" commands.

4)  To use a video filter, press enter to create a new line and then add the command for desired filter.  (A complete list of filters is available on the Avisynth home page.)  For example, here is the command you would use to reduce the horizontal and vertical resolutions of a video to half their original sizes:

ReduceBy2

You can run multiple filters on a video by pressing enter to create a new line of text and adding the desired command.  Each filter is executed sequentially.

5)  When you're done adding videos and filters, the text file might look something like this:

DirectShowSource("c:\capture.00.avi")+DirectShowSource("c:\capture.01.avi")
ReduceBy2
Sharpen(0.25)

Note 1:  In the above example, Avisynth first joins capture.00.avi and capture.01.avi.  Then, it shrinks the videos to half their original size in the vertical and horizontal direction.  Finally, it runs a sharpening filter on the videos.  

Note 2:  If I did not want to run any filters, I would have only included the first line.

Now click on File -> Save As, navigate to the desired directory, type in a file name like "avisynth.avs", set the File Type to 'All Files (*.*)', and hit the Save button.  Your Avisynth script should now be saved with the .avs extension in the directory of your choice.  You can close the text editor.

6)  All that remains is to open the *.avs file with your desired video application.  In the Open dialog box of your application, set the file type to *.avi.  For the filename, type in *.* and press enter, which will allow you to see files with the *.avs extension.  Then you can open the file just like you would open any other video.  If it won't accept the *.avs file as a *.avi file, try changing the file type to "All Files (*.*)" instead of *.avi.

At times, however, a program doesn't like the *.avs extension.  In such a case, you might be able to use VirtualDub's AVIFile client in proxy mode to help out.  First you need to install VirtualDub's AVIFile client and the "proxyon.reg" file as described in my Frameserving guide.  Then you can rename the *.avs file to *.avi and try to open it in the program again.  If it still won't open the script, you can try using VFAPI to frameserve your *.avs file to the stubborn program.  Instructions for using VFAPI can be found in my Frameserving guide.


More Information

Avisynth can perform many other functions that are more complicated than the ones I described.  To learn more about Avisynth, its scripting language, and the many different functions it has, head on over to the official Avisynth home page.