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. |
31st January 2021, 16:55 | #41 | Link |
Registered User
Join Date: Apr 2013
Posts: 346
|
I see what you did, and it works, but will cause problems with my external macro involvement.
However, I can accomplish the same thing (just thought of it) by adding FadeOut(1) to the script, above the function line. So, we have two solutions and are a little closer to perfection. |
31st January 2021, 17:04 | #42 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
HH,
I thought I was going nuts, I could not see any diff between code block #1 and code block #3, so I copied to 2 files, 1.txt and 2.txt and did a KDiff, and shows "Binary Equal". Were they supposed to be identical ? EDIT: OK, I see you just edited out this line Code:
Out = FrameEvaluate(Vid2, """ IsComb = IsCombedTIVTC(Vid1) IsRed = (AverageChromaV() > 128) IsEnd = (FrameCount() == (current_frame + 1)) Count = IsComb ? Count + 1 : Count WriteThis = (IsComb || IsRed ? string(current_frame) + \ (IsComb ? string(Count, " - Combing %.0f") : " - No Combing") + \ (IsRed ? string(AverageChromaV()-128, " - %.2f") : "") : "") + \ ((IsComb || IsRed) && IsEnd ? chr(10) : "") + \ (IsEnd ? string(FrameCount(), "%.0f - Frame Count") : "") """) Out = !Write ? Vid2 : \ !All ? WriteFileIf(Out, File, "IsComb || IsRed || IsEnd", "WriteThis", Append=Append) : \ WriteFile(Out, File, "current_frame", "WriteThis", Append=Append)
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? Last edited by StainlessS; 31st January 2021 at 17:08. |
31st January 2021, 18:48 | #43 | Link |
Registered User
Join Date: Mar 2011
Posts: 4,829
|
Yeah... bad copy and paste. Sorry.
Edit: and I just edited it again as reading your post made me realise I forgot to remove "current_frame" from the last line. Sigh..... Edit2: %*^$, that's wrong too. Edit number 3 will happen after I've checked it. Edit 3: Forget the old version. Latest attempt is found in post #46. Last edited by hello_hello; 31st January 2021 at 20:46. |
31st January 2021, 18:50 | #44 | Link | |
Registered User
Join Date: Mar 2011
Posts: 4,829
|
Quote:
If the function was to prevent the combing or red information being written for the last frame, and wrote the frame count instead, would that do it? Last edited by hello_hello; 31st January 2021 at 18:56. |
|
31st January 2021, 20:42 | #46 | Link |
Registered User
Join Date: Mar 2011
Posts: 4,829
|
StainlessS,
Speaking of going nuts... for the function below, which I fixed pointlessly because All=true isn't needed... but I had to make it work anyway... do you know if this is expected behaviour? If I make the "All" argument global like this: global All = default(All, false) it doesn't become global unless I use the argument in the function ie: FindCombingRed(All=true) If I don't, the "All" variable isn't seen by FrameEvaluate. FindCombingRed() Hence including the new variable "Everything". global Everything = All That's seen by FrameEvaluate either way. I don't understand why "All" doesn't become global unless it's specified, or appears not to. Unless that's the way argument globals work and I've never had a reason to notice. Anyway.... for the sake of completeness, this version works correctly when All=true. Code:
# =============================================================================== function FindCombingRed(clip Vid, bool "Append", string "FileName", bool "All", bool "Write") { Append = default(Append, false) FileName = default(FileName, "") All = default(All, false) Write = default(Write, true) N = ScriptFile() LN = LCase(N) NLen = StrLen(N) ELen = FindStr(LN, ".avs") - 1 File_Name = LeftStr(N, NLen-(NLen-ELen)) FName = (FileName == "") ? File_Name : FileName File = FName + "_Combing.txt" global Count = 0 Vid = Vid.GreyScale() global Vid1 = Vid.TFM(pp=1).TDecimate() CombTest = BlankClip(Vid, Color=color_red) Vid2 = Vid.TFM(Clip2=CombTest).TDecimate() global Everything = All Out = FrameEvaluate(Vid2, """ IsComb = IsCombedTIVTC(Vid1) IsRed = (AverageChromaV() > 128) IsEnd = (FrameCount() == (current_frame + 1)) Count = IsComb ? Count + 1 : Count WriteThis = \ (!IsComb && !IsRed && !Everything ? "" : string(current_frame)) + \ (!IsComb && !IsRed ? "" : \ IsComb && IsRed ? (string(Count, " - Combing %.0f") + string(AverageChromaV()-128, " - %.2f")) : \ IsComb ? string(Count, " - Combing %.0f") : \ (" - No Combing" + string(AverageChromaV()-128, " - %.2f"))) + \ (!IsEnd ? "" : \ (!IsComb && !IsRed && !Everything ? "" : chr(10)) + string(FrameCount(), "%.0f - Frame Count")) """) Out = !Write ? Vid2 : \ !All ? WriteFileIf(Out, File, "IsComb || IsRed || IsEnd", "WriteThis", Append=Append) : \ WriteFile(Out, File, "WriteThis", Append=Append) return Out } # =============================================================================== Last edited by hello_hello; 31st January 2021 at 21:44. |
31st January 2021, 20:44 | #47 | Link | |
Registered User
Join Date: Mar 2011
Posts: 4,829
|
Quote:
Maybe post an example of the last few lines the way you want it. |
|
31st January 2021, 21:16 | #49 | Link |
Registered User
Join Date: Mar 2011
Posts: 4,829
|
Maybe I'm being thick, but isn't that what's happening? If you don't want it labelled, use the function in post #46 and remove
- Frame Count from the last FrameEvaluate line. It appears to be writing a blank line at the very end, after the frame count. If that's the issue, I don't know how to prevent it, so you might need to remove it manually. Code:
...string(FrameCount(), "%.0f")) Code:
60 - Combing 24 - 48.78 70 - Combing 25 - 28.37 72 - Combing 26 - 22.18 73 - Combing 27 - 112.00 74 - Combing 28 - 30.47 76 - Combing 29 - 112.00 77 - Combing 30 - 26.82 79 - Combing 31 - 28.58 80 - Combing 32 - 112.00 81 Code:
80 - Combing 33 - 112.00 81 - No Combing - 34.56 92 - Combing 34 - 14.91 93 - No Combing - 16.27 161 - Combing 35 162 - Combing 36 - 42.75 163 - Combing 37 - 112.00 164 - Combing 38 - 35.61 208 Code:
...string(FrameCount(), "%.0f - Frame Count")) Code:
60 - Combing 24 - 48.78 70 - Combing 25 - 28.37 72 - Combing 26 - 22.18 73 - Combing 27 - 112.00 74 - Combing 28 - 30.47 76 - Combing 29 - 112.00 77 - Combing 30 - 26.82 79 - Combing 31 - 28.58 80 - Combing 32 - 112.00 81 - Frame Count Code:
80 - Combing 33 - 112.00 81 - No Combing - 34.56 92 - Combing 34 - 14.91 93 - No Combing - 16.27 161 - Combing 35 162 - Combing 36 - 42.75 163 - Combing 37 - 112.00 164 - Combing 38 - 35.61 208 - Frame Count Last edited by hello_hello; 31st January 2021 at 21:40. |
31st January 2021, 23:19 | #52 | Link | |
Registered User
Join Date: Apr 2013
Posts: 346
|
This is what I get when running the code in post #46:
Quote:
|
|
1st February 2021, 00:10 | #53 | Link | |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
Quote:
Code:
Colorbars.ConvertToYV12.KillAudio Return Test() #Return Test(undefined) #Return Test(All=undefined) #Return Test(All=false) #Return Test(false) #Return Test(True) #Return Test(All=True) Function Test(clip c, bool "All") { c Global All = Default(All,false) ScriptClip("Subtitle(String(ALL))") # COMMENT THIS OUT, NOTHING AT ALL HAPPENS Subtitle(String(ALL),Align=2) # Should print ALL on Bottom of frame. NOTHING HAPPENS. # EDIT ADDED LINE } Where it prints ALL on bottom of frame, and input to function is undefined, then prints undefined ie null string "". Why it Happens:- Local variable hides a Global variable of same name, so although you have defined ALL as Global, because the local ALL variable exists, but is undefined, so prints nothing on bottom of frame. However inside scriptclip the global All is NOT hidden by local All and so prints on top of frame OK. So is NOT a BUG, is as expected, but a bit tricky to figure out why.
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? Last edited by StainlessS; 1st February 2021 at 00:38. |
|
1st February 2021, 00:31 | #54 | Link |
Registered User
Join Date: Mar 2011
Posts: 4,829
|
Stainless, I saw your edited post after submitting this one, but anyhow....
Edit: Still trying to wrap my head around it, but in your example, where is a local All being declared as a variable? I can only see the global one. Surely converting it to a string shouldn't effect it's actual value, or global status? string(ALL) StainlessS, that certainly produces the expected result, but this.... not so much. Code:
Colorbars.ConvertToYV12.KillAudio Return Test() Function Test(clip c, bool "All") { Global All = Default(All,false) Return All ? c.Subtitle("All") : c.Subtitle("Not All") } Code:
Colorbars.ConvertToYV12.KillAudio Return Test() Function Test(clip c, bool "All") { Global All = Default(All,false) Global All = All Return All ? c.Subtitle("All") : c.Subtitle("Not All") } Code:
Colorbars.ConvertToYV12.KillAudio Return Test() Function Test(clip c, bool "All") { All = Default(All,false) Global All = All Return All ? c.Subtitle("All") : c.Subtitle("Not All") } PS Version() says Avisynth+ 3.5 r3106 Last edited by hello_hello; 1st February 2021 at 01:21. |
1st February 2021, 00:37 | #55 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
I figured out the reason, as in edit, hope it makes sense.
[I made a number of edits.] EDIT: When getting value of a variable, it searches the list of Local variables first, only if it does not find it there does it then search the Global variables list. Inside your function the optional arg "All" does exist, its just not defined unless provided by the caller with a value.
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? Last edited by StainlessS; 1st February 2021 at 00:49. |
1st February 2021, 00:59 | #56 | Link |
Registered User
Join Date: Mar 2011
Posts: 4,829
|
So are you saying
All = default(All, false) All doesn't have any value until something wants to know what "All" means later in the script? That seems odd to me. Because this works, not being an argument. Code:
Colorbars.ConvertToYV12.KillAudio Return Test() Function Test(clip c, bool "All") { Global MyCat = false Return MyCat ? c.Subtitle("All") : c.Subtitle("Not All") } |
1st February 2021, 01:11 | #57 | Link |
Registered User
Join Date: Mar 2011
Posts: 4,829
|
Code:
Colorbars.ConvertToYV12.KillAudio Return Test() Function Test(clip c, bool "All") { Global All = Default(All,false) Global MyCat = true Return MyCat ? c.Subtitle(string(All)) : c.Subtitle("Not All") } Yet here at the return line it's false. That seems inconsistent to me. Code:
Colorbars.ConvertToYV12.KillAudio Return Test() Function Test(clip c) { Global All = false Global MyCat = true Return MyCat ? c.Subtitle(string(All)) : c.Subtitle("Not All") } Because "All" is a function argument it's instantly a local variable inside the function, even though it's undefined, so as a global variable it's ignored. I dunno though... should an argument be a local variable before it's defined? Maybe it has to be, I think my brain is slowly coming to terms with how it works. Last edited by hello_hello; 1st February 2021 at 01:20. |
1st February 2021, 01:31 | #58 | Link |
Registered User
Join Date: Mar 2011
Posts: 4,829
|
I don't understand. I was using the function from post #46 to show you the examples. Are you sure you don't have two versions of the same function auto-loading? I've driven myself a little mad doing that before.
My favourite trick is to have the function open in a text editor (one that doesn't lock files), change the file name in Explorer, click "save" in the text editor, and then there's two versions. I did that yesterday or the day before while playing with an earlier version of this function and lost about 30 minutes banging my head on the desk before the penny dropped. I moved my copy out of the auto-loading plugins folder, made sure it resulted in a "no function named" error message, put it back and ran the script again. Code:
73 - Combing 27 - 112.00 74 - Combing 28 - 30.47 76 - Combing 29 - 112.00 77 - Combing 30 - 26.82 79 - Combing 31 - 28.58 80 - Combing 32 - 112.00 81 - Frame Count Last edited by hello_hello; 1st February 2021 at 01:42. |
1st February 2021, 01:34 | #59 | Link | ||
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
How bout this, any good
Code:
Colorbars.ConvertToYV12.KillAudio.Trim(0,-1) # 1 frame Return Test() #Return Test("Some Test String") Function Test(clip c, String "All") { c Out("1:- Test local All arg",All) # Local All, may be undefined Global All = "G_" + Default(All,"Undefined String") # This is 'Invisible' due to presence of function arg All. Out("2:- Test Global All",All) # This will output Local All, local All hides Global All SSS=""" Out("3:- Scriptclip Subtitle Global All",All) # Local arg All is not available in ScriptClip and so cannot hide the global All Subtitle(String(ALL)) """ ScriptClip(SSS) Subtitle(String(ALL),Align=2) # Should print ALL on Bottom of frame. Out("4:- Test local Subtitle All",All) # Local All, may be undefined Return Last } Function Out(String s, val "v") { RT_debugF("%s = '%s'",s,String(v),name="Out: ") # if v is undefined, then String(v) will produce "". } Return Test() Code:
00001012 0.28597242 [1224] Out: 1:- Test local All arg = '' 00001013 0.28608471 [1224] Out: 2:- Test Global All = '' 00001014 0.28634524 [1224] Out: 4:- Test local Subtitle All = '' 00001015 0.28672349 [1224] Out: 3:- Scriptclip Subtitle Global All = 'G_Undefined String' Code:
00001115 0.28165036 [3932] Out: 1:- Test local All arg = 'Some Test String' 00001116 0.28175980 [3932] Out: 2:- Test Global All = 'Some Test String' 00001117 0.28203043 [3932] Out: 4:- Test local Subtitle All = 'Some Test String' 00001118 0.28244600 [3932] Out: 3:- Scriptclip Subtitle Global All = 'G_Some Test String' Code:
Colorbars.Subtitle(String(All)) All=undefined at main script level, creates a named but undefined variable. [it has neither a variable type (int/bool etc) nor value, but it does exist] Code:
All=undefined Colorbars.Subtitle(String(All)) # String(undefined) : produces '' EDIT: Below copied here from previous posts. Quote:
Quote:
An Undefined variable does have an entry in the Local or Global variable Lists (or Tables), but has no value, nor type (strictly speaking its type is undefined). EDIT: Creating an additional Global as you have done will of course work, I tend to like naming globals with a prepended "G_" eg "G_All", or sometime prepend the function name as in "G_Test_All" or "_G_Test_All", or "__G_Test_All".
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? Last edited by StainlessS; 1st February 2021 at 14:46. |
||
|
|