I don't like complicated scripts. They're hard to understand, hard to edit.
videoFred/johnmeyer made an excellent film clean script. But sometimes it does too much. At times, I want to only use some of it. But I can't.
How can I excise the stabilization? Help.
This is my current failed attempt to reduce it down
The script is messy. Much of this syntax is probably not needed.Code:film="e:\2.avi" result="result2" maxstabH=30 #maximum values for the stabiliser (in pixels) 20 is a good start value maxstabV=30 est_left=40 est_top=40 est_right=40 est_bottom=40 #crop and contast values for special Estimate clip est_cont=1.1 #Too large a value defeats stabilization threads=3 SetMemoryMax(512) source1=AviSource(film).converttoYV12() stab_reference= source1.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(source1,data=mdata,cutoff=0.5,dxmax=maxstabH,dymax=maxstabV,method=1,mirror=15) result2= ????????????? Eval(result)
I have no idea what to put at result2=
Try StreamFab Downloader and download from Netflix, Amazon, Youtube! Or Try DVDFab and copy Blu-rays!
+ Reply to Thread
Results 1 to 10 of 10
Thread
-
Want my help? Ask here! (not via PM!)
FAQs: Best Blank Discs • Best TBCs • Best VCRs for capture • Restore VHS -
Someone else asked this exact same question just a few days ago. How weird is that?
I cannot speak for Fred's script, but my film restoration script is (he says humbly) very nicely partitioned, specifically to make it modular and therefore easy to understand and take things out. I also added a LOT of comments to help you understand what is going on (and to help me remember stuff when I go back and make modifications).
I have copied below the stabilizing section from the latest version of my script that I posted publicly. The input variable to the section is "cropped_source". The output of the stabilization is assigned to the variable "stab".
So all you have to do is assign the input variable directly to the output variable, and all the code in between will be bypassed:
stab = cropped_source
You can then delete or comment out the lines in between, although the way AVISynth works, those lines should no longer be executed and therefore won't slow things down.
Here's the beginning of the original script, including stabilization:
Code:#START OF SCRIPT #.................................................................................................................................................................... source1= Avisource(film).killaudio().assumefps(play_speed).converttoYV12() cropped_source=source1.crop(in_bord_left,in_bord_top,-in_bord_right,-in_bord_bot) #remove any black borders on input video cropped_source=filldrops(cropped_source) #Use this when removing bad frames that have been removed by duplicating previous frame #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)
Code:#START OF SCRIPT #.................................................................................................................................................................... source1= Avisource(film).killaudio().assumefps(play_speed).converttoYV12() cropped_source=source1.crop(in_bord_left,in_bord_top,-in_bord_right,-in_bord_bot) #remove any black borders on input video cropped_source=filldrops(cropped_source) #Use this when removing bad frames that have been removed by duplicating previous frame #STABILIZING #.................................................................................................................................................................... stab=cropped_source
Last edited by johnmeyer; 20th Sep 2020 at 01:31. Reason: added link to doom9.org post
-
Uhhh.. huh? That's still not a usable script.
With it that stripped down, I get:
Code:I don't know what "in_bord_left" means (New File, Line 7)
My issue is un-octopussing it, to make a single-task smaller script.
Part of the issue is the var/string definitions. I hate those. All the "film=" and "source1="
That's where I lose you. I don't always what's var/string define, and what's not. Nor how to undefine those.
For example, removing film= and just state the path in AviSource()
But how to undefine source1= ?
I don't know what Eval() does
I don't know how to use result2= when I don't want any of that code running. How to back out of there?
Your style of code writing is backwards from how I learned to script Avisynth. I actually find yourself coding style to be fairly unique. I'm trying my best to understand it, but I hit brick walls at times.Last edited by lordsmurf; 20th Sep 2020 at 02:23.
Want my help? Ask here! (not via PM!)
FAQs: Best Blank Discs • Best TBCs • Best VCRs for capture • Restore VHS -
Gosh, it wasn't meant to be a usable script because I thought you needed help with just that one section. So I showed how to remove stabilization. From your post, it sounded like you had stripped out a lot of stuff from my lengthy film restoration script, so it is impossible for me to duplicate whatever it is you have done without knowing what your current script looks like.
If what you posted is your entire script, that won't work at all, and all of your questions are irrelevant because you've deleted so much that all of the variables are undefined. Its like a car with half the parts removed, and asking why you can't drive it.
I don't know what problem you are trying to tackle, but I assume it has something to do with film restoration. My advice would be to download VideoFred's script and get it running. I am recommending that you use his original version rather than my derivative because he provides all the DLLs in one package so you can put everything into one folder and, hopefully, get the whole thing running right away without error messages complaining that you are missing something.
You will still need to use the version of AVISynth that he recommends. If you want, you can use multiple versions of AVISynth and switch between them using the AVISynth switcher available over at doom9.org.
P.S. My script defines variables for various intermediate steps. This is pretty much required when creating more complex scripts. In simple scripts you can avoid doing this because each line uses "last" which is an internal variable that is assigned to the results from the previous line. However, when you need to use the results from something that happened a few lines earlier, you have to save that in a variable so it can be passed down to an operation that happens later in the script.
In this script, the function QTGMC uses the results from AVISource via the hidden "last" variable:
Code:AVISource("e:\myvideo.avi") QTGMC()
Code:source = AVISource("e:\myvideo.avi") QTGMC(source)
Code:source = AVISource("e:\myvideo.avi") source.QTGMC()
Last edited by johnmeyer; 20th Sep 2020 at 13:41. Reason: typos
-
I'm trying to figure out how to write two isolated fully-working scripts. Not get code snippets.
1. This stabilize is the first. I have several already, wrote some myself. But yours is different. I want that in my library.
2. The color correction is the second. I've not gotten that far. Not to skip ahead, but I'm intrigued by the X/X2 variables that act as a black/white floor. I want to incorporate that into my own scripts. But I don't under how it works here.
I realize the reason for the var/string defines (complex scripts).
The difference is our styles. I'm old-school with video. There were steps, workflows. Do 1+ steps at once, stop. Review results. Do next step(s), etc.
Your film script is really nice, but it takes that all-in-one (AIO) impatient newbie mentality of wanting one ring to rule them all one script. That's awesome when it works, with no changes needs (or using the limited var options pre-made by the writer/programmer). When you want to advanced edit options, separate tasks, or even troubleshoot/bugfix, it's difficult.
Your script is awesome at what it does, but techniques from it could be used elsewhere. That's my problem. Trying to un-octopus it.
I'm actually not wanting to restore film at all here. I just want to excise the stabilize aspect to use for other things. And by "excise' I mean make a script all unto itself, because again steps/workflow. 99% of my sources are consumer video tapes. In fact, even most of my film was film>tape, and I'm trying to unring that bell as best as possible.
Analogy: I don't want a car. I just want to take the wheel off, and roll it down the hill. But when I try to take it off, it goes flat, and won't refill with air. How can I just remove the tire, and not have it go flat? I'm just excising, or trying to, a small snippet of this script. I want source > stabilize > done (pass to Hybrid or VirtualDub)
Do this make more sense now?Want my help? Ask here! (not via PM!)
FAQs: Best Blank Discs • Best TBCs • Best VCRs for capture • Restore VHS -
While I may still be confused, it sounds like you are trying to do the opposite of what I thought: you want to extract and use the stabilization code, not remove it.
If I wanted to use the stabilization code by itself, the last place I would go is to some massive script like our film restoration scripts. It would be like trying to do your own deinterlacing by going into the massively long QTMC script and extracting code.
Instead, I would start with the code given in the samples in the Depanestimate documentation, get that working, and then use tricks you find in some of these scripts to get what you want. Here's the sample code:
Code:AviSource("input.avi") LoadPlugin("depanestimate.dll") # or use autoloading LoadPlugin("depan.dll") # or use autoloading i = ConvertToYV12() mdata = DePanEstimate(i) DePanStabilize(i, data=mdata)
-
I already have various scripts. Some I wrote, some I found, some I got help writing. So that's not what I want. I specifically want to extract the stabilization method found in this script, as it works different from the others. Not a random script, new script, etc... but this script.
As the author of that script, why is that hard to explain what is doing what? I don't get it.
We're not all programmers. For me, scripting is hard. Not impossible, just hard, take time to understand. I'm visual, I work in visual mediums. Programming requires esoteric understanding of non-concrete concepts. It's like asking a cat to do algebra homework. (But don't feel superior. Asking a programmer to do visuals is like asking the same cat to draw the Mona Lisa, so it goes both ways here.) So comments like "read the documentation" can be completely worthless if the documentation is also complex jargon.
I'm stuck, and I'm frustrated. I want to be doing video, not writing syntax/code. I'm purposely NOT a computer programmer.
You said the code doesn't work. Your code. So how do I fix it? Where did I go wrong?
I would much rather start it with
Code:AviSource("c:\file.avi") converttoYV12()
Code:film="e:\file.avi" source1=AviSource(film).converttoYV12()
I actually like this:
Code:maxstabH=30 #maximum values for the stabiliser (in pixels) 20 is a good start value maxstabV=30 est_left=40 est_top=40 est_right=40 est_bottom=40 #crop and contast values for special Estimate clip est_cont=1.1 #Too large a value defeats stabilization threads=3
******** EDIT: I just tried to write it again, and it's just error after error.
(Note: I tend to use var/string interchangeably, because those sort of are the same thing here.)
This is what I can understand, and what I can't:
Code:film="e:\2.avi"
Code:result="result2"
Code:maxstabH=30 maxstabV=30 est_left=40 est_top=40 est_right=40 est_bottom=40 est_cont=1.1
Code:source1=AviSource(film).converttoYV12()
Convert colorspace.
Code:stab_reference= source1.crop(est_left,est_top,-est_right,-est_bottom).tweak(cont=est_cont).MT_binarize(threshold=80).greyscale().invert()
Code:mdata=DePanEstimate(stab_reference,trust=1.0,dxmax=maxstabH,dymax=maxstabV)
Code:stab=DePanStabilize(source1,data=mdata,cutoff=0.5,dxmax=maxstabH,dymax=maxstabV,method=1,mirror=15)
Code:result2=
Code:Eval(result)
Last edited by lordsmurf; 22nd Sep 2020 at 00:45. Reason: typos, presentation
Want my help? Ask here! (not via PM!)
FAQs: Best Blank Discs • Best TBCs • Best VCRs for capture • Restore VHS -
lordsmurf
Here's the separate stabilization and color correction from videoFred/johnmeyer script
Code:#Stabilization - part of script by videoFred/johnmeyer #Load plugins explicitly Loadplugin("plugins/Depan.dll") #Version 1.10.0.0 4/09/2007 LoadPlugin("plugins/DepanEstimate.dll") #Version 1.9.2.0 3/25/2007 Loadplugin("plugins/mt_masktools.dll") #Version 2.0.23.0 3/14/2008 MT_binarize #LoadPlugin("plugins/Deflicker.dll") #Version 0.4.0.0 8/16/2004 film="e:\2.avi" #location of the videofile source=AviSource(film).converttoYV12() #there may be a different decoder instead of AviSource(if there are files .mkv or .mp4 & etc.) maxstabH=30 #maximum values for the stabiliser (in pixels) 20 is a good start value maxstabV=30 est_left=40 est_top=40 est_right=40 est_bottom=40 #crop and contast values for special Estimate clip est_cont=1.1 #Too large a value defeats stabilization threads=3 #the number of processing threads, for greater stability, set 3/4 of the number of processor cores SetMemoryMax(512) #memory usage limit stab_reference= 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(source,data=mdata,cutoff=0.5,dxmax=maxstabH,dymax=maxstabV,method=1,mirror=15)#.deflicker() #............................COMPARISONS SECTION............................................. #COMPARISONS: ORIGINAL VS RESULTS resultS1= stackhorizontal(subtitle(source,"original",size=28,align=2),subtitle(stab,"stab",size=28,align=2)) #...........................Destination file-----uncomment the desired item.................. stab #...........................or if you want to see a comparison............................... #resultS1
Code:#Color correction - part of script by videoFred/johnmeyer #Load plugins explicitly LoadPlugin("plugins/autolevels.dll") #Version 0.6.0.0 1/09/2011 film="e:\2.avi" #location of the videofile source=AviSource(film).converttoYV12() #there may be a different decoder instead of AviSource(if there are files .mkv or .mp4 & etc.) #COLOR AND LEVELS PARAMATERS saturation=1.2 #for all outputs gamma=1.0 #for all outputs blue= -0 red=-0 #manual color adjustment, when returning result3 & result4. Values can be positive or negative black_level=0 white_level=255 output_black=0 output_white=255 #manual levels, when returning result2 & result4 #AUTO LEVELS PARAMETER X=4 #X is a special parameter for reducing the autolevels effect on the whites X2=4 #X2 is a special parameter for reducing the autolevels effect on the blacks #RESULT1: AUTOLEVELS,AUTOWHITE result1= source.coloryuv(autowhite=true).addborders(X,0,0,0,$FFFFFF).addborders(0,0,X2,0,$000000).autolevels(filterRadius=2).crop(X,0,-X2,-0) #RESULT3: AUTOLEVELS, MANUAL COLOR CORRECTIONS result3= source.coloryuv(off_U=blue,off_V=red).addborders(X,0,0,0,$FFFFFF).addborders(0,0,X2,0,$000000).autolevels(filterRadius=2).crop(X,0,-X2,-0) #RESULT2: MANUAL LEVELS, AUTOWHITE result2= source.levels(black_level,gamma,white_level,0,255).coloryuv(autowhite=true) #RESULT4: MANUAL LEVELS, MANUAL COLOR CORRECTIONS result4= source.coloryuv(off_U=blue,off_V=red).levels(black_level,gamma,white_level,0,255) #............................COMPARISONS SECTION................................................. #COMPARISONS: ORIGINAL VS RESULTS resultS1= stackhorizontal(subtitle(source,"original",size=28,align=2),subtitle(result1,"autolevels, autowhite",size=28,align=2)) resultS2= stackhorizontal(subtitle(source,"original",size=28,align=2),subtitle(result2,"autowhite, manual levels correction",size=28,align=2)) resultS3= stackhorizontal(subtitle(source,"original",size=28,align=2),subtitle(result3,"autolevels, manual color correction",size=28,align=2)) resultS4= stackhorizontal(subtitle(source,"original",size=28,align=2),subtitle(result4,"manual colors and levels correction",size=28,align=2)) #...........................Destination file-----uncomment the desired item.................. result1 #result2 #result3 #result4 #...........................or if you want to see a comparison...................................... #resultS1 #resultS2 #resultS3 #resultS4
-
first thing that helps is realize what types you work with
Code:film="e:\2.avi"
so this:
Code:film="e:\2.avi" source1=AviSource(film).converttoYV12()
Code:source1=AviSource("e:\2.avi").converttoYV12()
so source1 is a video clip type now. You can put a dot behind a clip type and add another function, like that converttoYV12()
this:
Code:result="result2" result2= ????????????? Eval(result)
Code:return stab
-
Thank you.
Yes, I now see where I went wrong.
Now to learn how/why each stab script behaves differently. That's a task for another day!
Yes, I understood that one. I understood most string, but got lost on a couple, tripped over some other code.
so source1 is a video clip type now. You can put a dot behind a clip type and add another function, like that converttoYV12()
this:Code:result="result2" result2= ????????????? Eval(result)
Code:return stab
Want my help? Ask here! (not via PM!)
FAQs: Best Blank Discs • Best TBCs • Best VCRs for capture • Restore VHS
Similar Threads
-
How to stabilize this video?
By TeNSoR in forum Newbie / General discussionsReplies: 2Last Post: 28th Jul 2020, 05:00 -
clean + improve the colors + stabilize (HELP)
By frank_zappa in forum RestorationReplies: 25Last Post: 26th Oct 2017, 02:23 -
Help ..how to stabilize video
By fulmanful in forum DVD RippingReplies: 6Last Post: 28th Oct 2016, 08:07 -
Batch stabilize script for ffmpeg
By racer-x in forum Video ConversionReplies: 20Last Post: 2nd Jun 2016, 17:10 -
Assistance with some depan/stabilize settings?
By Bruce/Fl in forum RestorationReplies: 12Last Post: 18th Apr 2016, 02:20