The big problems with badly degraded video are the extra filtering and the processing time they consume. Then there is the fact that the results can't look as good as a source that's more or less intact to begin with. A lot of damage just can't be repaired. On other hand, even a so-called "clean" analog source still needs some work, and one still needs a toolbox of effective filters to get improved results. The difference between a poor source and a good source is the vast difference in the quality of the results.
Below are script and filter details for the script in the preceding post:
It happens that the MDG2 plugin is a script-coded .avs file. Avisynth plugins come in three formats: .dll
, and .avs
. A .dll and an .avsi plugin load automatically when a script calls for them. An .avs is a plain text file whose coded text must be explicitly imported into your script using the Import()
function. You could also copy the text yourself into the bottom of your script, but it's a pain and some of the .avs filters have hundreds of lines of code.
function open and decodes many video codecs if the codec is installed on your PC. Once decoded, the file as AVisynth delivers it is uncompressed. If you want compressed output, you'll have to recompreess it yourself, for instance by telling VirtualDub
to do it.
is a multi-faceted builtin function that works on contrast, gamma, high end extension, black levels, and so forth. Its wiki page gives you a whole catalog of things it can adjust. Here, it's used to lower contrast. There are different kinds of contrast controls; with ColorYUV, contrast expands pixel values (luminance) from the center outward in each direction or, with negative values it shrinks pixel values toward the middle. Because a histogram showed luminance extending outside safe values at both ends of the dark-to-bright spectrum, cont_y
was used to shrink the response curve toward the middle of the spectrum. As you can guess by its name, it works only in YUV colorspaces.
The builtin Levels()
function works on luminance pixel values and on gamma (midtone response). Here, it adjusts luminance levels to stay within the range y=16-235. RGB display will expand YUV from 16-235 to 0-255. If the YUV range is already darker than 16 or brighter than 235, an RGB display or process will destroy the out of range values (aka "clipping"). The numbers in the Levels()
command indicate the following values, in this order: input dark values, desired gamma, input bright values, desired dark output adjust, desired bright output adjust. Dither
are explained on the Levels() wiki page (http://avisynth.nl/index.php/Levels
) adjust saturation in the YUV color range shown by the numbers in the startHue and endhue values. The numbers reflect the positions of colors in degrees around the YUV color wheel:
The images below are YUV vectorscopes that display measured saturation values. The vectorscope on the left shows the original saturation pattern before filtering. The pattern indicates an oversupply of saturation in the blue-cyan and green-yellow areas, and a deficit in red. The vectorscope on the right shows the more evenly balanced result of the Tweak and ColorYUV statements with reduced blue-cyan/yellow levels and more populated reds.
CNR2(mode="ooo", scdthr=255.0, ln=255, lm=222, un=255, um=255, vn=255, vm=255)
Avisynth's default field order priority for interlaced or telecined video is Bottom Field First (BFF). But most of the time you'll encounter Top Field First (TFF). AssumeTFF()
informs Avisynth that the current video's field order is TFF. Then, SeparateFields()
breaks apart each interlaced frame into its two half-height image fields. This is a non-destructive form of deinterlace, which will be required by the Avisynth filters that immediately follow.
go after edge halos and ghosting on right and left edges respectively. These two filters aren't enough to completely fix the ugly edge halos in the clip, and in fact will simply soften edge halos a bit -- which is what is desired here because of the over-sharpened halos themselves. The numeric values in the syntax for the two FixVHSOversharp commands are explained in the help file that comes with the filter and are actually copied from the documented samples. FixVHSOversharp works only in a YUY2 colorspace.
is a chroma filter that helps neutralize color streaks and blotches. The values that follow the CNR2 command are actually defaults except for "mode="ooo
" which activates a "wide" disturbance detection for Y (luma), U (yellow-blue), and V (red-green) channels. The scdthr
, and vm
set luminance and chroma filtering limits for scene changes, luma, U, and V channels. The numbers shown are defaults except for the "222" which tends to reflect an average peak value for luminance "hot spots" in VHS video. You could probably use all values at default 255 with no problems.
is at http://www.digitalfaq.com/forum/atta...d-cnr2_v261zip
is the function that puts all the separated fields back into their original order and position in the interlaced frames. http://avisynth.nl/index.php/Weave
Your sample clip used YUY2 color, preferred because it's more like the YPbPr color in VHS, but the filters that follow require YV12 color. Leave these conversions to Avisynth, which does it with great precision (many editors make a mess of YV12 conversions). For any colorspace conversion you must tell Avisynth whether or not the video is interlaced. Note that telecined video, the conversion of film speed to 29.97fps by inserted qdditional fields, is considered a form of interlace. Other conversion function parameters can be used, but usually you'll just ignore them and use defaults.
you come to one of the heavy-hitters. This is a deinterlacer. In using complex motion-compensated algorithms and additional support filters to deinterlace as cleanly as possible (something most deinterlacers don't
do), one side effect of QTGMC is that it also denoises in several ways. It reduces grain, cleans edges, and smooths uneven motion to a certain extent. The preset="medium"
parameter sets up a reasonably efficient denoising level (there are faster presets and slower ones). FPSdivisor=2
is a special parameter that discards alternate fields and maintains the original 29.97fps framerate. This is a decision you'll have to make: field decimation can make for less smooth motion that interlaced or double-rate video. If you retained all fields, interlacing would play at 59.94 fields
per second. if you double-rate interlace, the video would play at 59.94 frames
per second. But there's not that much motion in your clip. Sports video would be a different story. I decided to discard fields because of all the interlace damage and noise inflicted on this tape. The normal way would be to retain all fields, run special filters to calm buzzing edges and combing, and re-interlace after filtering -- but with this damaged video the edge noise and excessive combing would be intolerable.
The extra cleanup parameters that are activated in the QTGMC statement are ChromaMotion
(consider chroma, not just luma, when analyzing motion), border
(pad a little vertically to avoid top or bottom border flutter), ChromaNoise
(clean color noise as well as luma noise (grain)), Grainrestore
(restore a very small amount of original grain to avoid a plastic over-filtered look), and reduce Sharpness
a little so sharpened halos won't look worse.
QTGMC and its pile of support files and extra filters come as a 32-bit package. The .zip file contains all updates as of November 2017 (subsequent updates require a different version of QTGMC that you won't need for a long while, if ever). Most of the support files are popular standalone filters in their own right. The .zip also has links to required Microsoft VisualC++ runtimes if you don't have them. There are quick read-me files in the zip, as well as all of the original documentation that comes with the support files. READ the READ-ME's first! Ignore them at your peril. The3 complete QTGMC .zip package and all its subfolders is at:
is a packaged version of the MDegrain2 function that comes with MVTools2.dll. It's a degrainer that also helps to smooth buzzy edges. It requires MVTools2, which comes with QTGMC. it also requires aWarpSharp.dll (see remarks, 2 paragraphs below).
is another color and stain cleaner. You have to tell it whether or not your video is interlaced. At this point in the script, your video isn't interlaced. You can get Bifrost_v2.zip at http://www.digitalfaq.com/forum/atta...-bifrost_v2zip
combines the results of chroma-only sharpening with luma from previous statements. In short, this tells aWarpSharp2 to sharpen only the color channels, not the luma channel, because luma is already oversharpened. This tends to "tighten" colors closer around the edges they belong to. It won't clean up the chroma smearing mess entirely, but it helps. Get aWarpSharp2_2015.zip at
. It also requires the Microsoft VisualC++ runtime 2013 (which you will need for some other filters later), and you can get it at http://www.microsoft.com/en-us/downl....aspx?id=40784
is an old standby used by dozens of more complex filters. It adds a small amount of very fine film-like grain to mask hard macroblock edges and to avoid an over-filtered or posterized look. AddGrainC.dll and the 2012 VisualC++ runtime installs with the QTGMC package. Or get AddGrainC and the 2012 runtime separately at http://avisynth.nl/index.php/AddGrainC
These two commands remove unwanted border pixels and replace them with new black ones. Crop()
removes edge pixels in this order: 4 left border pixels, zero top border pixels, zero right border pixels, and 12 bottom border pixels. The bottom pixels are head-switching noise. Cropping might seem simple, but there are very stringent rules. You can see the rules in a small grid near the bottom of Crop's wiki page, linked below. Next, AddBorders()
gives you brand-new black border pixels in the same order processing order but it attempts to center the original image in the frame: add 2 left border pixels, 6 top border pixels, 2 right border pixels, and 6 bottom border pixels. The default border color is black but you can choose many other colors.
is another colorspace conversion, this time for use by the VirtualDub
filters that will be applied to the script's output. As usual, you must tell conversion functions whether or not your video is interlaced (at this point, it isn't) -- not making this clear can screw up your colors. The color matrix used for standard definition video is "Rec601", which is a flavor of RGB that VirtualDub will use. VirtualDub filters run in RGB color. if you don't make the conversion here, VirtualDub will do it when you load its filters. But Avisynth can usually do it more cleanly.
Without this conversion, your output at the end of this script is YV12 color. If you want to save the script as YV12 at this point, you'll need a lossless compressor other than huffyuv
, which can't compress YV12. I suggest Lagarith, since it's mainstreamn, recognized by media players and editors, and makes slightly smaller files than huffyuv
. Here's Lagarith's link again: https://lags.leetcode.net/codec.html
Using the Virtualdub filters:
The Avisynth script makes some initial levels and color corrections in YUV color. These were basic adjustments that are easier in the original colorspace, and are often not possible after conversion to other color systems. This particular video sample required work in the saturation department that would have been difficult in other software. Fortunately most videos don't require a bunch of Tweak statements as tricky as those used in the script.
After the basic corrections in YUV, color controls in VirtualDub can tweak the results and target certain areas more specifically. Shadows in bright objects still looked a little blue-green (those would be the midtone range centered at about RGB 128 in the middle of the spectrum). Flesh tones weren't quite right (rather orange-y, often grayed out, and very badly smeared), so adding a little warmth with Colormill and reducing cyan with gradation curves helped somewhat.
The image below shows the Red, Green, and Blue adjustment panes in the Gradation Curve plugin, as used in processing the sample clip.
Red is at the far left. The diagonal line for Red is curved upward, which increases the brightness of reds from the darkest values (at the bottom) to the brightest vales (at the top). There's a kink in the curve near the top of Red's vertical line intended to calm a slight red peak in the brighter reds. In the Green and Blue panes, both colors are lowered slightly across most of the range, but Green are lowered a little more at the high end to correct whites that were too green, and both Green and Blue vertical lines are raised somewhat in the darks (at the bottom) to correct darker colors that were too red. The curves plugin is similar to curves in Adobe Photoshop, Premiere Pro, and other high-end apps. Its .zip package comes with documentation.
The adjustments needed to correct whites, grays, and other areas of the spectrum were determined by using the Csamp
pixel reader to analyze pixels that were supposed to be whites, grays, or blacks. the RGB values shown by Csamp would indicate why those pixel colors were "off'. If a supposedly white pixel measured R185 G210 B213, it would indicate that those pixels didn't look white because there was too much green and blue and not enough red. So the bright colors would be manipulated to make Red, Green and Blue have similar values such as R200, G200 B200. Those values would equal white with about the same brightness as before.
The filters and settings ultimately used were saved in the .vcf file attached to the preceding post.
Speeding up Avisynth scripts for testing VirtualDub filters:
If you're running a script in VirtualDub and adding VDub filters at the same time, a slow Avisynth script can make scrolling thru the video very difficult while trying to adjust filters. Plugins like QTGMC can be very slow at certan settings and with very noisy video. You can temporarily make the script run faster if you comment-out some statements to prevent their execution. For example you can use Avisynth's comment in this statement:
and change it into this statement, which prevents QTGMC fromn running:
Any text that follows the cross-hatch or pound character (#) is converted to a comment, which is ignored by Avisynth. After making this change, in VirtualDub hit the F2 key (or click "File..." -> "Reopen video file") to reload the script at the point where you stopped scrolling. And don't forget to remove the comment marks when you're ready to save the file!
All I can add at this point is that I hope your other videos are in much better shape. If you wish you can submit a better sample from a workout tape to see how much better things can look.