AvsPmod Graphical Interface
I'm not sure if I clearly conveyed this above but AvsPmod is completely optional, it just helps with tweaking the filter and plugin arguments. Each plugin and function in the script has a graphical interface that allows arguments to be adjusted and previewed in real time:
The preview video can be updated by just left clicking on it after making changes to the script. AvsPmod also has a call tips which show as you open the "(" in a function. They can also be shown by right clicking with the cursor on the function -> "AviSynth Function" -> "Show calltip"
Clicking "Filter Help File" in the "AviSynth Function" menu does a google search for avisynth and the function name. This can be useful to view the documentation on the functions you are using. The "Show Function Definition" button opens the function definitions window where it shows the arguments and default values of that function. The window below that is "add or override AviSynth functions in the database" where it shows:
Core Filters | Internal AviSynth Functions |
Plugins | Filters located in the plugins(+) folder with dll extension |
User Functions | Filters in plugins(+) folder wit avsi extension |
Script Functions | Utility functions to perform operations in scripts |
Clip Properties | Built-in variables that are available, i.e. framecount |
Let's look at the BlankClip function defition:
Code:
(
[clip "clip"],
int "length"=240,
int "width"=640,
int "height"=480,
string "pixel_type"="RGB32" ("RGB32"/ "RGB24"/ "YUY2"/ "YV24"/ "YV16"/ "YV12"/ "YV411"/ "Y8"),
float "fps"=24,
int "fps_denominator"=1,
int "audio_rate"=44100,
[bool "stereo"=False],
[bool "sixteen_bit"=True],
int "channels"=1,
string "sample_type"="16bit" ("8bit"/ "16bit"/ "24bit"/ "32bit"/ "float"),
int "color"=$000000,
[int "color_yuv"]
)
The word before each argument is the type of value that can be passed to the argument. "int" refers to integer but can also be hex. Suprisingly "string" expects a string to be passed. The string must be in double quotation marks. "bool" or boolean can be True or False. Float can be a whole number or decimal. The square brackets around the argument mean that it is implicitly set, such as in clip. If the argument has a value defined, "length"=240, that is the default value if you do not set the argument when calling the function. There can also be a list of expected values, "sample_type"="16bit" ("8bit"/ "16bit"/ "24bit"/ "32bit"/ "float") where you can only pass those values in parenthesis to that argument.
If for some reason AvsPmod is not working correctly,
VirtualDub can preview changes almost as easily. After you save your script as an "avs" file open with
VirtualDub. After each change is saved to the script, File-> Reopen Video will load the changes while keeping filters and settings in VirtualDub intact.
Color Spaces - YUV, RGB, WTF?
There are extensive resources on the net and posts in this forum that dive into the details of color spaces but I will give a 10,000 foot overview. Color spaces are the format in which color and brightness is encoded in the video. The format or compression codec (mpeg, mp4, avi, etc.) does not indicate the color space of the file. Hopefully, you know what color space the video is in since you captured it but just in case you can use
MediaInfo. MediaInfo is a great tool that shows the color space, format, resolution and many other properties of a video. For now we will focus on just color space.
Color spaces are important because each color space allows different adjustments to be made to your video. Also, converting between color spaces is not ideal because the math involved causes rounding errors, eliminating some color information and degrading the quality. This is not a major issue but just something you should be aware of when working with your video. The function or software used to convert color spaces also impacts the quality degradation due to decimal precision. Avisynth is the preferred methods of converting between YUV and RGB.
RGB - Red, Green, Blue
RGB (Red, Green, Blue) is the most commonly known color space. It defines the color of the video by adding together amounts of red, green and blue light. Controlling the intensity of each color, controls the output color. For example, zero intensity is the darkest of each color making black and the highest intensity of all three colors making white.
Adjusting the R, G, B levels provide millions of different hue, saturation and lightness shades. The bit depth of an RGB video defines the amount of different combinations of red, green and blue. A 24bit RGB video provide 8bits per channel which allow values of 0-255 for each channel. RGB32 is a 32bit RGB video that has an extra alpha or greyscale layer of you guessed it 8bits, that provides additional shading control. RGB32 is most commonly used when working with video on a PC because processors can more efficiently handle it, even if the alpha layer contains no data (which is definitely the case if converting from YUV).
The primary ideas to remember when it comes to RGB is it results in a much larger file size than YUV but allows you to target specific colors more easily. As a result, conversion to RGB is typically an intermediate step used for VirtualDub filters and color correction.
YUV
YUV or YCbCr is the most common color space of broadcast television due to the human perception of color. The color information is broken up into one luma channel (brightness) and two chrominance (color) channels. Adjusting the "Y" or luma, can change the brightness levels of the video without altering the color data. Targeting specific colors is more difficult but shifting from green to red and yellow to blue can be done with ease by targeting the V and U channels, respectively.
Chroma Subsampling
The UV channels of the YUV color space contain the color information. The efficiency of YUV over RGB is the ability to discard some of the chroma or color information without impacting the human perception of the video. You may see YUV 4:4:4, YUV 4:2:2 and YUV 4:2:0. Going from YUV 4:4:4 to YUV 4:2:2 cuts the chroma data in half, resulting in a video with one third of the bandwidth but no perceptional difference while viewing the video. To complicate things further, each YUV color space can be arranged differently as in packed or planar formats.
There's no need to get too deep into the math behind this, just to be aware of the way different color spaces hold data. Most captures should be in YUY2, which is just a specific way of encoding YUV 4:2:2. There's no need to move up to 4:4:4 because most VHS players output 4:2:2 or 4:2:0, so to the additional chroma data would just be interpolated and there would be no added benefit for the larger file size.
Another consideration between YV12 and YUY2 is the speed of AviSynth filters. As I mentioned before some filters can use YV12, YUY2 or both. Typically when a filter can use both, YV12 will be faster if speed becomes an issue.
Another common format is YV12 which is a way of storing YUV 4:2:0. YV12 is used by many video formats such as MPEG-4 (x264, XviD, DivX, etc.), MPEG-2 for DVD's and MPEG-1.
What does it all mean?
The main point's to consider with color spaces are file size, speed (of filters), quality and purpose. If you have an old video that you need to perform heavy restoration and color correction on, YUY2 is usually the recommended capture format to maximize the availability of color data. However, after capture you must also consider what you need to "do" to the videos.
Certain AviSynth filters only work in YUY2 or YV12 formats, so there should be a strategy to avoid unnecessary conversions. Capturing in RGB is usually not recommended due to the large file size and the likely conversion you'll have to make to work in AviSynth. The larger file size does not mean improved quality either, television or VHS output is in YUV. If someone know's a reason to capture with RGB, please post a comment.
However, if you are not making many corrections or changes and plan to burn to a DVD, YV12 might be sufficient to capture in. For more information on color spaces read
AviSynth's Color Spaces Wiki Page and good ol' google
A workflow might be Capture YUY2 -> Process in AviSynth YUY2 & YV12
For further color correction convert to RGB32 in AviSynth -> VirtualDub or NLE
If burning to DVD, you can leave in YV12 and use a DVD encoding tool to convert to MPEG. This is discussed ad nauseum by Lordsmurf in many of his guides such as this one
Introduction to Video Encoding/Converting, Part 1.
An important thing to remember is the software doing the conversion has a noticeable impact on quality. It's better to convert between YUY2, YV12 and RGB in AviSynth due to the high precision of the math being done behind the scenes. I've read that VirtualDub does not handle the conversion to RGB that well so converting to RGB in AviSynth will be better than allowing virtualdub or another editor to do it.
Another note on VirtualDUb is that it is an RGB video processor, meaning any filters being used will automatically convert the video to RGB and then to whatever format your output is. That is unless you have direct stream copy selected, which will output in the format that's input.
More to come.....
If I got anything wrong or there's any incorrect information, please correct me :