Anda di halaman 1dari 16

AVSEdit - AviSynth for the scripting impaired

AVSEdit is the official script editor for AviSynth. It provides an easy interface to write and preview scripts, making AviSynth more accessible to beginners and advanced users alike. If you've always wanted to use AviSynth, but have been intimidated by the lack of a GUI, or if you just want to make scripting a little easier, you should give AVSEdit a try. This guide was written by vurbal.

Software used in this guide


AviSynth 2.54 AVSEdit 1.0

Installation
Start by installing AviSynth. If you decide to change the install location from the default (C:\Program Files\AviSynth 2.5) make a note of where it is. You'll need this information later to install plugins. Next install AVSEdit. The installer will check to see if your system has Microsoft's .NET 1.1 Framework installed. If it's not already installed you'll see a dialog prompting you to download and install it.

Plugins
Many people have written plugins that extend the functionality of AviSynth. Before you can use a plugin you need to download it to your computer and copy 1 or more files to the AviSynth plugins directory. If you installed AviSynth to the default location, that will be C:\Program Files\AviSynth\plugins. In the AviSynth program group on the Start menu there's a Download Plugins link that will open a web page with links to many of them, including the ones used in this guide. Each download is a zip archive which normally

includes a DLL file and either text or html files with instructions. Some plugins also come with source code or example scripts. The DLL files need to be copied to the AviSynth plugins directory so AviSynth can autoload them. Note: The download page has 2 columns for download links. The column to the left is for AviSynth 2.0 plugins and the one on the right is for AviSynth 2.5. Make sure you get the v2.5 plugins.

Get to know AVSEdit


Before you start creating scripts you'll need to familiarize yourself with AVSEdit. There are 3 basic parts to the interface. At the top are the menu and button toolbars, which are fairly standard Windows toolbars. Below the toolbars on the left is the editor. You can view your script here as it's being created and also make manual changes and add comments. Finally, on the right side are 3 tabs Parameters, Filters, and Profiles. Filters are the basic instructions for AviSynth and parameters are the details required for most filters. These 2 tabs allow you to select the filters from a list and enter the parameters in the fields provided. The Profiles tab gives you the ability to quickly save and load multiple versions of your script for comparison.

The filters tab

You'll want to arrange the Filters tab to make it easier to find what you're looking for. When you run the program the first time the filters are arranged in alphabetical order.

That's fine if you know the name for the filter you want, but not so good for a beginner trying to figure out which filter does what to use. Right click anywhere on the tab and you'll see a popup giving you options for how filters are organized. Select View by Category. The tab changes to a list of categories, each with a + next to it. Clicking + will expand the list of filters in a category. Clicking a second time hides the list. Setting the Filters tab to View by Plugin will group filters by plugin so you can tell which plugin is required for a particular filter before you select it. Filters from plugins are also displayed in all views with a lighter blue circle next to them than the one used for Core filters.

Your first script


It's time to create your first script. Go to the Filters tab and expand the Debug category. Double-click Version and the text Version() will appear in the editor. Highlight Version() and the Parameters tab automatically becomes visible. At the top of the tab is a dropdown list that says Core::Version and below that is empty space. Core::Version tells you that you're using an AviSynth Core filter (built in to AviSynth) called Version. If there was more than one Version filter you could click the arrow next to it and select the correct one. The blank space tells you there are no parameters to enter.

Previewing

The Preview Window allows you to test the output from your script. On the Extras menu click Preview. The output from the Version filter is information about the AviSynth version you're using. Pressing on your keyboard will play the script's output and pressing

a second time stops it. In this case you won't be able to tell it's playing because Version creates 240 duplicate frames so there's no motion. The Preview Window is also useful for troubleshooting scripts because AviSynth displays error messages the same way it displayed your Version script (a 240 frame video stream).

The parameters tab


