Stabilization Tools Pack v1.7
I developed a set of tools to work with common stabilization issues, mainly from telecine process.
For aggressive handheld camera shaking I still recommend vdub's Deshaker.
First there is FilmGateFix() which is very straight forward although the least out-of-the-box experience from the pack.
I set defaults to my needs and although very conservative worked quite well. It's still open to suggestions and somewhat experimental. This function does 2 assumptions. That after a scene change the worst film gate frame is the second, and the third frame is stable. And two, that the source is cel animation based since simple freezeframe() filters are being used.
The function can be expanded in the future with frame interpolation for live footage, and refactored settings for better results. Test and share your experience, don't forget to upload a chunk of the source so I can check.
The other two tools are related mainly to stab(). This is my main stabilization filter because it's very production friendly; works fine in one pass without too much parameter tweaking.
As all deshakers go there is one main problem, mismatches. This generally creates black borders around the source frames to compensate for the stabilization, for that in stab() you can use the "mirror" parameter, something like mirror=15 will do the job, this can be called the "patchy" method. It won't fix the huge (over 5px) stabilization mismatches specially problematic in tilts and pans. This method requires you to go through the whole source and check carefully where stab() failed, sometimes not as evident as we used the mirror edge filling feature.
A nicer more passive method was in need so I made the next two functions. After Stab() without the use of the mirror option I recommend to crop by at least 2 pixels on all sides, then we apply a pass of the new filter FillBorders(). This will fill dark borders with adjacent content, it uses AVSInpaint plugin hence results are much nicer than simple mirror filling. This filter will also work with retail sources that present random black borders, by using the "thr" setting you can tell how dark it must be to be validated as a border. Do tweaks while in debug mode.
RAW........................................ ... FillBlackLines().............................. FillBorders()
The previous FillBorders() will work with black borders up to 3px, let's call this false positives because they are inherent stabilization borders we decided to fill rather than crop. After that threshold of 3px (plus 2px previously cropped) we are still left with some thick borders result of serious stab() mismatches, the better approach here is to trim out the whole scene. To avoid the tedious process of carefully rewatching the film/episode from start to finish, I created a second function, FindBlackBorders(). This will detect if any of the borders present a black or "thr" defined border and report to a statistics file. Meanwhile it will output the input clip untouched so you can do two things at the same time, render a preview clip to check stab() mismatches, and WriteFile border statistics to a file. This comes handy with very heavy filters or long episodic series.
So far our script looks like this:
# stabilization pass
# Crop some border garbage
Crop(2, 2, -2, -2)
# Clean stab() garbage a bit further (up to 3px)
# Now we have a clean slate to detect big stab() mismatches
FindBlackBorders(path="C:\") # output statistics for ClipClop
# For debug purposes you can test results of FilmGateFix() if you want
# Output to half the size for debugging doing trims with ClipClop
# Encode with x264 fast presets
With the rendered output clip (now with most borders already cleaned) we load it in avspmod
and load as well the statistics file using the Macro "Import Bookmarks from File".
Now all we need to do is use F3 to jump through all bookmarks and manually trim out problematic scenes, hopefully saving us a few precious hours and eye health issues.
For the trims I like using ClipClop() by StainlessS. After we finished, we replace our FindBlackBorders() line with the new ClipClop() one and render our main script.
unstab=Crop(2, 2, -2, -2)
Crop(2, 2, -2, -2)
# recover problematic scenes from the unstab variable
# also those from FilmGateFix(), although by default it's very conservative
v1.7 - Refactored FindBlackBorders() again for TRUE border detection
v1.6 - Refactored FindBlackBorders() a bit and fixed some bugs along
- Small ternary change in FillBorders()
v1.5 - Documentation fix (InpaintLogo is spatial, Average.dll thread link)
- Overall script cleaning and reformat
- Fixed a mod crop issue in FilmGateFix()
- In FilmGateFix() swapped mt_lutspa() with PadInwards() (custom helper function)
- Huge overhaul and optimization of FillBorders()
v1.0 - Initial release
|How / Where to Download the Files? You'll find the attached file downloads at the bottom of this top post. Files are provided for the convenience of our members. To get download access, simply join the forum as either a Free Member or Premium Member. We don't send spam or sell your email addresses. If you're not sure what to do with .zip or .rar files, see this help post.|