AviSynth

From SDA Knowledge Base

Revision as of 14:43, 25 August 2006 by Ballofsnow (Talk | contribs)

Jump to: navigation, search

Introduction

Avisynth rocks my socks.


Installation / plugins

Go to http://www.avisynth.org/ and download the latest non-alpha version of Avisynth. It is currently at 2.5.6a. Install the program.

With Avisynth installed, go to Start menu -> [All] Programs -> Avisynth -> Plugin Directory. This will open the directory where Avisynth stores its plugins. Copy the files from inside the avisynth plugins zip file to the avisynth plugins directory window you just opened.


The avisynth script

The work folder for this guide is "C:\video processing\" where all source files are located.

Create a .txt document with a name of your choice. Rename the extension from .txt to .avs. If you can't see the extension and are running in Windows, open Windows Explorer, go to Tools -> Folder Options -> View and uncheck "Hide extensions for known filetypes".

Open the avs file in Notepad or any text editor.


Part 1: Loading the plugins

Depending on what kind of source material you have, there will be some plugins you don't use. It doesn't hurt to load them though. Mvbob's extension is .avsi so it will automatically be loaded. Copy the following code into the avs file. Change the file paths if needed.

Loadplugin("C:\Program Files\DGMPGDec\DGDecode.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\LeakKernelDeint.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\ac3source.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\mpasource.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\ac3source.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\Warpsharp.dll")

Part 2: Loading the source files

There are different ways to load the source files and it all depends on what it is you're working with. Here is a list of available commands.

  • avisource(video.avi)
  • directshowsource(video.avi)
  • MPEG2source(video.d2v)
  • Ac3source(video, sound.ac3)
  • Wavsource(sound.wav)
  • Mpasource(sound.mpa)
  • AudioDub(video, sound)


Advanced tip: You don't need to include the whole file path, as long as you keep the avs file in the same folder as the source files.


If you used a capture card or screen capture software then it is quite simple to load the files. If avisource does not work, try directshowsource. Those using Camtasia will probably need to use the latter.

### Video and audio are already combined
avisource("C:\video processing\video.avi")

### Video and audio are split
#AudioDub(avisource("C:\video processing\video.avi"), wavsource("C:\video processing\audio.wav"))

Notice the # before AudioDub. This is telling avisynth to skip over the line. If you need to use this line, remove the # and add one before the first avisource command.


If you used a DVD recorder then your video and audio is most likely split. Make sure you've gone over the DVD page before continuing.

AC3source(MPEG2source("C:video processing\vob.d2v"),"C:\video processing\vob T01 2_0ch 192Kbps DELAY -66ms.ac3")
#AudioDub(MPEG2source("C:video processing\vob.d2v"),MPASource("C:\video processing\vob T01 2_0ch 192Kbps DELAY -66ms.mpa")) 

I hope you haven't removed the delay information from the sound files. Not that it's the end of the world if you did remove it, you'll just have to listen by ear until you get a close value with DelayAudio().


Part 3: Fixing audio delay

This will only work if the audio desync is constant and not progressive. Constant desync is when the desync at the beginning of the video is the same as the desync at the end of the video. You guessed right, it's easy to fix. Progressive desync, on the other hand, can be a huge pain and may require external tools to fix.

The DelayAudio command is straightforward, but there is an extra concept worth learning. Look at the following two scripts:

Ac3Source(MPEG2source("vob.d2v"),"vob1 DELAY -66ms.ac3")
DelayAudio(-0.066)
Ac3Source(MPEG2source("vob.d2v"),"vob1 DELAY -66ms.ac3").DelayAudio(-0.066)

Is there a difference between them? Yes and no. They both get the same result, however the script with one line makes it easier for projects where you append files together. I suggest using the format of the second script.


Part 4: Appending

Personal tools