Now that you know how to create a script it's time to learn about parameters. Some filters, like Version, don't have any parameters. Most filters do have parameters, some of which are required, and some of which are optional. In order to learn how to work with them we're going to look at the AVISource filter. If you don't have an AVI file to open you can save your version script (select Save As from the File menu) and use it like a normal AVI. Start a new script by clicking the furthest button on the left side of the toolbar or selecting New from the File menu. Go to the Filters tab, expand the Source category, and add the AVISource filter to your script. Highlight the filter in the editor and look at the Parameters tab. Once again you'll see that this is a Core filter, but this time there are 3 parameters listed - filename, [audio], and [pixel_type]. The brackets around the last 2 parameters indicate that they are optional so you don't have to enter anything in them. Click the button next to the filename parameter and a window will open for you to select an AVI to open. Preview the script and start playing the AVI. Now close the preview and select the field next to the audio parameter. Change it to false by clicking the button to the right and selecting false. Preview your script again. If you're opening the Preview script nothing will change since it didn't have any audio to begin with. If it's a normal AVI (with sound), the video will still play, but there won't be any sound.

DVD2AVI project files (also known as D2V files), can be opened with AviSynth using a plugin called MPEG2Dec3. Follow the shortcut on the Start Menu in the AviSynth program group that says Download Plugins to open the web page, and scroll down the page to find the plugin. There are 2 different versions of it. Make sure to get the one that says Recommended Version in the description (decodefix100.zip). When you open the zip archive you'll see the MPEG2Dec3 plugin (MPEG2Dec3dg.dll) which you need to copy to the AviSynth plugins directory. Make sure you use the version of DVD2AVI (DVD2AVIdg) that's included in the archive to create the D2V projects. Once you have the DLL file copied to the plugins directory you're ready to open your project file. Expand the Source category and add the MPEG2Source filter. There are 2 filters listed with that name because there is more than 1 plugin that uses the same filter name, but they're not interchangeable. Add either one to your script and then highlight the line in the editor to find out what plugin it belongs to. The dropdown above the parameters should say MPEG2Dec3::MPEG2Source. If it lists a different plugin you need to click the arrow for the dropdown and select the correct one. The only parameter you need to set is the filename. Adding audio from a separate file

Loading DVD2AVI projects

AviSynth can combine video and audio from separate files. If the audio file is in Wave format, the WavSource Core filter can be used to load the audio file. MPA files can also be loaded using the MPASource plugin. Start by adding the filters to load the video and audio files. Now you need to edit the script directly to add Video= to the beginning of the line that loads the video source and Audio= to the beginning of the line that loads the audio. This creates variables for AudioDub to use. After you have those lines edited you can add the AudioDub filter from the Processing category. Clicking the arrow button next to the video_clip and audio_clip parameters will show you a list of available variables. Select Video for video_clip and Audio for audio_clip.

Editing
AviSynth can edit out unwanted frames, allowing you to do simple editing like removing credits from a movie or more complex editing like removing commercials from TV captures. If you know what frames you want to keep, you can add the Trim filter from the Editing category and directly enter the beginning and end frame on the Parameters tab. You can also use the Preview window to interactively edit a clip. When you have the Preview window open you'll see a trackbar at the bottom with a yellow line indicating the location of the current frame. You can use the left and right arrow keys or the scroll wheel on your mouse to navigate to the first frame you want to keep. Pressing on your keyboard will set that frame as the first_frame for the Trim filter and the trackbar indicator will turn red. Move to the last frame you want to include in the Trim and press on your keyboard to set that frame as the last_frame. Now the trackbar has a blue line indicating the selection you just made. Repeat this process until all your edits have been made and then close the Preview window. AVSEdit will insert the Trim filter with the correct frame numbers entered for you. Note: If you have multiple trim points and the audio goes out of sync after the first section, try editing the Trim line, changing each + to ++

Colorspace conversion
AviSynth 2.5 works in YV12 colorspace by default, but most of the applications that open scripts will require the input to be YUY2. You can convert to

