Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

Domains: forum.doom9.org / forum.doom9.net / forum.doom9.se

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage

Reply
 
Thread Tools Display Modes
Old 19th February 2026, 05:13   #1  |  Link
frobber
Registered User
 
frobber's Avatar
 
Join Date: Sep 2023
Posts: 31
Stablizing a film image ...

I'm trying to use Stab() to reduce vertical jitter on a TV broadcast of an old black-and-white movie (the usual problem with worn-down sprockets on the print, I guess).

It seems to help, although I see what looks like a 1-pixel black line on the top of the frame that flashes on and off.

Is there some way to eliminate this artifact? Or, is there another plug-in I should use for this purpose?

Also, I'm de-interlacing and converting the video from 29.970 to 23.976 fps, using:

tfm().TDecimate()

Not sure if(?) I can just add Stab() after that line, or if I need(?) to change my script somehow.

TIA !

Last edited by frobber; 19th February 2026 at 06:27.
frobber is offline   Reply With Quote
Old 19th February 2026, 09:00   #2  |  Link
RetsimLegin
Registered User
 
Join Date: Apr 2021
Posts: 81
Crop the top line so it's always black.
RetsimLegin is offline   Reply With Quote
Old 19th February 2026, 16:05   #3  |  Link
johnmeyer
Registered User
 
Join Date: Feb 2002
Location: California
Posts: 2,789
You should always recover the original 24 fps cadence before applying stabilization.

"VideoFred" over at doom9.org started several epically long threads about film restoration. This includes film stabilization. I re-wrote some of his scripts and posted my own version there. Here is the original thread:

The power of Avisynth: restoring old 8mm films

He specifically addressed just stabilization here:

An advanced stabilisation script

Here is the stabilization code from my version of his script. You can try some of the parameters in your script.

Code:
#STABILISING PARAMETERS
#----------------------------------------------------------------------------------------------------------------------------
maxstabH=10                                                      #maximum values for the stabiliser (in pixels) 20 is a good start value 
maxstabV=10
est_left=40  est_top=40  est_right=40  est_bottom=40             #crop and contast values for special Estimate clip
est_cont=0.6                                                     #Too large a value defeats stabilization


#STABILIZING
#....................................................................................................................................................................
stab_reference= cropped_source.crop(est_left,est_top,-est_right,-est_bottom).tweak(cont=est_cont).MT_binarize(threshold=80).greyscale().invert()
mdata=DePanEstimate(stab_reference,trust=1.0,dxmax=maxstabH,dymax=maxstabV)
#stab=DePanStabilize(cropped_source,data=mdata,cutoff=0.5,dxmax=maxstabH,dymax=maxstabV,method=1,mirror=15).deflicker() #use this instead of next line to add the Deflicker function
stab=DePanStabilize(cropped_source,data=mdata,cutoff=0.5,dxmax=maxstabH,dymax=maxstabV,method=1,mirror=15)
johnmeyer is offline   Reply With Quote
Old 20th February 2026, 10:44   #4  |  Link
frobber
Registered User
 
frobber's Avatar
 
Join Date: Sep 2023
Posts: 31
@johnmeyer, thank you for kindly sharing this.

I looked at VideoFred's script 256.1.01_Stab_only.avs, but I'm not sure how to use it. I have the various DLLs installed, but the script itself is fairly complicated.

I tried pasting your script into what I've already got to correct the frame rate (after that step, as you indicated), but when I run it through MeGUI I get an error because cropped_source is undefined.

Any additional hints to make this work would be much appreciated.
frobber is offline   Reply With Quote
Old 20th February 2026, 17:49   #5  |  Link
johnmeyer
Registered User
 
Join Date: Feb 2002
Location: California
Posts: 2,789
Sorry about posting only that fragment. My main intent was to show you some Depan parameters that work and produce good results.

If you click on the first link in my previous post, it takes you directly to my full script. Search for the undefined variable and you'll see what it is and how it gets defined.

Here is a video that shows "before/after" examples of what the script can do. The first half dozen examples mostly show the stabilization and, as you will see, it works quite well.

Before/After Examples
johnmeyer is offline   Reply With Quote
Old 20th February 2026, 23:49   #6  |  Link
frobber
Registered User
 
frobber's Avatar
 
Join Date: Sep 2023
Posts: 31
Thanks, but now I'm lost. The first link in your previous post leads to a thread by videoFred. I don't see johnmeyer anywhere in that thread. Are you "videoFred"? I'm confused.

videoFred links to a ZIP file from 2012. I DL'd it and opened "01_E_Stabilisation_Only.avs". It is similar to the script fragment you pasted, but not the same. No mention of cropped_source anywhere.

Perhaps I misunderstood something and just got completely lost.

Also, these scripts don't really explain the various parameters. Are the crop values going to actually crop the image, or are these only for the stabilization code to do image processing? If they do crop the image, can I just use zero values, or will the algorithm cease to function?

I need to know if any cropping/zooming will happen to the result, because I'm afraid that is a deal-breaker for my purposes.

Last edited by frobber; 20th February 2026 at 23:54.
frobber is offline   Reply With Quote
Old 21st February 2026, 04:41   #7  |  Link
Leo 69
Registered User
 
Join Date: Nov 2004
Posts: 268
Hey, could you provide the source clip? I'm developing my own software that will include automatic frame stabilization and would love to test it on specific sources like yours.
Leo 69 is offline   Reply With Quote
Old 21st February 2026, 06:35   #8  |  Link
frobber
Registered User
 
frobber's Avatar
 
Join Date: Sep 2023
Posts: 31
Quote:
Originally Posted by Leo 69 View Post
Hey, could you provide the source clip? I'm developing my own software that will include automatic frame stabilization and would love to test it on specific sources like yours.
Sure. Here 'ya go: https://www.sendspace.com/file/x1fraj
frobber is offline   Reply With Quote
Old 21st February 2026, 18:04   #9  |  Link
johnmeyer
Registered User
 
Join Date: Feb 2002
Location: California
Posts: 2,789
Just a few days ago I gave someone else the link directly to my own script that is posted in the middle of that massive thread. I thought I had done that above, but as you found, it is just a link to the beginning of that thread.

Here is the link I should have sent to you:

John Meyer's version of the film restoration script
johnmeyer is offline   Reply With Quote
Reply

Tags
avisynth, stabilization, stabilize

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 18:56.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.