I capture and process a lot of tv programming for later viewing. I'd like to automate the process more so that I'm spending less time processing them and more time enjoying them. My captures usually have a couple of garbage scan lines at the top, so I use the AviSynth feature in ffdshow to remove them before they get passed into AutoGK, like this:
The reason I keep the black pixels around the top and sides is so that the final video will be positioned correctly on my tv when I view it (just the way it came over the cable). I realize AGK usually resizes the video smaller, but once my DVD player sizes it back up, it should fit the screen just right. For widescreen programming, I use:
I don't add back the black bars at top and bottom because a)it allows for lower compression and higher quality and b) the DVD player centers the video anyway, so I'm not missing anything, even if it isn't positioned exactly the way it was on the original airing. Of course, not every capture falls neatly into one of these two categories, so I inspect every one and adjust the script as necessary before I AGK it, which brings me to my question.
Does anyone know a way, using Avisynth to automatically detect the number of garbage and/or black pixels at the edges and process them accordingly? This would allow me to use a single script for all of my videos and not have to inspect every one and adjust accordingly.
Another concern relating to my script, though not as big of a concern to me, is that AGK does color correction, and I'm afraid that after using AddBorders (which adds pure black), the black level correction will not be as good as it could be. Is AGK smart enough not to consider edge pixels when doing the color correction? Is there a way in Avisynth to detect the level of the darkest shadow in the frame and add borders of that color instead of pure black?
+ Reply to Thread
Results 1 to 5 of 5
Don't know of anything. Maybe try a few things with:
FillMargins(8,2,12,0) # (left, top, right, bottom)
instead of crop/addborders.
FillMargins(12,4,16,0) will give some leeway & cost you a few pixels, but will you ever notice?
Filter is, probably, already on your PC. Or here. http://avisynth.org/warpenterprises/
Yeah, I don't know of any way either, for AutoGK or anything else to detect garbage pixels and automatically crop them off. As for detecting and cropping black, AutoGK's AutoCrop does a decent job:
You don't have to worry about black levels for the color correction. It uses ColorMatrix and is just doing a BT.709 to BT.601 conversion when necessary. You can read about it here:
and an in-depth discussion here:
Or download the ColorMatrix filter and read the docs.
As mentioned, Autocrop will do a good job of detecting black.
But 'garbage" is a lot harder to define, I think.
If you use AvsP, it has a crop editor that might be useful.
You drag the borders, then it inserts the crop line in your script.
You could probably write a macro to do the matching AddBorders.
If you ask in the Doom9 forum, someone might even do that for you.
I played around with writing a script to do this automatically, but it was, shall we say computationally expensive. Those of you who know more about AviSynth and the available filters, please don't laugh at me, but I was cutting the video into two equal length clips and using layer() to combine them. I did this repeatedly, until the resulting clip was one frame long. This was so the levels in the frame would be representative of the levels in the full length video over all. My plan was to crop down to key areas of the frame and use AverageLuma etc to take appropriate action conditionally, but I never figured out how to use AverageLuma. Every time I tried, I got the error message "I don't know what 'AverageLuma' means."
EDIT: I'd rather not use AGK's autocrop because there's no way to tell it to crop in only one dimension instead of both. Plus there's pretty consistently garbage in the first couple scan lines of my captures that would throw it off anyway.