the correct colorspace by using the ConvertToYUY2 filter from the Processing category. Make sure to set the interlaced parameter to true if your video is interlaced.

The crop editor


The Core filters Crop and CropBottom can be used to crop lines from the edges of the video. When you have either of these filters highlighted, the Parameters tab has an additional button at the bottom which opens the Crop Editor. With the Crop Editor you can use either your mouse's scroll wheel or your keyboard to remove lines from any side of your video. Moving your mouse pointer so it's above one of the edges of the video will highlight that side to be cropped. Scrolling up with your scroll wheel or pressing + on your keyboard will increase the crop, while scrolling down or pressing the - key will decrease it. Click the Keys button to see additional options. The bottom of the window also displays the width and height of the video with the current cropping as well as Mod numbers, which indicate what number the height and width are multiples of. When you close the Crop Editor, the parameters will be filled in for you. Note: The AddBorders filter, which adds solid color lines to the sides, gives you the option to use the Crop Editor as well, but you can't interactively edit the borders. Instead you can use the Crop Editor to view the current height and width, exit the Crop Editor, and enter the desired parameters in the fields on the Parameters tab.

The resize editor

Resizing filters (from the Resize category) change the resolution of the video. When using a Core filter that resizes by a variable amount (like BilinearResize, BicubicResize, or LanczosResize) the Parameters tab has an additional button at the bottom which opens the Resize Editor. In the Resize Editor you can select the width and height you want and see what the Mod number is. The total number of pixels and aspect ratio for the selected resolution are also displayed at the bottom. Note: If your final format is a standard format for TV display (ie DVD, SVCD, VCD, etc,...) the aspect ratio can be a misleading number. For example, 704x480 and 352x480 will display different aspect ratios, but when you play them in your DVD player the aspect ratios will be the same. For viewing on your TV make sure to use the correct resolution for the format you're encoding to.

Other useful filters for beginners


Besides loading and editing clips, you may want to process the video to make it look better. The UnDot and Convolution3D plugins add excellent filters for this purpose while being easy enough for anybody to use. Like the name suggests, Undot removes dots from the video. UnDot has no parameters - just add the filter from the Processing category and you're done. Convolution3D is a denoiser with presets for different levels of noise in the video - movieHQ, movieLQ, animeHQ, animeLQ, animeBQ, and vhsBQ. There are 2 different Convolution3D filters listed in the Noise category so make sure to select the one with only clip and preset parameters. I've also noticed that if you select movieHQ for the preset AVSEdit doesn't add it to the script. To get around this you can use movieLQ and manually edit the script to change the L to H. Note: Unlike most AviSynth 2.5 plugins, Convolution3D works in YUY2 colorspace so you'll have to use ConvertToYUY2() before Convolution3D. There's a beta version that works in YV12 colorspace, but not all the features of the filter are implemented, and since you will probably need to output YUY2 anyway, it's best to use the normal release version.

Working with interlaced video


Depending on what filters your script uses, it may be necessary to separate the top and bottom fields from interlaced video before processing. Filters that compare pixels to adjacent pixels in the same frame (primarilly resize filters and spatial smoothers) won't work correctly if the video is interlaced. There are several ways to separate the top and bottom fields of the video, but the one I prefer is to use functions that are available on the AviSynth website in the Shared Functions section. You can copy and paste the functions into every script you want to use or you can do what I do and create a .AVSI (AviSynth Include) file so they will be available in AVSEdit. Follow these instructions to create the AVSI file:

Copy the following into a blank script:


