Jump to content

AviSynth

From Wikipedia, the free encyclopedia
AviSynth
Developer(s)AviSynth developers,Doom9community
Initial release19 May 2000;24 years ago(2000-05-19)
Stable release2.6.0 (May 31, 2015;9 years ago(2015-05-31))[±]
Preview release2.6.1 Alpha 1 (May 17, 2016;8 years ago(2016-05-17))[±]
Repository
Written inC++,Assembly
Operating systemWindows,Linux,macOS
Platformx86andx86-64
TypeDigital videoframeserver
LicenseGNU GPL
Websitewww.avisynth.nl

AviSynthis aframeserverprogram forMicrosoft Windows,LinuxandmacOSinitially developed by Ben Rudiak-Gould, Edwin van Eggelen, Klaus Post, Richard Berg and Ian Brabham in May 2000[1]and later picked up and maintained by the open source community which is still active nowadays. It isfree softwarelicensed under theGNU General Public License.

Scripting video editor

[edit]

AviSynth acts as anon-linear video editorcontrolled entirely byscripting(without aGUI).[2]It emulates anAVIvideo file (orWAVaudio file) as seen by theVFWdownstream application, which is typically amedia player,video editing software,or anencoder.[3]

AviSynth is built uponfilters,which are much likeDirectShow filters,but with a differentbinary interface.Filter capabilities includecropping,deinterlacing,inverse telecine,working with stillimages,doing basiccolor grading,reducingvideo noise,and many other things. AviSynth also performs traditionalvideo editingtasks like cutting, trimming and re-sequencing segments.

For example, consider the script "myAvi.avs" (just a plain text-file saved with the extension "avs" )

AviSource( "myAvi.avi" )
Crop(0, 0, 320, 240)
Blur(0.1)

This script file can be opened in most media players (such asWindows Media Player). The program will play the video file "myAvi.avi" cropped down to its top-left 320pixelsby 240 pixels and blurred by a small amount. Operations occur in sequential order, so the cropping occurs first, then the blurring.

Technically, AviSynth constructs afilter graph(likeMicrosoftGraphEditbut with added capabilities),[4]controlled byscriptswritten in theAviSynth scripting language.Its functionality can be extended through the use of third-party filters known asplugins.An external plugin list is maintained atAviSynth Filter Collection.

AviSynth is aframeserver– the calling programrequestsaudio/video frames and the scriptservesthem. The calling program can call frames in any order, allowing it to pause, jump forward or backward etc., just as with a physical file.

AviSynth scripting language

[edit]

The scripting language is adataflowlanguage:[4]aprogramming paradigmthat describes adirected graphof the data flowing between operations. It lacks someprocedural programmingcontrol structures,[5]but it contains many features familiar to programmers, includingvariables,distinctdatatypes,conditionals, and complexexpressions.

The language works primarily with the audio/videoclipas a built-in data type. The clip is a complex structure with many attributes such as width, height and duration.[6]The language also has several other more standard data types:int,float,boolandstring.[7]These can be used to perform calculations, decisions, and write text such assubtitlesto the video.

The script has a singlereturn value,which is the audio and video 'seen' by the program running the script. This is normally the last line of the script, but areturn statementmay be inserted at any point.

"Hello World"

[edit]

This example is a"Hello World" program.

BlankClip()
Subtitle( "Hello, world!" )

If the above text is entered into a text file with the.avs extension, it can be opened inWindows Media Playeror any of the other programs in thelist below,and a video containing the words "Hello, world!" will be displayed.

TheBlankClipfunction creates a new video. 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.

TheSubtitlefunction draws the words "Hello, world!" on top of the previously-created blank video.

Although both functions both accept many more arguments (for example, controlling the size and length of the blank video, and the positioning, font, and color of the subtitle), this example leaves them out; the functions use built-in default arguments.

Avisynth usessyntactic sugarthat makes simple scripts far easier to write: an implicit variable calledLast.Without implicit variables, the above script would have to be written like this:

Last = BlankClip()
Last = Last.Subtitle( "Hello, world!" )
return Last

or like this:

A = BlankClip()
B = A.Subtitle( "Hello, world!" )
return B

Explicit clip variables are normally only used for functions involving more than one clip:

A = BlankClip()
B = A.Subtitle( "Hello, world!" )
return Dissolve(A, B, 30) # 30-frame cross fade

Video-processing

[edit]

This example takes an actual video, applies some simple processing, and returns it to the output.

AviSource( "C:\Example.avi" )
ReduceBy2()
GreyScale()

TheAviSourcefunction is used to load an AVI video from a real location. To open other media types, theDirectShowSourcefunction could be used instead.ReduceBy2divides the vertical and horizontal size of the video in half, andGreyScaleremoves all color information.

AviSynth filters work in manyRGBandYUVcolor spacesto allow all kinds of video input and output.[8]Certain functions only work on specificcolor spaces,requiring conversion – for example, most videos are distributed in aYUVcolor space, but mostcolor correctionis done in one of theRGBspaces. A color-correcting script might look like this:

DirectShowSource( "movie.mp4" ) # YV12 color space
ConvertToRGB32
RGBAdjust(1.0, 0.95, 1.0) # decrease Green channel
ConvertToYV12

User defined

[edit]

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" )

# call the user-defined function which is defined below:
interlaced_dissolve(clip1, clip2, 30)
#...the script returns the above result to the calling program

# user-defined function:
# 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)
Interleave(evn, odd).Weave.DoubleWeave.SelectOdd
#...the function returns the above result to the main script
}

AviSynth 3.0 and AviSynth+

[edit]

