digitalFAQ.com Forum

digitalFAQ.com Forum (https://www.digitalfaq.com/forum/)
-   Restore, Filter, Improve Quality (https://www.digitalfaq.com/forum/video-restore/)
-   -   Stabilization Tools Pack v1.7 for Avisynth [DOWNLOAD] (https://www.digitalfaq.com/forum/video-restore/6510-stabilization-tools-pack.html)

Dogway 04-26-2015 01:25 PM

Stabilization Tools Pack v1.7 for Avisynth [DOWNLOAD]
 
1 Attachment(s)
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.


FilmGateFix()

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.


FillBorders()

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()
http://www.digitalfaq.com/forum/imag...90iOqS0t-1.png...........http://www.digitalfaq.com/forum/imag...ITIpE5yt-1.png...........http://www.digitalfaq.com/forum/imag...hS9Og6It-1.png


FindBlackBorders()

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.


Examples:

So far our script looks like this:

First/Debug Pass
Code:

# stabilization pass
stab(ts=7,range=5,dxmax=15,dymax=15)

# Crop some border garbage
Crop(2, 2, -2, -2)

# Clean stab() garbage a bit further (up to 3px)
FillBorders(debug=false)

# 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
FilmGateFix(debug=false)

# Output to half the size for debugging doing trims with ClipClop
RatioResize(0.5,"%")

# 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.

Second/Final Pass
Code:

unstab=Crop(2, 2, -2, -2)
stab(ts=7,range=5,dxmax=15,dymax=15)
Crop(2, 2, -2, -2)

FillBorders(debug=false)
FilmGateFix(debug=false)

# recover problematic scenes from the unstab variable
# also those from FilmGateFix(), although by default it's very conservative
ClipClop(unstab,SCmd="1(20000,30000);1(80000,100000)")


Changelog:
Code:

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.

lordsmurf 04-26-2015 10:59 PM

Remember to attach files to the forum. External links too often disappear, are subjected to malware, etc.
And anytime you have updates or new versions, just attach those in a reply, and we'll get it sorted for you (added to original post, etc).

Dogway 04-27-2015 08:17 AM

If I attach the file outsiders can't download the script. I want everyone to use my tools without constraints, is it possible to add both options?

lordsmurf 04-27-2015 09:29 AM

All anybody has to do is register for the forum.
But sure, you can do both. At minimum, however, it needs to be attached for longevity.

Dogway 04-27-2015 07:02 PM

Can I edit posts? I can't find how.

lordsmurf 04-27-2015 07:15 PM

You can edit posts for 60 minutes. See also: http://www.digitalfaq.com/forum/news...embership.html
After an hour, just post a reply.
Site Staff will help maintain posts like this, by merging or editing to keep it updated.


All times are GMT -5. The time now is 03:19 AM

Site design, images and content © 2002-2024 The Digital FAQ, www.digitalFAQ.com
Forum Software by vBulletin · Copyright © 2024 Jelsoft Enterprises Ltd.