#Functions For Processing Interlaced Video #By stickboy (James D. Lin)# # SetParity function SetParity(clip c, bool parity) { return parity ? c.AssumeTFF() : c.AssumeBFF() } # UnfoldFieldsVertical function UnfoldFieldsVertical(clip c, bool "flip") { flip = default(flip, false) oldParity = c.GetParity() c = c.AssumeTFF().SeparateFields().AssumeFrameBased() top = c.SelectEven() bottom = c.SelectOdd() c = StackVertical(top, flip ? bottom.FlipVertical() \ : bottom) return c.SetParity(oldParity) } # FoldFieldsVertical function FoldFieldsVertical(clip c, bool "flip") { assert(c.Height() % 2 == 0, "FoldFieldsVertical: unexpected frame height") flip = default(flip, false) oldParity = c.GetParity() originalHeight = c.Height() / 2 evens = c.Crop(0, 0, c.Width(), originalHeight) odds = c.Crop(0, originalHeight, c.Width(), originalHeight) odds = flip ? odds.FlipVertical() : odds c = Interleave(evens, odds).AssumeFieldBased().AssumeTFF().Weave() return c.SetParity(oldParity)

} #Stop Copying Here Select Save As from the File menu and browse to the AviSynth plugins folder. Name the file 'Interlaced Functions.avsi (make sure you enter the .avsi extension). Close AVSEdit and then open it again and go to the Filters Tab. You have a new category called User. Expand that category and you'll see the 3 functions in the file you just saved - FoldFieldsVertical, SetParity, and UnfoldFieldsVertical. Now you can add these functions by double clicking them. When you have interlaced material that you want to denoise or resize, start by adding the UnfoldFieldsVertical function. If you highlight it in the editor, you'll see parameters listed. Ignore these parameters as they won't give you the correct syntax for the function. Instead, manually edit the line in the editor to read UnfoldFieldsVertical(true). When you are done filtering you need to weave the fields together again using FoldFieldsVertical(true). Note: Some filters, like Crop and AddBorders, should be used while the video is still interlaced.

Using profiles

There are times when you want to try using different filters or even the same filter with

different settings to find out which settings you prefer. By saving different versions as profiles, AVSEdit allows you to quickly switch between them without rewriting each time. To create a profile, go to the Profiles tab, enter a name in the field at the top, and click the save button. To load a profile, select the profile name from the list and click Load. If you want to compare scripts side by side you should use an external program for previewing (I use VirtualDubMod). Before you can do that you need to select Options from the Extras menu, click the External Preview button, and browse to the program you want to preview with. To compare different scripts, select External Preview from the Extras menu to view the output from the first script. Leave the external preview open, go back to AVSEdit, switch to another profile, and do another External Preview. Now you have both scripts open in different windows. Note: I use profiles for editing TV captures. I have one profile with sound and one without. I do an External Preview in VirtualDubMod to save the audio stream as a WAV file (edited to match my video) and then use the profile with no sound to encode the video.

nverse Telecine
If your video is 29.97fps and was originally shot on film, it's probably been telecined. Telecine is a process that changes 23.976fps (frames per second) progressive video to 29.97 frames per second interlaced (59.94 fields per second). Normally that means you can perform an IVTC (Inverse Telecine) operation on it to recover the original progressive frames. Not only will this give you back the original progressive content, it will also reduce the filesize by discarding 1 out of every 5 frames. Note: Since the IVTC process creates 23.976fps, depending on your final format, you may need to add pulldown information after encoding. There are some free utilities available for this, and some DVD authoring software will do it for you when you load 23.976fps video that hasn't already had pulldown flags added.

The Decomb Plugin


IVTCing your video requires 2 filters, both of which are in the Decomb plugin. Decomb also comes with excellent HTML documentation (which is also in the AVSEdit Help File), including a tutorial which has step by step instructions for performing IVTC and a Reference Manual with hints for using each of the included filters. If the steps in this guide give you poor results, the tutorial may help you sort out your problem. If you have a hybrid source (mixed film and video content) you should go straight to Decomb's documentation. If your source is pure film you can (usually) use the steps in this guide.

Note: If your source is a D2V file and you used Force Film when you created the project, you've already performed IVTC on it. If you want to use AviSynth to IVTC you should create a new DVD2AVI project with Field Operation set to None.

