Difference between revisions of "AviSynth"
From SDA Knowledge Base
Ballofsnow (Talk | contribs) |
Ballofsnow (Talk | contribs) (→Part 1: Loading the plugins) |
||
Line 29: | Line 29: | ||
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\ac3source.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\mpasource.dll") | ||
− | |||
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\Warpsharp.dll") | LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\Warpsharp.dll") | ||
</nowiki></pre> | </nowiki></pre> |
Revision as of 19:12, 31 August 2006
Contents
- 1 Introduction
- 2 Installation / plugins
- 3 The avisynth script
- 3.1 Part 1: Loading the plugins
- 3.2 Part 2: Loading the source files
- 3.3 Part 3: Fixing audio delay
- 3.4 Part 4: Appending
- 3.5 Part 5: Deinterlacing / Full framerate video
- 3.6 Part 6: Trimming
- 3.7 Part 7: Resizing
- 3.8 Part 8: Cropping / Adding borders
- 3.9 Part 9: Color / Brightness
- 3.10 Part 10: SDA StatID
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\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)
- 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.
Tip: If your video is separated in multiple parts, which is usually the case when recording with Fraps, then be sure to look at part 4 since it is linked to part 2.
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"),"vob DELAY -66ms.ac3") DelayAudio(-0.066)
Ac3Source(MPEG2source("vob.d2v"),"vob 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
One of the best features of avisynth is its ability to do an aligned splice when appending video. There is usually a mismatch between the length of the video and the length of the audio, typically ranging from -50 ms to +50 ms. This means that appending files in VirtualDub(Mod) will in almost all cases cause a desync because the audio of clip2 will be appended right after clip1. VirtualDub(Mod) is unable to do an aligned splice. Here is an illustration:
You will probably never use UnalignedSplice. Here are different methods for using AlignedSplice:
### Method 1 AlignedSplice(avisource("clip1.avi"), avisource("clip2.avi"), avisource("clip3.avi")) ### Method 2 a = avisource("clip1.avi") b = avisource("clip2.avi") c = avisource("clip3.avi") AlignedSplice(a,b,c) ### Method 3 avisource("clip1.avi")++avisource("clip2.avi")++avisource("clip3.avi")) Ac3Source(MPEG2source("vob1.d2v"),"vob1 DELAY -66ms.ac3").DelayAudio(-0.066)++Ac3Source(MPEG2source("vob2.d2v"),"vob2 DELAY -30ms.ac3").DelayAudio(-0.030) ### Method 4 import("script1.avs")++import("script2.avs")++import("script3.avs")
Method 2 is good for when you're joining a lot of clips since it's easier to edit. Notice the double plus signs in method 3, this is the same as AlignedSplice. One plus sign would indicate UnalignedSplice. Method 4 is to join independent avisynth scripts.
Part 5: Deinterlacing / Full framerate video
You can skip this section if you used Fraps/Camtasia to record a computer game, or if your console game outputs in progressive mode and you captured in progressive mode as well. Otherwise, if you're footage looks anything like this with the horizontal lines, then you definitely need to deinterlace.
Avisynth will help you restore the full range of motion to your video. Capturing at 320 x 240 without Avisynth, as most people do, would cause you to lose half of your motion information.
Tip: You should create separate avisynth scripts for each quality version that has differences between them. There's no sense in creating one avisynth script, encoding it, editing the script, encoding again, etc. With separate avisynth scripts you'll get less script errors, less headaches, and you'll be able to queue many encodes.
Half framerate - 25 fps (PAL), 29.97 fps (NTSC)
- DivX - Low Quality
- DivX - Medium Quality
- H.264 - Low Quality
This is the easiest kind of deinterlacing. You barely even have to think about it. Looking at the picture above, notice all the individual horizontal lines. These show the fields. Every even numbered line is one field, while every odd numbered line is the other field. With half framerate we simply remove one of the fields. This reduces the height of the video by half, we'll take care of the width later on when resizing.
Use the following code:
separatefields() selecteven()
Full framerate - 50 fps (PAL), 59.94 fps (NTSC)
- Everything else. Yes, SDA now allows full framerate for H.264 Medium Quality.