316
Avisynth 2.5 Selected External Plugin Reference Wilbert Dijkhof

Avisynth 2.5 Selected External Plugin Reference · Table of Contents 7 AviSynth FAQ − Loading clips (video, audio and images) into AviSynth 7.1.3 What are the advantages and disadvantages

  • Upload
    others

  • View
    5

  • Download
    3

Embed Size (px)

Citation preview

  • Avisynth 2.5 Selected External Plugin ReferenceWilbert Dijkhof

  • Table of Contents1 Avisynth 2.5 Selected External Plugin Reference.........................................................................................1

    1.1 General info.......................................................................................................................................11.2 Deinterlacing & Pulldown Removal..................................................................................................21.3 Spatio−Temporal Smoothers.............................................................................................................31.4 Spatial Smoothers..............................................................................................................................41.5 Temporal Smoothers.........................................................................................................................41.6 Sharpen/Soften Plugins......................................................................................................................41.7 Resizers..............................................................................................................................................51.8 Subtitle (source) Plugins....................................................................................................................51.9 MPEG Decoder (source) Plugins.......................................................................................................51.10 Audio Decoder (source) Plugins......................................................................................................61.11 Plugins to compare video quality.....................................................................................................61.12 Broadcast Video Plugins..................................................................................................................61.13 Misc Plugins....................................................................................................................................7

    2 AviSynth Frequently Asked Questions..........................................................................................................92.1 Contents.............................................................................................................................................9

    2.1.1 General information.................................................................................................................92.1.2 Loading clips (video, audio and images) into AviSynth..........................................................92.1.3 Opening scripts in encoder and player applications.................................................................92.1.4 Some common error messages.................................................................................................92.1.5 Recognizing and processing different types of content............................................................92.1.6 The color format YV12 and related processing and encoding issues...................................102.1.7 How to use VirtualDub's plugins in AviSynth.......................................................................10

    3 AviSynth FAQ − Some common error messages........................................................................................113.1 Contents...........................................................................................................................................11

    3.1.1 I got the message "LoadPlugin: unable to load "xxx (some plugin)" is not an AviSynth 1.0/AviSynth 2.0 plugin"?.......................................................................................................11

    3.1.2 When frameserving I got the following message: "Script error, there is no function named "xxx (some filter)"" ?...................................................................................................11

    3.1.3 I installed AviSynth and got the following error message: "Couldn't locate decompressor for format 'YV12' (unknown)."?.......................................................................11

    3.1.4 When encoding I got the following error "ACM failed to suggest a compatible PCM format"?...................................................................................................................................12

    3.1.5 When encoding I got the following error: "framesize xyz x 56 not supported"?..................123.1.6 When frameserving I got the following message: "AVISource: couldn't locate a

    decompressor for fourcc (...)"?................................................................................................123.1.7 When frameserving I got the following message: "DirectShowSource: Could not open

    as video or audio Video Returned: "DirectShowSource: the filter graph manager won't talk to me""?............................................................................................................................13

    3.1.8 I am trying to load a script that has a path name with a mix of japanese characters (someone's name) and Ascii test. I got an import error and the path that is displayed has some strange characters (not the japanese characters)?...........................................................13

    3.1.9 When frameserving I got the following message: "CAVIStreamSynth: System exception − Access Violation at 0x0, reading from 0x0"?......................................................13

    3.1.10 When frameserving I got a message similar to: "Avisynth open failure: Script error: Invalid arguments to function "xxx (some filter)" (I:\Video.avs, line 5)"...............................13

    Avisynth 2.5 Selected External Plugin Reference

    i

  • Table of Contents4 AviSynth FAQ − Recognizing and processing different types of content.................................................15

    4.1 Contents...........................................................................................................................................154.1.1 The video and audio in my final encoding is out of sync, what should I do?........................154.1.2 How do I recognize progressive, interlaced, telecined, hybrid and blended content?...........164.1.3 How do I process interlaced content?.....................................................................................164.1.4 How do I process telecined content?......................................................................................174.1.5 How do I process hybrid content?..........................................................................................174.1.6 What is variable framerate video?..........................................................................................174.1.7 How do I import variable framerate video into AviSynth and how do I process it?..............17

    5 AviSynth FAQ − Opening scripts in encoder and player applications.....................................................195.1 Contents...........................................................................................................................................19

    5.1.1 What is frameserving and what is it good for?.......................................................................195.1.2 How do I use AviSynth as a frameserver?.............................................................................195.1.3 How do I frameserve my AVS−file to encoder/application X?.............................................20

    5.1.3.1 Direct frameserving to compatible applications...........................................................205.1.3.2 Direct frameserving to applications using additional plugins......................................205.1.3.3 Direct frameserving to special or modified versions of encoders................................205.1.3.4 Frameserving to applications via fake AVI files and proxy utilities............................215.1.3.5 Frameserving via pipe from auxiliary programs to application−encoders...................21

    5.1.4 How do I solve problems when opening/reading scripts in encoders and players?...............215.1.5 How do I frameserve from Premiere/Ulead/Vegas to AviSynth?..........................................22

    6 AviSynth FAQ − General information.........................................................................................................236.1 Contents...........................................................................................................................................23

    6.1.1 What is AviSynth?..................................................................................................................236.1.2 Who is developing AviSynth?................................................................................................246.1.3 Where can I download the latest versions of AviSynth?........................................................246.1.4 What are the main bugs in these versions?.............................................................................246.1.5 Where can I find documentation about AviSynth?................................................................246.1.6 How do I install/uninstall AviSynth?.....................................................................................246.1.7 What is the main difference between v1.0x, v2.0x, v2.5x, v2.6x and v3.x?..........................246.1.8 How do I know which version number of AviSynth I have?.................................................256.1.9 How do I make an AVS−file?................................................................................................256.1.10 Where do I save my AVS−file?...........................................................................................256.1.11 Are plugins compiled for v2.5x/v2.6x compatible with v1.0x/v2.0x and vice versa?.........256.1.12 How do I use a plugin compiled for v2.0x in v2.5x?...........................................................256.1.13 How do I switch between different AviSynth versions without re−install?........................256.1.14 VirtualdubMod, WMP6.4, CCE and other programs crash every time on exit (when

    previewing an avs file)?...........................................................................................................266.1.15 My computer seems to crash at random during a second pass in any encoder?..................266.1.16 Is there a command line utility for encoding to DivX/XviD using AviSynth?....................266.1.17 Does AviSynth have a GUI (graphical user interface)?.......................................................26

    7 AviSynth FAQ − Loading clips (video, audio and images) into AviSynth................................................287.1 Contents...........................................................................................................................................28

    7.1.1 Which media formats can be loaded into AviSynth?.............................................................287.1.2 Which possibilities exist to load my clip into AviSynth?......................................................28

    Avisynth 2.5 Selected External Plugin Reference

    ii

  • Table of Contents7 AviSynth FAQ − Loading clips (video, audio and images) into AviSynth

    7.1.3 What are the advantages and disadvantages of using DirectShowSource to load your media files?..............................................................................................................................29

    7.1.4 Has AviSynth a direct stream copy mode like VirtualDub?..................................................297.1.5 How do I load AVI files into AviSynth?................................................................................297.1.6 Can I load video with audio from AVI into AviSynth?.........................................................307.1.7 How do I load MPEG−1/MPEG−2/DVD VOB/TS/PVA into AviSynth?.............................307.1.8 How do I load QuickTime files into AviSynth?.....................................................................307.1.9 How do I load raw source video files into AviSynth?...........................................................317.1.10 How do I load RealMedia files into AviSynth?...................................................................317.1.11 How do I load Windows Media Video files into AviSynth?...............................................317.1.12 How do I load MP4/MKV/M2TS/EVO into AviSynth?......................................................327.1.13 How do I load WAVE PCM files into AviSynth?...............................................................327.1.14 How do I load MP1/MP2/MP3/MPA/AC3/DTS/LPCM into AviSynth?............................337.1.15 How do I load aac/flac/ogg files into AviSynth?.................................................................337.1.16 How do I load pictures into AviSynth?................................................................................33

    8 AviSynth FAQ − Using VirtualDub plugins in AviSynth...........................................................................358.1 Contents...........................................................................................................................................35

    8.1.1 Where can I download the latest version of scripts which import filters from VirtualDub?.............................................................................................................................35

    8.1.2 Which filters can be imported?..............................................................................................358.1.3 Do these scripts work in RGB−space or in YUV−space?......................................................358.1.4 How do I make such a script?................................................................................................35

    9 AviSynth FAQ − The color format YV12 and related processing and encoding issues..........................379.1 Contents...........................................................................................................................................37

    9.1.1 What is YV12?.......................................................................................................................379.1.2 Where can I download the latest stable AviSynth version which supports YV12?...............379.1.3 Where can I download the DGIndex/DGDecode plugin, which supports YV12, to

    import MPEG−1/MPEG−2/TS/PVA in AviSynth ?................................................................379.1.4 Which encoding programs support YV12?............................................................................389.1.5 How do I use v2.5x if the encoding programs can't handle YV12 (like TMPGEnc or

    CCE SP)?.................................................................................................................................389.1.6 What will be the main advantages of processing in YV12?...................................................389.1.7 How do I use VirtualDub/VirtualDubMod such that there are no unnecessary color

    conversions?.............................................................................................................................399.1.8 Which internal filters support YV12?....................................................................................399.1.9 Which external plugins support YV12?.................................................................................399.1.10 Are there any disadvantages of processing in YV12?..........................................................399.1.11 How do I know which colorspace I'm using at a given place in my script?........................399.1.12 The colors are swapped when I load a DivX file in AviSynth v2.5?...................................399.1.13 I got a green (or colored line) at the left or at the right of the clip, how do I get rid of

    it?.............................................................................................................................................409.1.14 I installed AviSynth v2.5 and get the following error message: "Couldn't locate

    decompressor for format 'YV12' (unknown)."?.......................................................................409.1.15 I installed AviSynth v2.5 and DivX5 (or one of the latest Xvid builds of Koepi), all I

    got is a black screen when opening my avs in VirtualDub/VirtualDubMod/MPEG−2

    Avisynth 2.5 Selected External Plugin Reference

    iii

  • Table of Contents9 AviSynth FAQ − The color format YV12 and related processing and encoding issues

    encoder?..........................................................................................................................................409.1.16 Are there any lossless YV12 codecs, which I can use for capturing for example?..............409.1.17 Some important links:..........................................................................................................41

    9.3.0.1 Linear Editing:..............................................................................................................419.3.0.2 Non−Linear Editing:.....................................................................................................42

    9.2 Filters with multiple input clips.......................................................................................................429.3 Getting started..................................................................................................................................439.4 AviSynth Internet Links...................................................................................................................449.5 Scripting reference...........................................................................................................................459.6 Arrays...............................................................................................................................................459.7 Block statements..............................................................................................................................479.8 Background......................................................................................................................................48

    9.8.1 Features enabling construction of block statements..............................................................499.9 Implementation Guide....................................................................................................................50

    9.9.1 The if..else block statement...................................................................................................509.9.1.1 Using Eval() and three−double−quotes quoted strings................................................509.9.1.2 Using separate scripts as blocks and the Import() function.........................................529.9.1.3 Using functions (one function for each block)............................................................54

    9.9.2 The if..elif..else block statement............................................................................................559.9.2.1 Using Eval() and three−double−quotes quoted strings................................................559.9.2.2 Using separate scripts as blocks and the Import() function.........................................569.9.2.3 Using functions (one function for each block)............................................................56

    9.9.3 The for..next block statement................................................................................................569.9.3.1 For..Next loop with access to variables in local scope................................................579.9.3.2 For..Next loop without access to variables in local scope...........................................58

    9.9.4 The do..while and do..until block statements........................................................................589.10 Deciding which implementation to use.........................................................................................58

    9.10.1 The if..else and if..elif..else block statements......................................................................599.10.2 The for..next block statement..............................................................................................599.10.3 The do..while and do..until block statements......................................................................59

    9.11 References.....................................................................................................................................599.12 The script execution model............................................................................................................599.13 The script execution model − Evaluation of runtime scripts.........................................................609.14 Contents.........................................................................................................................................60

    9.14.1 Runtime environment initialisation......................................................................................619.14.2 Runtime script parsing and evaluation.................................................................................619.14.3 Runtime environment cleanup and delivery of the resulting frame.....................................619.14.4 The runtime environment in detail.......................................................................................61

    9.14.4.1 Elements of the runtime environment.........................................................................629.14.4.2 Runtime functions and current_frame........................................................................629.14.4.3 Checklist for developing correct runtime scripts........................................................63

    9.15 The script execution model − The fetching of frames...................................................................639.16 The script execution model − The filter graph..............................................................................64

    9.16.1 An example of a filter graph.................................................................................................649.17 The script execution model − Scope and lifetime of variables......................................................659.18 Contents.........................................................................................................................................65

    9.18.1 Global scope.........................................................................................................................65

    Avisynth 2.5 Selected External Plugin Reference

    iv

  • Table of Contents9 AviSynth FAQ − The color format YV12 and related processing and encoding issues

    9.18.2 Local scope...........................................................................................................................659.18.3 Lifetime of variables............................................................................................................669.18.4 A variables scope and lifetime example...............................................................................669.18.5 Code−injecting language facilities and scopes.....................................................................67

    9.18.5.1 Import and Eval..........................................................................................................679.18.5.2 Runtime scripts...........................................................................................................699.18.5.3 The try...catch block...................................................................................................70

    9.19 The script execution model − Performance considerations...........................................................709.19.1 Plugin auto−loading.............................................................................................................719.19.2 Frame caching and the effect on spliting filter graph's paths...............................................719.19.3 What not to include in runtime scripts.................................................................................72

    9.20 The script execution model − Sequence of events.........................................................................739.20.1 The initialisation phase.........................................................................................................739.20.2 The script loading and parsing phase...................................................................................749.20.3 The video frames serving phase...........................................................................................74

    9.21 User functions................................................................................................................................749.21.1 Manipulating arguments.......................................................................................................75

    9.21.1.1 Optional arguments.....................................................................................................759.21.1.2 var arguments..............................................................................................................75

    9.21.2 Manipulating globals............................................................................................................759.21.3 Recursion..............................................................................................................................759.21.4 Tuning performance.............................................................................................................759.21.5 Design and coding−style considerations..............................................................................759.21.6 Organising user defined functions........................................................................................75

    9.22 AviSynth Syntax............................................................................................................................759.23 AviSynth Clip properties...............................................................................................................769.24 AviSynth − Colors.........................................................................................................................789.25 AviSynth Syntax − Control structures...........................................................................................799.26 Contents.........................................................................................................................................79

    9.26.1 Thetry..catch statement........................................................................................................799.26.2 Other control structures (in the broad sense)........................................................................80

    9.26.2.1 Example 1: Create a function that returns a n−times repeated character sequence....819.26.2.2 Example 2: Create a function that selects frames of a clip in arbitrary intervals.......81

    9.27 AviSynth Syntax − Internal functions...........................................................................................829.28 AviSynth Syntax − Boolean functions...........................................................................................839.29 AviSynth Syntax − Control functions............................................................................................849.30 AviSynth Syntax − Conversion functions.....................................................................................879.31 AviSynth Syntax − Multithreading functions................................................................................889.32 AviSynth Syntax − Runtime functions..........................................................................................899.33 AviSynth Syntax − String functions..............................................................................................919.34 AviSynth Syntax − Version functions...........................................................................................949.35 AviSynth Syntax − Operators........................................................................................................94

    9.35.1 Available Operators per Type..............................................................................................949.35.2 Operator Precedence.............................................................................................................96

    9.36 AviSynth Syntax − Plugins............................................................................................................969.37 Plugin autoload and name precedence v2......................................................................................979.38 Plugin autoload and conflicting function names v2.55..................................................................97

    Avisynth 2.5 Selected External Plugin Reference

    v

  • Table of Contents9 AviSynth FAQ − The color format YV12 and related processing and encoding issues

    9.39 AviSynth Syntax............................................................................................................................989.40 AviSynth Runtime environment..................................................................................................100

    9.40.1 Contents..............................................................................................................................1009.40.2 Definition............................................................................................................................1009.40.3 Runtime filters....................................................................................................................1019.40.4 Special runtime variables and functions.............................................................................1019.40.5 How to script inside the runtime environment...................................................................102

    9.41 AviSynth Syntax − Script variables.............................................................................................1029.42 AviSynth Syntax − User defined script functions.......................................................................104

    9.42.1 Definition and Structure.....................................................................................................1049.42.2 Facts about user defined script functions...........................................................................1059.42.3 Related Links......................................................................................................................106

    9.43 Troubleshooting...........................................................................................................................1069.43.1 Contents..............................................................................................................................106

    9.43.1.1 Installation problems.................................................................................................1069.43.1.2 Other problems.........................................................................................................1079.43.1.3 Write Simple.............................................................................................................1079.43.1.4 Always check parameters.........................................................................................1079.43.1.5 Test scripts using Virtualdub....................................................................................1089.43.1.6 Go through the script step by step............................................................................1089.43.1.7 Check your autoloading plugin directory for a files.................................................1089.43.1.8 Use conservative image sizes...................................................................................1099.43.1.9 Finally check the AviSynth Q&A.............................................................................1099.43.1.10 Reporting bugs / Asking for help............................................................................109

    9.44 Advanced Topics........................................................................................................................1109.44.1 Interlaced and field−based video........................................................................................1109.44.2 Color format conversions, the Chroma Upsampling Error and the 4:2:0 Interlaced

    Chroma Problem....................................................................................................................1109.44.3 Colorspace Conversions.....................................................................................................1109.44.4 Wrong levels and colors upon playback.............................................................................1109.44.5 AviSynth, variable framerate (vfr) video and Hybrid video..............................................1109.44.6 Importing your media in AviSynth....................................................................................1119.44.7 Resizing..............................................................................................................................111

    9.45 Color conversions........................................................................................................................1119.45.1 Converting to programming values....................................................................................112

    9.46 References....................................................................................................................................112

    10 AviSynth, variable framerate (vfr) video and hybrid video..................................................................11310.1 Table of contents..........................................................................................................................11310.2 Variable framerate and hybrid video...........................................................................................11310.3 How to recognize vfr content (mkv/mp4)....................................................................................11410.4 Opening MPEG−2 hybrid video in AviSynth and re−encoding..................................................115

    10.4.1 encoding to cfr (23.976 fps or 29.97 fps)...........................................................................11510.4.2 encoding to cfr − 120 fps....................................................................................................11610.4.3 encoding to vfr (mkv).........................................................................................................11710.4.4 encoding to vfr (mp4).........................................................................................................11810.4.5 summary of the methods....................................................................................................118

    Avisynth 2.5 Selected External Plugin Reference

    vi

  • Table of Contents10 AviSynth, variable framerate (vfr) video and hybrid video

    10.5 Opening non MPEG−2 hybrid video in AviSynth and re−encoding...........................................11810.5.1 opening non−avi vfr content in AviSynth..........................................................................11810.5.2 re−encoding 120 fps video.................................................................................................11910.5.3 converting vfr to cfr avi for AviSynth................................................................................11910.5.4 encoding to MPEG−2 vfr video.........................................................................................120

    10.6 Audio synchronization.................................................................................................................12010.7 References....................................................................................................................................121

    11 Importing media into AviSynth................................................................................................................12211.1 Contents.......................................................................................................................................12211.2 Loading clips into AviSynth........................................................................................................122

    11.2.1 1.1) Loading clips with video and audio into AviSynth.....................................................12311.2.1.1 1.1.1) AVI with audio:..............................................................................................12311.2.1.2 1.1.2) Other containers with audio:..........................................................................124

    11.2.2 1.2) Loading video clips into AviSynth.............................................................................12711.2.3 1.3) Loading audio clips into AviSynth.............................................................................12911.2.4 1.4) Loading images into AviSynth...................................................................................132

    11.3 2) Changing the merit of DirectShow Filters...............................................................................13211.4 3) Using GraphEdit to make graphs of DirectShow filters and loading these graphs in AviSynth.............................................................................................................................................13211.5 To Do..........................................................................................................................................13511.6 Interlaced and Field−based video................................................................................................135

    11.6.1 Color conversions and interlaced / field−based video.......................................................13511.6.2 Color conversions, interlaced / field−based video and the interlaced flag of dvd2avi......13611.6.3 Changing the order of the fields of a clip...........................................................................137

    11.6.3.1 Swapping fields:.......................................................................................................13711.6.3.2 Reversing field dominance:......................................................................................138

    11.6.4 The parity (= order) of the fields in AviSynth...................................................................13911.6.5 About DV / DVD in relation to field dominance...............................................................13911.6.6 References..........................................................................................................................139

    12 Resampling.................................................................................................................................................14012.1 Resampling..................................................................................................................................140

    12.1.1 The Nyquist–Shannon sampling theorem..........................................................................14012.1.2 Example: the bilinear resampling filter − upsampling.......................................................14112.1.3 Example: the bilinear resampling filter − downsampling..................................................14312.1.4 Example: the bicubic resampling filter − upsampling.......................................................145

    12.2.0.1 AviSynth's implementation.......................................................................................14612.2 An implementation of the resampling filters...............................................................................14712.3 Resizing Algorithms....................................................................................................................149

    12.3.1 Nearest Neighbour resampler.............................................................................................14912.3.2 Bilinear resampler..............................................................................................................15012.3.3 Bicubic resampler...............................................................................................................15112.3.4 Windowed sinc resamplers.................................................................................................153

    12.3.4.1 Sinc resampler...........................................................................................................15312.3.4.2 Lanczos resampler....................................................................................................15412.3.4.3 Blackman resampler.................................................................................................155

    Avisynth 2.5 Selected External Plugin Reference

    vii

  • Table of Contents12 Resampling

    12.3.5 Spline resampler.................................................................................................................15612.3.6 Gaussian resampler.............................................................................................................159

    12.4 ....................................................................................................................................................160

    13 Sampling.....................................................................................................................................................16213.1 1. Color format conversions and the Chroma Upsampling Error................................................162

    13.1.1 1.1 Chroma Upsampling Error (or CUE)...........................................................................16313.1.2 1.2 Correcting video having the Chroma Upsampling Error.............................................164

    13.2 2. Theoretical Aspects..................................................................................................................16413.2.1 2.1 The color formats: RGB, YUY2 and YV12.................................................................164

    13.2.1.1 YUV 4:4:4 color format............................................................................................16413.2.1.2 YUY2 color format...................................................................................................16413.2.1.3 YV12 color format....................................................................................................165

    13.2.2 2.2 Subsampling.................................................................................................................16613.2.2.1 RGB −> YUY2 conversion......................................................................................166

    13.2.3 2.3 Upsampling..................................................................................................................16813.2.3.1 YUY2 conversion −> RGB......................................................................................16813.2.3.2 YV12 interlaced conversion −> YUY2....................................................................169

    13.2.4 2.4 References....................................................................................................................17213.2.5 3.1 MPEG−1 versus MPEG−2 sampling...........................................................................17213.2.6 3.2 DV sampling.................................................................................................................17313.2.7 3.3 References....................................................................................................................174

    13.25.0.1 To strictly preserve the original fields and just fill in the missing lines.................17413.33.0.1 Other internal functions:.........................................................................................174

    13.3 4. 4:2:0 Interlaced Chroma Problem (or ICP)..............................................................................17413.4 Introduction..................................................................................................................................17513.5 Media file filters..........................................................................................................................17613.6 Color conversion and adjustment filters.....................................................................................17613.7 Overlay and Mask filters..............................................................................................................17713.8 Geometric deformation filters......................................................................................................17713.9 Pixel restoration filters.................................................................................................................17813.10 Timeline editing filters..............................................................................................................17813.11 Interlace filters..........................................................................................................................17913.12 Audio processing filters............................................................................................................17913.13 Meta filters................................................................................................................................18013.14 Conditional filters......................................................................................................................18013.15 Debug filters..............................................................................................................................18113.16 AddBorders...............................................................................................................................18213.17 RGBAdjust.................................................................................................................................18313.18 Amplify / AmpiflydB.................................................................................................................18513.19 Animate / ApplyRange.............................................................................................................18513.20 AssumeSampleRate..................................................................................................................18613.21 AudioDub / AudioDubEx..........................................................................................................18713.22 AVISource / OpenDMLSource / AVIFileSource / WAVSource..........................................18913.23 BlankClip / Blackness...............................................................................................................18913.24 Blur / Sharpen............................................................................................................................19113.25 Bob............................................................................................................................................191

    Avisynth 2.5 Selected External Plugin Reference

    viii

  • Table of Contents13 Sampling

    13.26 ColorBars..................................................................................................................................19213.27 ColorYUV.................................................................................................................................19313.28 Compare....................................................................................................................................19413.29 ConditionalFilter.......................................................................................................................19413.30 ScriptClip...................................................................................................................................19513.31 FrameEvaluate...........................................................................................................................19513.32 ConditionalReader.....................................................................................................................19613.33 Runtime Functions.....................................................................................................................19613.34 Advanced conditional filtering: part I........................................................................................19713.35 Advanced conditional filtering: part II.....................................................................................19913.36 Advanced conditional filtering: part III....................................................................................19913.37 ConditionalReader....................................................................................................................202

    13.37.1 Parameters........................................................................................................................20213.37.2 File format........................................................................................................................20213.37.3 Types................................................................................................................................20313.37.4 Examples..........................................................................................................................203

    13.37.4.1 Basic usage.............................................................................................................20313.37.4.2 Adjusting Overlay...................................................................................................20413.37.4.3 Complicated ApplyRange.......................................................................................205

    13.38 ConvertBackToYUY2 / ConvertToRGB / ConvertToRGB24 / ConvertToRGB32 ConvertToY8 / ConvertToYUY2 / ConvertToYV12 / ConvertToYV16 / ConvertToYV24 / ConvertToYV411...............................................................................................................................20513.39 ConvertAudioTo8bit / ConvertAudioTo16bit / ConvertAudioTo24bit ConvertAudioTo32bit / ConvertAudioToFloat..................................................................................20913.40 ConvertToMono.........................................................................................................................20913.41 GeneralConvolution...................................................................................................................20913.42 Crop / CropBottom...................................................................................................................21113.43 Memory alignment.....................................................................................................................21213.44 Crop restrictions.........................................................................................................................21213.45 DelayAudio................................................................................................................................21313.46 DeleteFrame...............................................................................................................................21313.47 DirectShowSource....................................................................................................................213

    13.47.1 Examples..........................................................................................................................21513.47.2 Troubleshooting video and audio problems.....................................................................216

    13.47.2.1 RenderFile, the filter graph manager won't talk to me...........................................21613.47.2.2 The samplerate is wrong.........................................................................................21613.47.2.3 My sound is choppy................................................................................................21613.47.2.4 My sound is out of sync..........................................................................................21613.47.2.5 My ASF renders start fast and finish slow..............................................................216

    13.47.3 Common tasks..................................................................................................................21713.47.3.1 Opening GRF files..................................................................................................21713.47.3.2 Downmixing AC3 to stereo...................................................................................21714.7.0.1 Remark1:...................................................................................................................22114.7.0.2 Remark2:...................................................................................................................221

    13.48 Dissolve.....................................................................................................................................22213.49 DoubleWeave.............................................................................................................................22213.50 DuplicateFrame..........................................................................................................................222

    Avisynth 2.5 Selected External Plugin Reference

    ix

  • Table of Contents13 Sampling

    13.51 EnsureVBRMP3Sync................................................................................................................22413.52 FadeIn / FadeIn0 / FadeIn2 / FadeIO0 / FadeIO / FadeIO2 / FadeOut / FadeOut0 / FadeOut2.............................................................................................................................................22513.53 FixBrokenChromaUpsampling..................................................................................................225

    14 FixLuminance.............................................................................................................................................22514.1 FlipHorizontal / FlipVertical......................................................................................................22614.2 AssumeFPS..................................................................................................................................22714.3 AssumeScaledFPS.......................................................................................................................22714.4 ChangeFPS...................................................................................................................................22914.5 ConvertFPS..................................................................................................................................22914.6 FreezeFrame.................................................................................................................................23014.7 GetChannel.................................................................................................................................23114.8 Greyscale......................................................................................................................................23114.9 Histogram....................................................................................................................................231

    14.9.1 Classic mode.......................................................................................................................23114.9.2 Levels mode.......................................................................................................................23214.9.3 Color mode.........................................................................................................................23214.9.4 Color2 mode.......................................................................................................................23314.9.5 Luma mode.........................................................................................................................23414.9.6 Stereo and StereoOverlay mode.........................................................................................23414.9.7 AudioLevels mode.............................................................................................................235

    14.33.0.1 Parameters:..............................................................................................................23614.33.1 RGB considerations..........................................................................................................23714.33.2 Conditional Variables.......................................................................................................23814.33.3 Examples..........................................................................................................................23914.33.4 Changelog:........................................................................................................................239

    14.10 ImageReader / ImageSource......................................................................................................24014.11 ImageWriter..............................................................................................................................24014.12 Import.........................................................................................................................................24014.13 Info............................................................................................................................................24214.14 Interleave....................................................................................................................................24214.15 Invert.........................................................................................................................................24214.16 KillAudio / KillVideo................................................................................................................24314.17 Layer [yuy2][rgb32]...................................................................................................................24314.18 Mask [rgb32]..............................................................................................................................24414.19 ResetMask [rgb32].....................................................................................................................24514.20 ColorKeyMask [rgb32]..............................................................................................................24614.21 Letterbox....................................................................................................................................24714.22 Levels........................................................................................................................................24814.23 Limiter......................................................................................................................................24914.24 Loop...........................................................................................................................................25014.25 MaskHS....................................................................................................................................25014.26 Merge / MergeChroma / MergeLuma.......................................................................................25014.27 MergeChannels.........................................................................................................................25114.28 MergeARGB / MergeRGB.......................................................................................................25214.29 MessageClip...............................................................................................................................252

    Avisynth 2.5 Selected External Plugin Reference

    x

  • Table of Contents14 FixLuminance

    14.30 MixAudio..................................................................................................................................25414.31 MonoToStereo...........................................................................................................................25414.32 Normalize...................................................................................................................................25514.33 Overlay......................................................................................................................................25714.34 AssumeFrameBased / AssumeFieldBased.................................................................................25714.35 AssumeTFF / AssumeBFF.........................................................................................................25714.36 ComplementParity.....................................................................................................................25714.37 PeculiarBlend.............................................................................................................................25814.38 Pulldown....................................................................................................................................25814.39 HorizontalReduceBy2 / VerticalReduceBy2 / ReduceBy2.......................................................25914.40 ResampleAudio.........................................................................................................................26014.41 BicubicResize / BilinearResize / BlackmanResize / GaussResize / LanczosResize / Lanczos4Resize / PointResize / SincResize / Spline16Resize / Spline36Resize / Spline64Resize...260

    14.41.1 General information.........................................................................................................26114.41.2 BilinearResize..................................................................................................................26114.41.3 BicubicResize...................................................................................................................26214.41.4 BlackmanResize...............................................................................................................26314.41.5 GaussResize......................................................................................................................26314.41.6 LanczosResize / Lanczos4Resize.....................................................................................26314.41.7 PointResize.......................................................................................................................26314.41.8 Spline16Resize/Spline36Resize/Spline64Resize.............................................................26414.41.9 SincResize........................................................................................................................264

    14.42 Reverse.......................................................................................................................................26414.43 SegmentedAVISource / SegmentedDirectShowSource............................................................26414.44 SelectEven / SelectOdd..............................................................................................................26514.45 SelectEvery...............................................................................................................................26514.46 SelectRangeEvery......................................................................................................................26614.47 SeparateFields............................................................................................................................26614.48 ShowAlpha, ShowRed, ShowGreen, ShowBlue.......................................................................26714.49 ShowFiveVersions.....................................................................................................................26714.50 ShowFrameNumber...................................................................................................................26814.51 ShowSMPTE.............................................................................................................................26814.52 ShowTime..................................................................................................................................26914.53 SpatialSoften / TemporalSoften................................................................................................26914.54 SoundOut...................................................................................................................................271

    14.54.1 Installation and Usage......................................................................................................27114.54.2 Output Modules................................................................................................................271

    14.54.2.1 WAV/AIF/CAF......................................................................................................27114.54.2.2 FLAC......................................................................................................................27114.54.2.3 APE.........................................................................................................................27114.54.2.4 MP2.........................................................................................................................27214.54.2.5 MP3.........................................................................................................................27214.54.2.6 AC3.........................................................................................................................27214.54.2.7 OGG........................................................................................................................27214.54.2.8 Commandline Output..............................................................................................272

    14.54.3 Exporting from script.......................................................................................................27314.54.3.1 General Parameters.................................................................................................273

    Avisynth 2.5 Selected External Plugin Reference

    xi

  • Table of Contents14 FixLuminance

    14.54.3.2 WAV/AIF/CAF Script Parameters:........................................................................27314.54.3.3 FLAC Script Parameters:........................................................................................27414.54.3.4 APE Script Parameters:..........................................................................................27414.54.3.5 MP2 Script Parameters:..........................................................................................27414.54.3.6 MP3 Script Parameters:..........................................................................................27514.54.3.7 AC3 Script Parameters:..........................................................................................27514.54.3.8 OGG Script Parameters:.........................................................................................27614.54.3.9 Wavpack Script Parameters:...................................................................................27614.54.3.10 Commandline Output Script Parameters:.............................................................276

    14.54.4 Examples..........................................................................................................................27714.54.5 Implementation notes.......................................................................................................27714.54.6 Changelist.........................................................................................................................277

    14.58.0.1 Parameters...............................................................................................................28014.55 AlignedSplice / UnalignedSplice...............................................................................................28014.56 SSRC.........................................................................................................................................28114.57 StackHorizontal / StackVertical.................................................................................................28214.58 Subtitle.......................................................................................................................................28214.59 Subtract.....................................................................................................................................28514.60 SuperEQ....................................................................................................................................28514.61 SwapUV / UToY / VToY / YToUV.........................................................................................28614.62 SwapFields.................................................................................................................................28714.63 TCPServer / TCPSource...........................................................................................................287

    14.63.1 Syntax...............................................................................................................................28714.63.1.1 Server:.....................................................................................................................28714.63.1.2 Client:......................................................................................................................288

    14.63.2 Examples..........................................................................................................................28814.63.3 Usability Notes.................................................................................................................28914.63.4 Changelog.........................................................................................................................289

    14.64 TimeStretch...............................................................................................................................28914.65 Tone..........................................................................................................................................29214.66 Trim...........................................................................................................................................29314.67 TurnLeft / TurnRight / Turn180...............................................................................................29314.68 Tweak........................................................................................................................................293

    14.68.1 Usage and examples: adjusting contrast and brightness..................................................29414.68.2 Usage and examples: adjusting saturation........................................................................295

    14.71.0.1 Usage is best explained with some simple examples:............................................29714.71.0.2 There are easier ways to write numbers in a file, BUT:.........................................29714.71.0.3 More examples:.......................................................................................................298

    14.69 Version......................................................................................................................................29914.70 Weave........................................................................................................................................29914.71 WriteFile / WriteFileIf / WriteFileStart / WriteFileEnd............................................................29914.72 AviSynth License.......................................................................................................................300

    14.72.1 AviSynth documentation license......................................................................................30014.72.2 AviSynth logo...................................................................................................................30114.72.3 Avisynth uses codes from following projects:.................................................................30214.72.4 Thanks also to everyone else contributing to the AviSynth project!...............................303

    Avisynth 2.5 Selected External Plugin Reference

    xii

  • 1 Avisynth 2.5 Selected External Plugin Reference

    1.1 General info

    AviSynth plugins are external linked modules (libraries) implementing one or more additional functions(filters) for deinterlacing, noise reduction, etc. Great number of plugins (200 or more) were written byindependent developers as free software. You can get them at collection by WarpEnterprises or (most recent)at homepages of authors (see also AviSynth Web site and forums). This documentation includes authorsdescriptions of selected popular plugins with typical useful functions. It can be good reading even if you willuse some other (similar) plugins.

    The description of a plugin starts with some general info about the plugin. For example

    author: Rainer Wittmann (aka kassandro)version: 0.6.1download: http://www.removedirt.de.tf/category: Temporal Smoothersrequirements:

    YV12 & YUY2 Colorspace• SSEMMX support• width and the height of the clip must be a multiple of 8•

    license: GPL

    The first line "author" gives the author(s) of the plugin. It can be his/her real name, the forum nickname, orboth.The second line "version" gives the version of the plugin on which is described in this documentation. Notethat it might not be the most recent version of the plugin.The third line "download" gives the download page of the plugin.The fourth line "category", is the category under which the plugin can be found.The fifth line "requirements", are the requirements for being able to use the plugin. Requirements can be thesupported color space (YV12 and YUY2 in this case), the supported CPU (which is SSEMMX here) or thatthe width/height must be a multiple of some number (usually 8 or 16). The latter is a requirement for theoptimizations in the plugin.The last line "license" gives the license of the plugin. Usually it is none (ie closed source), GPL or just opensource (without a specific license).

    A final note about the CPUs which might be required for a plugin. If you don't know what kind of optimizinginstructions are used by your CPU, you can look it up in the following table

    optimizinginstructions

    CPU

    MMXPentium MMX, Pentium II, K6, K6II,K6III and later

    iSSE (also calledSSEMMX)

    Pentium III, all Duron (called 3DNowextension), all Athlon (called 3DNowextension)

    SSE

    1 Avisynth 2.5 Selected External Plugin Reference 1

    http://avisynth.org/warpenterpriseshttp://www.removedirt.de.tf/

  • Pentium III, Duron (core Morgan),Athlon XP and later

    SSE2 P−IV, Opteron, Athlon 64SSE3 P−IV Prescott

    1.2 Deinterlacing & Pulldown Removal

    All PAL, NTSC, and SECAM video is interlaced, which means that only every other line is broadcast at eachrefresh interval. Deinterlacing filters let you take care of any problems caused by this. IVTC (inversetelecine, aka pulldown removal) filters undo the telecine process, which comes from differences between thetiming of your video and its original source.

    Decomb Filter package (byDonald Graft)

    This package of plugin functions for AviSynth provides the meansfor removing combing artifacts from telecined progressive streams,interlaced streams, and mixtures thereof. Functions can becombined to implement inverse telecine for both NTSC and PALstreams. [discussion].

    DGBob (by Donald Graft)This filter splits each field of the source into its own frame and thenadaptively creates the missing lines either by interpolating thecurrent field or by using the previous field's data. [discussion].

    FDecimate (by DonaldGraft)

    This filter provides extended decimation capabilities not availablefrom Decimate(). It can remove frames from a clip to achieve thedesired frame rate, while retaining audio/video synchronization. Itpreferentially removes duplicate frames where possible.[discussion].

    GreedyHMA (by TomBarry)

    DScaler's Greedy/HM algorithm code to perform pulldownmatching, filtering, and video deinterlacing. [discussion].

    IBob (by Kevin Atkinson)This simple filter works identically to the Avisynth built−in Bobfilter except that it uses linear interpolation instead of bicubicresizing. [discussion].

    KernelDeint (by DonaldGraft)

    This filter deinterlaces using a kernel approach. It gives greatlyimproved vertical resolution in deinterlaced areas compared tosimple field discarding. [discussion].

    LeakKernelDeint (mod ofKernelDeint by Leak)

    This filter deinterlaces using a kernel approach. It gives greatlyimproved vertical resolution in deinterlaced areas compared tosimple field discarding. [discussion].

    MultiDecimate (by DonaldGraft)

    Removes N out of every M frames, taking the frames most similarto their predecessors. [discussion].

    SmartDecimate (by KevinAtkinson)

    This filter removes telecine by combining telecine fields anddecimating at the same time, which is different from the traditionalapproach of matching telecine frames and then removing duplicates.[discussion].

    TDeint (by tritical) TDeint is a bi−directionally, motion adaptive (sharp) deinterlacer. Itcan also adaptively choose between using per−field and per−pixelmotion adaptivity. It can use cubic interpolation, kernelinterpolation (with temporal direction switching), or one of two

    Avisynth 2.5 Selected External Plugin Reference

    1.2 Deinterlacing & Pulldown Removal 2

    http://forum.doom9.org/showthread.php?s=&threadid=76456http://forum.doom9.org/showthread.php?s=&threadid=55598http://forum.doom9.org/showthread.php?s=&threadid=77798http://forum.doom9.org/showthread.php?s=&threadid=45995http://forum.doom9.org/showthread.php?s=&threadid=62142http://neuron2.net/ipw-web/bulletin/bb/viewtopic.php?t=57http://forum.doom9.org/showthread.php?t=81322http://forum.doom9.org/showthread.php?s=&threadid=51901&perpage=20&pagenumber=2http://forum.doom9.org/showthread.php?s=&threadid=60031

  • forms of modified ELA interpolation which help to reduce "jaggy"edges in moving areas where interpolation must be used. TDeintalso supports user overrides through an input file, and can act as asmart bobber or same frame rate deinterlacer, as well as an IVTCpost−processor. [discussion].

    TIVTC Filter package (bytritical)

    This package of plugin functions for AviSynth provides the meansfor removing combing artifacts from telecined progressive streams,interlaced streams, and mixtures thereof. Functions can becombined to implement inverse telecine for both NTSC and PALstreams.

    TomsMoComp "Motioncompensated deinterlacefilter" (by Tom Barry)

    This filter uses motion compensation and adaptive processing todeinterlace video source (not for NTSC film). [discussion].

    UnComb IVTC (by TomBarry)

    Filter for matching up even and odd fields of properly telecinedNTSC or PAL film source video. [discussion].

    1.3 Spatio−Temporal Smoothers

    These filters use color similarities and differences both within and between frames to reduce noise andimprove compressed size. They can greatly improve noisy video, but some care should be taken with them toavoid blurred movement and loss of detail.

    Deen (by Marc FD) Several denoisers. [discussion]

    Convolution3D /Convolution3DYV12 (byVlad59)

    Convolution3D is a spatio−temporal smoother, it applies a 3Dconvolution filter to all pixels of consecutive frames. [discussion].

    FluxSmooth (by SansGrip)Fluctuating pixels are wiped from existence by averaging it with itsneighbours. [discussion].

    FFT3DFilter (by Fizick)FFT3DFilter is 3D Frequency Domain filter − strong denoiser andmoderate sharpener. [discussion].

    FFT3DGPU (by tsp) FFT3dGPU is a GPU version of FFT3DFilter. [discussion].

    NoMoSmooth (bySansGrip)

    A motion−adaptive spatio−temporal smoother. [discussion].

    MipSmooth (by Sh0dan)

    It takes the source frame, and creates three new versions, each halfthe size of the previous. They are scaled back to original size. Theyare compared to the original, and if the difference is below thethreshold, the information is used to form the final pixel.[discussion].

    PeachSmoother (by LindseyDubb)

    An adaptive smoother optimized for TV broadcasts. The Peachworks by looking for good pixels and gathering orange smoke fromthem. When it has gathered enough orange smoke, it sprinkles thatonto the bad pixels, making them better. [discussion].

    STMedianFilter"SpatioTemporal MedianFilter" (by Tom Barry)

    STMedianFilter is a (slightly motion compensated) spatial/temporalmedian filter.

    Avisynth 2.5 Selected External Plugin Reference

    1.3 Spatio−Temporal Smoothers 3

    http://forum.doom9.org/showthread.php?s=&threadid=82264http://forum.doom9.org/showthread.php?s=&threadid=37915http://forum.doom9.org/showthread.php?s=&threadid=52333http://forum.doom9.org/showthread.php?s=&threadid=41643http://forum.doom9.org/showthread.php?s=&threadid=38281http://forum.doom9.org/showthread.php?s=&threadid=38296http://forum.doom9.org/showthread.php?t=85790http://forum.doom9.org/showthread.php?t=89941http://forum.doom9.org/showthread.php?s=&threadid=37471http://forum.doom9.org/showthread.php?s=&threadid=63153http://forum.doom9.org/showthread.php?s=&threadid=36575

  • 1.4 Spatial Smoothers

    These use color similarities and differences within a frame to improve the picture and reduce compressedsize. They can smooth out noise very well, but overly aggressive settings for them can cause a loss of detail.

    MSmooth "MaskedSmoother" (by DonaldGraft)

    This filter is effective at removing mosquito noise as well aseffectively smoothing flat areas in anime. [discussion].

    SmoothUV (by Kurosu)This filter can be used to reduce rainbows, as done bySmartSmoothIQ. [discussion].

    TBilateral (by tritical)TBilateral is a spatial smoothing filter that uses the bilateral filteringalgorithm. It does a nice job of smoothing while retaining picturestructure. [discussion]

    VagueDenoiser (byLefungus)

    A simple denoiser that uses wavelets. [discussion].

    1.5 Temporal Smoothers

    These filters use color similarities and differences between frames to improve the picture and reducecompressed size. They can get rid of most noise in stationary areas without losing detail, but overly strongsettings can cause moving areas to be blurred.

    Cnr2 "Chroma NoiseReducer" (by Marc FD)

    Reduces the noise on the chroma (UV) and preserves the luma (Y).[discussion].

    GrapeSmoother (by LindseyDubb)

    When colors change just a little, the filter decides that it is probablynoise, and only slightly changes the color from the previous frame.As the change in color increases, the filter becomes more and moreconvinced that the change is due to motion rather than noise, andthe new color gets more and more weight. [discussion].

    RemoveDirt (by kassandro)A temporal cleaner with strong protection against artifacts.[discussion].

    TemporalCleaner (by JimCasaburi; ported toAviSynth by Vlad59)

    A simple but very fast temporal denoiser, aimed to improvecompressibility.

    TTempSmooth (by tritical)TTempSmooth is a motion adaptive (it only works on stationaryparts of the picture), temporal smoothing filter. [discussion]

    1.6 Sharpen/Soften Plugins

    These are closely related to the Spatial Smoothers, above. They attempt to improve image quality bysharpening or softening edges.

    asharp (by Marc FD) Adaptive sharpening filter. [discussion].

    aWarpSharp (by Marc FD) A warp sharpening filter.

    Avisynth 2.5 Selected External Plugin Reference

    1.4 Spatial Smoothers 4

    http://forum.doom9.org/showthread.php?s=&threadid=43976http://forum.doom9.org/showthread.php?s=&threadid=60631http://forum.doom9.org/showthread.php?s=&threadid=77856http://forum.doom9.org/showthread.php?s=&threadid=56871http://forum.doom9.org/showthread.php?s=&threadid=78905http://forum.doom9.org/showthread.php?s=&threadid=37196http://forum.doom9.org/showthread.php?s=&threadid=70856http://forum.doom9.org/showthread.php?s=&threadid=77856http://forum.doom9.org/showthread.php?s=&threadid=38436

  • MSharpen (by DonaldGraft)

    This plugin for AviSynth implements an unusual concept in spatialsharpening. Although designed specifically for anime, it also worksquite well on normal video. The filter is very effective at sharpeningimportant edges without amplifying noise. [discussion].

    TUnsharp (by tritical)

    TUnsharp is a basic sharpening filter that uses a couple differentvariations of unsharpmasking and allows for controlled sharpeningbased on edge magnitude and min/max neighborhood valueclipping. The real reason for its existence is that it sports a gui withreal time preview. [discussion].

    Unfilter plugin (by TomBarry)

    This filter softens/sharpens a clip. It implements horizontal andvertical filters designed to (slightly) reverse previous efforts atsoftening or edge enhancment that are common (but ugly) in DVDmastering. [discussion].

    WarpSharp WarpSharp.

    Xsharpen This filter performs a subtle but useful sharpening effect.

    1.7 Resizers

    Plugins for resizing your clip.

    BicublinResize (by MarcFD)

    This is a set of resamplers: FastBilinear (similar to tbarry'ssimpleresize), FastBicubic (an unfiltered Bicubic resampler) andBicublin (uses bicubic on Y plane and bilinear on UV planes).[discussion].

    SimpleResize (by TomBarry)

    Very simple and fast two tap linear interpolation. It is unfilteredwhich means it will not soften much.

    YV12InterlacedReduceBy2(by Tom Barry)

    InterlacedReduceBy2 is a fast Reduce By 2 filter, usefull as a veryfast downsize of an interlaced clip. [discussion].

    1.8 Subtitle (source) Plugins

    Plugins which let you import various subtitle formats (hard−coded).

    VSFilter (by Gabest)Lets you import various formats of subtitles, like *.sub, *.srt, *.ssa,*.ass, etc. [discussion].

    1.9 MPEG Decoder (source) Plugins

    Plugins which let you import mpeg2 files (including hdtv transport files).

    DGDecode (by DonaldGraft)

    A MPEG2Dec3 modification. Supports in addition MPEG−1 files,4:2:2 input, and a lot of other things. See changelist for more info.Incompatible with the dvd2avi 1.xx versions and requires DGIndex.[discussion].

    MPEG2Dec (by dividee andMpeg2dec is a plugin which lets AviSynth import MPEG2 files.

    Avisynth 2.5 Selected External Plugin Reference

    1.7 Resizers 5

    http://forum.doom9.org/showthread.php?s=&threadid=42839http://forum.doom9.org/showthread.php?t=84344http://forum.doom9.org/showthread.php?s=&threadid=28197&pagenumber=3http://forum.doom9.org/showthread.php?s=&threadid=43207http://forum.doom9.org/showthread.php?s=&postid=271863http://forum.doom9.org/showthread.php?s=&threadid=41196http://forum.doom9.org/showthread.php?t=94184

  • others) (outputs to YUY2)

    MPEG2Dec3 (by