AviSynth
From Wikipedia, the free encyclopedia
AviSynth | |
---|---|
Developed by | AviSynth developers |
Latest release | 2.5.7 final / January 7, 2007 |
OS | Windows |
Genre | Digital video frameserver |
License | GNU GPL |
Website | http://www.avisynth.org |
AviSynth is a frameserver program for Microsoft Windows developed by Ben Rudiak-Gould, Edwin van Eggelen, Klaus Post, Richard Berg, Ian Brabham and others. It is free software under GNU GPL license.
Contents |
[edit] Scripting video editor
AviSynth acts as a non-linear video editor (without a GUI) controlled entirely by scripting. It stands as an intermediary between a digital video source, like an AVI or MPEG, and a VFW receiving program, which is typically a media player, video editing software, or an encoder.
AviSynth communicates with any program that supports AVIs through the video for windows system by acting as a "fake" AVI file. It can apply a large variety of editing and processing functions (called filters) to a video stream before passing along the results as if it were a legitimate file being read. Filter capabilities include trimming, cropping, deinterlacing, inverse telecine, loading and splicing still images, doing color corrections, denoising, and many other things.
Technically, it acts as a codec for AviSynth scripts, which are text files written in the AviSynth scripting language. The scripting language can be extended through the use of plugins. A plugin list is maintained at AviSynth Filter Collection.
AviSynth filters work in several color spaces including RGB, YUY2 and YV12. This is necessary to allow all kinds of video input and output. Also, certain functions only work on certain color spaces, making conversion mandatory.
For example, say the script "myAvi.avs" (just a plain text-file saved with the extension "avs") contains the following:
AviSource("myAvi.avi") Crop(0, 0, 320, 240) Blur(0.1)
This script file can be opened in most media players (such as Windows Media Player). The program will play the video file "myAvi.avi" trimmed down to precisely 320 pixels by 240 pixels and blurred by a small amount. Operations occur in sequential order, so the Cropping occurs first, then the Blurring.
[edit] AviSynth Scripting Language
The scripting language is a programming language, containing many features familiar to programmers, including variables, distinct datatypes, conditionals, and complex expressions.
The language deals primarily with videos, as a primitive data type. A typical script loads a video as input, applies processing to it, and then "returns" that video in the same way functions return values. The returned video is the output of the script, which is seen as the video by the program running the script.
The language also has several other more standard data types, including int, float, bool and string. These can be used to perform calculations, decisions, and write text such as subtitles to the video.
The processing work is largely done by functions or filters (the two terms are interchangeable). The programmer can pass arguments to one of many built-in functions, and a value may be returned. Also, many functions take a video stream as an argument, and make changes to this stream.
Programmers may be unaware that they are constantly passing video streams into functions, since convention suggests that the video is not explicitly passed. If no video is passed into a function, it simply takes the last video used.
Additional functions/filters are available through plugins. The use of plugins is encouraged to extend the capabilities of AviSynth. (See AviSynth Filter Collection link for a list of plugins).
[edit] "Hello World"
This example is a "Hello World" program - it simply creates a video containing the words "Hello, world!".
BlankClip() Subtitle("Hello, world!")
The BlankClip function is necessary to create a new video, before having a subtitle displayed on top of it. The parentheses at the end of the word are optional, since no arguments are being passed, but are given in this case to indicate it is a function and not a variable.
The Subtitle function draws the words "Hello, world!" on top of the previously-created blank video.
Although the BlankClip and Subtitle functions both accept many more arguments (for example, controlling the size and length of the video, and the positioning, font, and color of the subtitle), this example leaves them out, so AviSynth simply uses its built-in defaults.
If the above text is entered into a .avs file, it can be opened in Windows Media Player or any of the other programs in the list above, and a video containing the text will be displayed.
[edit] Video-processing
This example takes an actual video, applies some simple processing, and returns it to the output.
AviSource("C:\Example.avi") ReduceBy2() GreyScale()
The AviSource function is used to load a video from a real location. The DirectShowSource function could also be used. ReduceBy2 divides the vertical and horizontal size of the video in half, and GreyScale forces the video to greyscale colors.
Again, the above script can be entered into a .avs file and opened in a video player or editor. Assuming C:\Example.avi exists, it will play a copy of that file, except that it will be half the size and greyscale.
[edit] User defined
The AviSynth scripting language allows for users to define their own functions.
This is an example of a function that allows you to dissolve from one clip to another without damaging interlacing lines.
clip1 = AVISource("video1.avi")
clip2 = AVISource("video2.avi")
return interlaced_dissolve(clip1,clip2,30) # dissolve from clip1 to clip2 over 30 frames
function interlaced_dissolve(clip clip1, clip clip2, int iter)
{
clip1 = clip1.SeparateFields()
evn1 = clip1.SelectEven()
odd1 = clip1.SelectOdd()
clip2 = clip2.SeparateFields()
evn2 = clip2.SelectEven()
odd2 = clip2.SelectOdd()
evn = Dissolve(evn1,evn2,iter)
odd = Dissolve(odd1,odd2,iter)
return Interleave(evn,odd).Weave().DoubleWeave.SelectOdd()
}
[edit] AviSynth 3.0 code rewrite
AviSynth 3.0 is a complete rewrite of AviSynth 2.5 and is still in development. It aims at overcoming limitations of AviSynth 2.x and editing and processing videos in a non-linear manner. It is being developed to offer more powerful frameserving capabilities through improvements such as an abstracted color space model, in which new color spaces (including two with 45-bit depth) can be supported through a plug-in mechanism, better cache management for better performance, and a more powerful scripting language. AviSynth 3 will also be available for other operating systems than Windows, and it will rely on GStreamer. Therefore, it will theoretically be compilable on every OS supported by GStreamer, such as Linux, Mac OS X and BSD.
[edit] AviSynth compatible programs
Program name | Comments | Homepage |
---|---|---|
Adobe Premiere | Versions 6.0, 6.5, and Pro have an AviSynth import plugin available. | |
Cinema Craft Encoder | Cinema Craft Encoder is a widely-used[citation needed] MPEG-2 encoder. | |
TMPGEnc {Plus, Express} | TMPGEnc is a free MPEG-1 and MPEG-2 encoder. TMPGEnc Plus and TMPGEnc Express are commercial versions of TMPGEnc that include enhanced functionality, as well as the removal of a 30-day restriction on MPEG-2 encoding present in TMPGEnc. | |
VirtualDub | VirtualDub is a widely-used all-purpose video converter. Although it works well with AviSynth, VirtualDubMod (below) is designed with AviSynth in mind. | VirtualDub |
VirtualDubMod | VirtualDubMod is widely considered to be the best way to interact with AviSynth. It contains several AviSynth-specific features such as explicit support for AviSynth scripts, an AviSynth script editor, and more. | VirtualDubMod |
Windows Media Player | Windows Media Player is capable of loading and playing AviSynth scripts, so it is a good choice for simple playback and testing. | Windows Media Home |
Media Player Classic | Media Player Classic is capable of loading and playing AviSynth scripts. | Media Player Classic |
SUPER | SUPER (Simplified Universal Player, Encoder and Renderer) is freeware from eRightSoft that can encode most common video formats and has full AviSynth support. | SUPER |
In addition, several programs have now been created which accept only AviSynth scripts as input - thereby simplifying the program itself but giving users the full power of AviSynth for input.
Some examples of this type of program are xvid_encraw - which is a command line encoder for the Xvid codec, and x264, which natively comes as a command line encoder. Both accept YV12 (4:2:0) input, and will produce MPEG-4 / MPEG-4 AVC compliant output.
There are also several batch encoding applications that tie together AviSynth with command line audio and video encoders and muxers to provide an all in one modular, customizable video encoding application. MeGUI is an example of this kind of application
Please help improve this section by expanding it. Further information might be found on the talk page or at requests for expansion. |