Telecide
The first step is to recreate the original progressive frames. Before you can do that, you need to determine whether your video is TFF (Top Field First) or BFF (Bottom Field First). This can be done using Core filters from the Interlaced category. Add AssumeTFF and SeparateFields to your script and preview it. Navigate through the preview until you find a section where something moves either left to right or right to left across the screen and step through several frames, one frame at a time. If the object moves backwards in every other frame, the field order is BFF. If the movement looks correct it's TFF.

Delete the AssumeTFF and SeparateFields lines and add the Telecide filter from the Interlaced category. Set the order parameter to 0 if your video is BFF or 1 if it's TFF. You must set the order because there is no default value. Preview your video again, find a section with motion, and step through it one frame at a time. You should see a repeating pattern of 3 unique frames followed by 2 identical frames. If you don't see this pattern, or you only see it some of the time, refer to the Decomb tutorial instead of this guide.

Decimate
Now that you've recovered the original film frames, you can use the Decimate filter from the Interlaced category to get rid of the duplicate frames. You don't need to set any parameters, as Decimate drops 1 in 5 frames by default. Make sure you preview your

video to see if there are any problems. Once again, if you end up with video that doesn't look right, refer to the Decomb tutorial for more help.

Deinterlacing
If you have an interlaced source, but want progressive output, and your source isn't telecined, you need to deinterlace. This section will describe 2 different ways to deinterlace, but there are many different ways to do it. Depending on the source material, the destination format, your viewing equipment, and your personal preferences you'll get better results from one or the other, or you may prefer a different approach altogether.

Discarding Fields
One option is to simply remove every other field. This will leave you with frames that are half the height of the original video, so you'll need to resize after discarding fields. This can be a useful approach if your final format will be half the height of your source like converting a 720x480 video into VCD (or a VCD resolution DVD), because AviSynth doesn't have to add information that's not in the original source. On the other hand, you may lose important details that were only in the fields you removed. Add the SeparateFields filter from the interlaced category and then either SelectEven or SelectOdd from the Editing category.

Bobbing

This will usually give you the best quality for deinterlaced video. Like the previous method, bobbing starts by separating fields, but then each field is changed to a full-size frame by filling in either the even or odd lines, depending on whether it was originally a top or bottom field. You can also use this method to create double framerate or slow motion video. Make sure you have the DGBob plugin for this operation. You'll also need to know the field order of your video. This can be done using Core filters from the Interlaced category. Add AssumeTFF and SeparateFields to your script and preview it. Navigate through the preview until you find a section where something moves either left to right or right to left across the screen and step through several frames, one frame at a time. If the object moves backwards in every other frame, the field order is BFF. If the movement looks correct it's TFF.

Add the DGBob filter from the ??? category. There are 2 parameters you need to set order and mode. Set the order parameter to 0 if your video is BFF or 1 if it's TFF. You must set the order because there is no default value. If you want video with a doubled framerate (59.94 fields per second becomes 59.94 frames per second) you don't need to change the mode. If you want to maintain a standard video framerate (59.94 fields per second becomes 29.97 frames per second by dropping every other frame) set the mode parameter to 0. If you want slow motion video (59.94 fields per second becomes 29.97 frames per second but no frames are dropped) set the mode to 2.

Getting help
Clicking Content on the Help menu or clicking the help icon on the toolbar will open the AviSynth Manual. It's a good idea to read as much of the manual as possible to understand how AviSynth works. There are sections about general AviSynth useage, Core Filters, and External Filters that give basic instructions for scripting. You can look at the AviSynth Editor section for AVSEdit specific help, and it's also a good idea to read through the FAQ for help loading your script in another application like an encoder. If you are looking for help with a specific filter, highlight the filter in your script and click the Help button at the bottom of the Parameters tab. That will open the help file for the selected filter.

Still have questions?


If you can't figure out how to use a filter, post a question on our discussion forums. Using AviSynth isn't as hard as you probably think, and there are a lot of people ready to answer your questions. Above all, don't be afraid to try it out first.

Anda mungkin juga menyukai