AviSynth 3.0 was acomplete rewriteof AviSynth 2.x, and aimed to overcome the limitations of AviSynth 2.x. Adding improvements such as an abstractedcolor spacemodel, in which new color spaces (including two with 45-bit depth) could be supported through a plug-in mechanism, better cache management for better performance, and usingRubyrather than the homegrown language employed in current versions.[9]

AviSynth 3.0 was to be available for other operating systems thanWindows,instead relying onGStreamer,extending support to platforms such asLinux,Mac OS XandBSD.Development has been stalled since August 2007.[9][10]

AviSynth+is a fork of the official AviSynth 2.xx, introducing long-sought features such as64-bit support,multithreading,deep color spaces,support for recent compilers, new scripting constructs (new control-flow constructs such as loops), and increased performance in many areas.[11]At the same time it retained 100% compatibility to the AviSynth 2.5/2.6 series, both for filters and host applications. At the time of writing (2023-06), it is also actively maintained.

AviSynth for non-Windows operating systems

[edit]

AviSynth 2.xx may be used under operating systems other than Windows through the use ofWine.To work on scriptsVirtualDub/VirtualDubModcan be used as on Windows. To interface between AviSynth under Wine and for exampleFFmpegrunning on a Linux host,Avs2YUVcan be used. Avs2YUV is aWindowscommand line program that is run under Wine and renders the output of an AviSynth script tostdoutthat is then piped to FFmpeg. Avs2YUV also supports writing to anamed pipe.[12]

There is a Linux port of AviSynth called AvxSynth.[13]

AviSynth compatible programs

[edit]
Program name License Comments Homepage
Adobe Premiere Pro Proprietary, commercial Versions 6.0 and later (up to and including CS4) have an AviSynth import plugin available. Premiere AviSynth import plugin
Avanti GUI Proprietary, freeware Avanti GUI is a free front-end forFFmpegwith the option to insert AviSynth as pre-processor. Avanti GUI
AvsPmod GPL AvsPmod is AviSynth script editor with builtin player, syntax highlighting and code autocompletion. AvsPmod
Cinema Craft Encoder Proprietary Cinema Craft Encoder is a commercial MPEG-2 encoder that supports AviSynth input. Cinema Craft
FFmpeg LGPL2.1+, GPL 2+ FFmpeg compiled for windows can receive AviSynth input instructions
GOM Player Proprietary, freeware, ad-supported can play.avs files
Media Player Classic GPL Media Player Classic is capable of loading and playing AviSynth scripts. The 32-bit version is needed. Media Player Classic
Microsoft Expression Encoder Proprietary, freemium Microsoft Expression Encoder can import and transcode.avs files.
MPlayer GPL MPlayer can play.avs files
Nero Multimedia Suite Proprietary, commercial Nero Showtime can play avs files
SUPER Proprietary, freeware, ad-supported SUPER (Simplified Universal Player, Encoder and Renderer) isfreewarefrom eRightSoft that can encode most common video formats and has full AviSynth support. SUPER
TMPGEnc Shareware/freeware TMPGEncis afreeMPEG-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. Pegasys Inc.
Total video converter Proprietary, trialware Total video converter has an AviSynth import plugin available. Total Video Converter
VirtualDub GPL VirtualDubis a widely used all-purpose video converter. VirtualDub
VirtualDubMod GPL VirtualDubModcontains several AviSynth-specific features such as explicit support for AviSynth scripts, an AviSynth script editor, and more. However, it has not been updated since 2006 and contains many bugs.[14] VirtualDubMod
Windows Media Player Proprietary, component of Windows / freeware Windows Media Player is capable of loading and playing AviSynth scripts, so it is a good choice for simple playback and testing. It may require some registry tweaks to get it working. Windows Media Home

In addition, several programs have now been created which acceptonlyAviSynth scripts as input - thereby simplifying the programs themselves but giving users the full power of AviSynth for input.

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.MeGUIis an example of this kind of application.

Although AviSynth scripts are meant to be easily opened in simple text editing programs, there are several editors meant especially for editing AviSynth scripts such asAvsPMod.

See also

[edit]

References

[edit]
  1. ^"Avisynth Copyright".AviSynth Mediawiki.AviSynth Team.Retrieved11 September2015.
  2. ^"Main Page - Avisynth".AviSynth Mediawiki.AviSynth Team.Retrieved10 April2013.
  3. ^"More about AviSynth - Avisynth".AviSynth Wiki.AviSynth Team.Retrieved10 April2013.
  4. ^ab"The Script Execution Model: The Filter Graph".AviSynth Wiki.AviSynth Team.Retrieved25 October2019.
  5. ^"AviSynth syntax: control structures".AviSynth Wiki.Avisynth Team.RetrievedSep 21,2014.
  6. ^"Clip Properties".AviSynth Wiki.Avisynth Team.RetrievedOct 27,2019.
  7. ^"Script Variables".AviSynth Wiki.Avisynth Team.RetrievedSep 14,2017.
  8. ^"Convert - Avisynth".AviSynth Wiki.AviSynth Team.Retrieved27 October2019.
  9. ^ab"Avisynth 3 - dead project?".Doom9 Forum.Retrieved2009-06-17.
  10. ^"AviSynth v3".AviSynth Mediawiki.Retrieved22 September2019.
  11. ^"AviSynth+".AviSynth Mediawiki.Retrieved22 September2019.
  12. ^"Avs2YUV".Akuvian.org.Retrieved2011-01-09.
  13. ^"avxsynth/avxsynth: Linux Port of Avisynth".GitHub.Retrieved2017-09-16.
  14. ^"SourceForge.net: VirtualDubMod: Bugs".Retrieved2009-12-03.
[edit]