View Full Version : Count/Display/Save Frames Containing Red


Danette
18th January 2021, 20:01
I'm using this script to identify likely moire effects:

Greyscale()
CombTest=BlankClip(Last,Color=color_red)
TFM(Clip2=CombTest)
TDecimate()
ShowChannels()

Rather than using ShowChannels, I would prefer to be able to save a text file that reports the number of frames that contain V (red projection) appearances. Less preferable would be to simply display the number of occurrences. The idea being that, if the number of possible moire frames (as indicated by red) is acceptably low, I would not bother addressing it in that particular video.

Can anyone suggest some scripting approaches?

hello_hello
19th January 2021, 10:02
%^ck me! The first time in month I don't copy a post to the clipboard before submitting it, so the "token expired" message crap appears and the mini essay I wrote is gone.

This function will write the frame numbers when combing is detected. If you need to know how many there are, open the text file with something that tells you what line you're on in the status bar, scroll to the end and click somewhere on the last line. :)

Append=false and the text file is over-written when the script runs. TFM will overwrite it's own text file each time anyway so be careful there.
FileName should be obvious.
All=true writes every frame to the text file, combed or not.
TFMOut=true gives you a second text file from TFM. TFM=false should stop it over-writing an existing file.
I don't know how useful TFM's file will be.
TDecOut=true gives you a potentially useless file from TDecimate too. I can't remember exactly what they contain.
TDecOut=true won't do anything unless TFMOut is also true.

Load the script into MeGUI and run an analysis pass, or I assume you can run one with AvsPmod. Change what you need to by editing the function, but the current order of things is:

TFM - No de-interlacing.
TDecimate - It's decimating.
Check for combing and how detectable that combing is.
Write the text file.
TFM again, writing another text file, still not de-interlacing.
TDecimate = just writing it's output file. No decimation.

Change the MI values in the function if need be. Each IsCombedTIVTC() instance is detecting combing at a different threshold according to the MI value for each.
Change the text written next the frame numbers to whatever you prefer.

Edit: There's an updated version in post #6 without TFM and TDecimate.

SomethingSomething(Append=true, FileName="D:\Something", All=false, TFMOut=false, TDecOut=false)

function SomethingSomething(clip Vid, bool "Append", string "FileName", bool "All", \
bool "TFMOut", bool "TDecOut") {

Append = default(Append, true)
FileName = default(FileName, "Something")
All = default(All, false)
TFMOut = default(TFMOut, false)
TDecOut = default(TDecOut, false)

Vid = Vid.TFM(pp=1).TDecimate()

Vid = \
FrameEvaluate(Vid, """

A = IsCombedTIVTC(MI=30)
B = IsCombedTIVTC(MI=80)
C = IsCombedTIVTC(MI=130)

LowThresh = "Heeere's Johnny"
NormalThresh = "Open the pod bay doors, Hal"
HighThresh = "Klaatu barada nikto"
WhatCombing = " "

TheCombing = " - " + \
(A && !B && !C ? LowThresh : \
B && !C ? NormalThresh : \
C ? HighThresh : WhatCombing)

""")

File1 = FileName + "Combed.txt"
File2 = FileName + "TFM.txt"
File3 = FileName + "TDec.txt"

Vid = All ? WriteFile(Vid, File1, "current_frame", "TheCombing", Append=Append) : \
WriteFileIf(Vid, File1, "A || B || C", "current_frame", "TheCombing", Append=Append)

Vid = \
TFMOut && !TDecOut ? Vid.TFM(pp=1, output=File2) : \
TFMOut && TDecOut ? Vid.TFM(pp=1, output=File2).TDecimate(mode=4, output=File3) : Vid

Return Vid }

StainlessS
19th January 2021, 14:14
HH [AKA Gort],
FireFox Addons [TextAreaCache]:- https://forum.doom9.org/showthread.php?t=177066



TextArea Cache

Hi guys, just a recommendation here for Firefox addon "TextArea Cache",

First time I've had to use it and saved me about 20->30 minutes of repeated searching to re-write post after accidental deletion.

I had several different threads open on D9, and accidentally went back to previous page on the wrong tab, result: about 20 to 30 minutes of searching/writing lost.
I clicked on the TextArea Cache tool icon, and it was there just like it was before deletion, this is defo gonna be staying on all my machines, it was there just when I needed it.

It saves copy of text edit boxes of fireFox. [you can give list of websites not to cache eg your on-line banking]
Saved my bacon, perhaps do same for you one day. :)

EDIT: https://addons.mozilla.org/en-GB/firefox/addon/textarea-cache/

Also available for Chrome:- https://chrome.google.com/webstore/detail/textarea-cache/chpphekfimlabghbdankokcohcmnbmab?hl=en
[not sure if above link will work(may have re-directed to another page), for me it shows correctly that I dont have Chrome installed, so cannot install addon]

reviews (2nd link has two alternative addons, but I'm happy with this one):
https://www.ghacks.net/2019/03/03/never-lose-text-input-in-firefox-again-with-textarea-cache/
https://www.raymond.cc/blog/saving-what-you-typed-in-firefox-or-wordpress-locally-to-your-compouter/

EDIT: You can set it to Not Allow to run in Private Windows (is FireFox controlled Default [unless you changed Firefox default], eg when banking),


EDIT: From later in above thread,

EDIT: TextAreaCache (first post) has recently saved me about 3 or four more times, I'm very happy with it.

hello_hello
19th January 2021, 17:44
Thanks StainlessS.
I'm usually in the habit of a quick CTRL+A and CTRL+C before I click to submit, because I've lost a lot time spent typing in the past. I even try to avoid mice with back/forward navigation buttons on them, because that's a recipe for having to type everything from scratch again, but I'll check out those extensions.
Cheers.

Gavino
19th January 2021, 20:51
Having also suffered from this problem, I long ago learned to construct any long posts in a separate editor before logging in to D9 and pasting them in.

hello_hello
19th January 2021, 21:43
While there's two experts in the thread....

Just for fun.... I thought I'd try to get Avisynth to count the frames for each threshold detection level. Outsourcing the counting to separate functions seems a bit clunky, but I tried 379 other ways of doing it before finding one that worked. Is there a better way to do it?

Edit: I created a function today to help with 2 pass VBR encoding, and thought I might as well add the same thing to this script too. There's no need to specify a name for the output text file any more, You can, but if you don't, it'll be created using the same name as the script.

A version of the previous function without TFM and TDecimate, as it'd probably be better for the function to only do combing detection, and this one has non-silly descriptions for the combing detection.

FindCombing(Append=false, All=false)


# ===============================================================================

function FC_CounterA(){ try{ global FC_X = FC_X + 1 }catch(err){ global FC_X = 1 } return FC_X }
function FC_CounterB(){ try{ global FC_Y = FC_Y + 1 }catch(err){ global FC_Y = 1 } return FC_Y }
function FC_CounterC(){ try{ global FC_Z = FC_Z + 1 }catch(err){ global FC_Z = 1 } return FC_Z }

# ===============================================================================

function FindCombing(clip Vid, bool "Append", string "FileName", bool "All") {

Append = default(Append, false)
FileName = default(FileName, "")
All = default(All, false)

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"

Vid = FrameEvaluate(Vid, """

A = IsCombedTIVTC(MI=30)
B = IsCombedTIVTC(MI=80)
C = IsCombedTIVTC(MI=130)

TheCombing = " - " + \
(A && !B && !C ? string(FC_CounterA(), "Thresh Low % 6.0f") : \
B && !C ? string(FC_CounterB(), "Thresh Med % 6.0f") : \
C ? string(FC_CounterC(), "Thresh Hi % 6.0f") : " ")

""")

Vid = !All ? WriteFileIf(Vid, File, "A || B || C", "current_frame", "TheCombing", Append=Append) : \
WriteFile(Vid, File, "current_frame", "TheCombing", Append=Append)

return Vid }

# ===============================================================================

hello_hello
21st January 2021, 23:20
Ahhh, now I get it....
Counting without the external functions.

# ==================================================================================
# ==================================================================================

function FindCombing(clip Vid, bool "Append", string "FileName", bool "All") {

Append = default(Append, false)
FileName = default(FileName, "")
All = default(All, false)

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 FCA = 0
global FCB = 0
global FCC = 0

Vid = FrameEvaluate(Vid, """

A = IsCombedTIVTC(MI=80)
B = IsCombedTIVTC(MI=130)
C = IsCombedTIVTC(MI=180)

FCA = A && !B && !C ? FCA + 1 : FCA
FCB = B && !C ? FCB + 1 : FCB
FCC = C ? FCC + 1 : FCC

TheCombing = " - " + \
(A && !B && !C ? string(FCA, "Thresh Norm % 6.0f") : \
B && !C ? string(FCB, "Thresh High % 6.0f") : \
C ? string(FCC, "Thresh Very High % 6.0f") : " ") """)

""")

Vid = !All ? WriteFileIf(Vid, File, "A || B || C", "current_frame", "TheCombing", Append=Append) : \
WriteFile(Vid, File, "current_frame", "TheCombing", Append=Append)

return Vid }

# ==================================================================================
# ==================================================================================

StainlessS
22nd January 2021, 13:40
Dont think you need the globals.

Gavino
22nd January 2021, 17:32
Dont think you need the globals.
You do if they are declared inside the function.
But they could be taken out and placed at script level.

hello_hello
22nd January 2021, 19:13
Dont think you need the globals.

Variables don't seem to be passed to FrameEvaluate unless they're global.

I tried doing it GrunT style, by using an argument list for FrameEvaluate
args="FCA, FCB, FCC"
but that seems to reset their values for each frame, and therefore no counting.

The only other non-global method that worked was to place them in Try/Catch thingies within FrameEvaluate, to give them an initial value. I'm just not sure how that compares to setting a global value outside of FrameEvaluate, in respect to over-head.

try{FCA = A && !B && !C ? FCA + 1 : FCA}catch(err){FCA = 1}

You do if they are declared inside the function.
But they could be taken out and placed at script level.

I don't quite understand what you mean there, but I'm fairly new to conditional filtering so it still tends to melt my brain a little. :)

For example, trying to understand why it still works when it's apparently backwards is making my head hurt.
I think it was something like:

global FCA = 0
global FCB = 0
global FCC = 0
Vid = last

A = WriteFile(Vid, File, "current_frame", "TheCombing", Append=Append)

B = FrameEvaluate(A, """

A = IsCombedTIVTC(MI=80)
B = IsCombedTIVTC(MI=130)
C = IsCombedTIVTC(MI=180)

FCA = A && !B && !C ? FCA + 1 : FCA
FCB = B && !C ? FCB + 1 : FCB
FCC = C ? FCC + 1 : FCC

TheCombing = " - " + \
(A && !B && !C ? string(FCA, "Thresh Norm % 6.0f") : \
B && !C ? string(FCB, "Thresh High % 6.0f") : \
C ? string(FCC, "Thresh Very High % 6.0f") : " ") """)

return B

StainlessS
22nd January 2021, 19:34
You do if they are declared inside the function.
But they could be taken out and placed at script level.

Oops, I did not realize that it was inside a function, maybe I had it scrolled out of view [EDIT: function start] in the scrolley window thingy.
I thought it was at main script level. [I nearly added something like "you would need globals if inside a function"]

Nice to see Big G keepin' me on my toes.

Gavino
22nd January 2021, 20:28
Variables don't seem to be passed to FrameEvaluate unless they're global.
...
I don't quite understand what you mean there, but I'm fairly new to conditional filtering so it still tends to melt my brain a little. :)
The run-time script (the string passed to FrameEvaluate()) runs at the same scope level as the main script, so variables from the main script are visible inside, whereas local function variables are not and have to be declared global to become visible.

Danette
23rd January 2021, 18:50
I’ve spent a few days trying to make these suggestions work. I appreciate all of the work, and hurting of heads, that went into them, but I cannot get any value out of them. I even changed "Heeere's Johnny" to “Mr. Echo, go to hell!” to keep the genre consistent.

Basically, it seems that just about every frame is identified as having some characteristic that puts it on the list, i.e.; it is not creating an exclusive-enough frame listing to be useful for what I am trying to do in the first post.

Here is a sample video: https://www.mediafire.com/file/ybqmelw07mp9das/Red_Test.m2v/file

If you use this script on it:

CombTest=BlankClip(Last,Color=color_red)
TFM(Clip2=CombTest)
TDecimate()

#SomethingSomething(Append=False, FileName="C:\test.txt", All=False, TFMOut=True, TDecOut=True)
FindCombing(Append=False, FileName="C:\test.txt", All=False)

you will see, in the video, the red frames. It is these red frames where the moire effect makes it’s appearance and it is these red frame numbers that I was hoping to list and/or just a count of these frames. Of course, some low tolerance around such a listing would be ok, but the “SomethingSomething” and “FindCombing” scripts have more non-red frames than red frames.

I would appreciate any further effort to make it work, but I also understand that it does seem to be consuming quite a bit of time for something that none of you may ever use.

hello_hello
24th January 2021, 19:41
The newer version in post #7 doesn't do anything with TFM or TDecimate. It only looks for combing and reports three different levels of how hard that combing was to detect, according to the MI values. By default it only writes the frame numbers when combing is detected, and for each detection level it counts the number of frames as it goes. The only oddity I just discovered is it starts off writing the first frame number three times, which throws the counting off, so to compensate I've edited the previous function to start the counting at -2 for the low detection threshold (Edit: It was MeGUI's fault. See post #26.).

TFM(pp=1) # pp=1 to prevent TFM de-interlacing otherwise there won't be combing.
TDecimate()
FindCombing()

There's no way to report how much combing there is in a frame, as far as I know, but this is the next best thing. I tried this as an experiment after running the analysis pass (using your latest sample), and this is just a small section of the file it wrote.

17 - Thresh Med 1
18 - Thresh Med 2
19 - Thresh Med 3
20 - Thresh Med 4
21 - Thresh Med 5
22 - Thresh Hi 1
23 - Thresh Med 6
24 - Thresh Hi 2
25 - Thresh Hi 3
26 - Thresh Med 7
27 - Thresh Med 8
28 - Thresh Med 9
29 - Thresh Med 10
30 - Thresh Med 11
31 - Thresh Med 12
32 - Thresh Med 13
33 - Thresh Low 1
34 - Thresh Low 2
35 - Thresh Low 3
36 - Thresh Low 4

The following is to test how the info in the file corresponds to the red you see. It assumes you're using the default of MI=80 for TFM.

A = TFM(pp=1).TDecimate().Frame(Size=1.5)

CombTest=BlankClip(Last,Color=color_red)

B = TFM(Clip2=CombTest).TDecimate()

StackHorizontal(A,B)

Frame 24 - Thresh Hi means combing is still detected at a high threshold (MI=130). Chances are there'll be a fair amount of red.

https://i.postimg.cc/sBbPHTvr/Frame-24.jpg (https://postimg.cc/sBbPHTvr)

Frame 32 - Thresh Med is the default of MI=80. For Thresh Med you should always see some red.

https://i.postimg.cc/8JWR2L6r/Frame-32.jpg (https://postimg.cc/8JWR2L6r)

Frame 33 - Thesh Low means combing is only detected when the detection level is more sensitive. You won't see red.

https://i.postimg.cc/hJXb0k4s/Frame-33.jpg (https://postimg.cc/hJXb0k4s)

Remember it's not showing you how much red there is, only if combing was detected and how hard it was to detect. The idea was to try to make it more informative than simple true or false combing detection.
You could maybe try using different cthresh levels for the combing detection in the function instead of MI levels, or change the MI levels so it reports medium, high and very high or something like that, as maybe there's no point to it reporting combing lower than the threshold you're using, but I think that sort of thing is about as close as you'll get to what you wanted.

Edit: I've changed the function in post #7 so it'll only report combing at the default detection level of MI=80 or above, so slightly different to the examples in this post:

Thresh Norm means combing was detected at the default of MI=80
Thresh High means combing was detected even at MI=130
Thresh Very High means combing was still detected at MI=180

If you can't see red, it won't report combing.
That'll probably be more useful than the way is was.

You're probably viewing the video in AVsPmod or something that tells you the frame numbers, but for the screenshots I used this: Position.zip (https://files.videohelp.com/u/210984/Position.zip)

Now if only someone could tell me why the counting in the file starts off like this (initial number set to -2 to compensate).
Edit: It was MeGUI's fault. See post #26.

0 - Thresh Low -2
0 - Thresh Low -1
0 - Thresh Low 0
17 - Thresh Med 1
18 - Thresh Med 2

StainlessS
24th January 2021, 20:20
HH, below is at the very least a bit confusing.

global FCA = 0
global FCB = 0
global FCC = 0
Vid = last

A = WriteFile(Vid, File, "current_frame", "TheCombing", Append=Append)

B = FrameEvaluate(A, """

A = IsCombedTIVTC(MI=80)
B = IsCombedTIVTC(MI=130)
C = IsCombedTIVTC(MI=180)

FCA = A && !B && !C ? FCA + 1 : FCA
FCB = B && !C ? FCB + 1 : FCB
FCC = C ? FCC + 1 : FCC

TheCombing = " - " + \
(A && !B && !C ? string(FCA, "Thresh Norm % 6.0f") : \
B && !C ? string(FCB, "Thresh High % 6.0f") : \
C ? string(FCC, "Thresh Very High % 6.0f") : " ") """)

return B

You seem to have A var being a clip in some places, and a bool in others, same for B.
Also can be source of weird problems when doing that.
EDIT: Also is horrible to use that awful bottom up passing of TheCombing, [seen in Advanced Runtime Scripting]
is always a bit confusing to say the least, almost certainly the cause of below statement.
Now if only someone could tell me why the counting in the file starts off like this (initial number set to -2 to compensate).

Probably the only person that could solve your problem is Gavino, alas no longer with us. :)

EDIT:
Now if only someone could tell me why the counting in the file starts off like this (initial number set to -2 to compensate).
Possible Cause, assignment to FCA, FCB, FCC inside FrameEvaluate, should be to Global FCA etc,
or remove Global storage speciifer from main level script.

StainlessS
24th January 2021, 23:13
HH,
I think this does as you were wantin', [without the -2, or Advanced Runtime Scripting headache]


MPEG2Source("D:\DVD\S\VIDEO_TS\S.d2v")
###
File = "" # Name Part Only, No Path, No Extension : "" = Current ScriptFile name.
SUBS = True
ALL = True
#
NORM_TH = 80
HIGH_TH = 130
VERY_TH = 180
###
Assert(NORM_TH < HIGH_TH < VERY_TH,"NORM_TH < HIGH_TH < VERY_TH")

File = (((File == "") ? ScriptFile.ReplaceExtension : File) + "_Combing.txt").RT_GetFullPathName


FCA = 0
FCB = 0
FCC = 0

RT_FileDelete(File)

SSS = """
A = IsCombedTIVTC(MI=NORM_TH)
B = IsCombedTIVTC(MI=HIGH_TH)
C = IsCombedTIVTC(MI=VERY_TH)

if(!(A||B||C)){
if(ALL) {
TxtS = RT_String("%5d] ................ [%.1s%.1s%.1s : %d %d %d]",current_frame,A,B,C,FCA,FCB,FCC)
RT_WriteFile(File,"%s",TxtS,Append=true)
(SUBS) ? Subtitle(TxtS,font="Courier New") : NOP
}
} else {
IsA = A && !B && !C
IsB = B && !C
IsC = C

FCA = IsA ? FCA + 1 : FCA
FCB = IsB ? FCB + 1 : FCB
FCC = IsC ? FCC + 1 : FCC

FCS = "Thresh " + (IsA?"Norm ":IsB?"High " : IsC ? "Very High" : " ")
TxtS = RT_String("%5d] %s [%.1s%.1s%.1s : %d %d %d]",current_frame,FCS,A,B,C,FCA,FCB,FCC)
RT_WriteFile(File,"%s",TxtS,Append=true)
(SUBS) ? Subtitle(TxtS,font="Courier New") : NOP
}
Return Last
"""

Scriptclip(SSS)

Return Last
################

Function ReplaceExtension(String fn,String "Ext") { # https://forum.doom9.org/showthread.php?p=1896882#post1896882
Ext=Default(Ext,"") # Default is "", ie STRIP extension, replace with "" (Ext should include DOT eg ".mp4")
rfn=fn.RevStr
i=rfn.FindStr(".")
Return (i==0) ? fn : rfn.MidStr(i+1).RevStr + Ext
}

EDIT: Thresh Check. Some Tweaks.

Small section of output when ALL=True

2839] ................ [FFF : 70 23 33]
2840] ................ [FFF : 70 23 33]
2841] ................ [FFF : 70 23 33]
2842] ................ [FFF : 70 23 33]
2843] ................ [FFF : 70 23 33]
2844] ................ [FFF : 70 23 33]
2845] ................ [FFF : 70 23 33]
2846] ................ [FFF : 70 23 33]
2847] Thresh Norm [TFF : 71 23 33]
2848] Thresh Norm [TFF : 72 23 33]
2849] Thresh Norm [TFF : 73 23 33]
2850] Thresh Norm [TFF : 74 23 33]
2851] Thresh Norm [TFF : 75 23 33]
2852] Thresh Norm [TFF : 76 23 33]
2853] Thresh Norm [TFF : 77 23 33]
2854] Thresh High [TTF : 77 24 33]
2855] Thresh High [TTF : 77 25 33]
2856] Thresh High [TTF : 77 26 33]
2857] Thresh Very High [TTT : 77 26 34]
2858] Thresh Very High [TTT : 77 26 35]
2859] Thresh Very High [TTT : 77 26 36]
2860] Thresh Very High [TTT : 77 26 37]
2861] Thresh Very High [TTT : 77 26 38]
2862] Thresh Very High [TTT : 77 26 39]
2863] Thresh Very High [TTT : 77 26 40]
2864] Thresh Very High [TTT : 77 26 41]
2865] Thresh Very High [TTT : 77 26 42]
2866] Thresh Very High [TTT : 77 26 43]
2867] Thresh Very High [TTT : 77 26 44]
2868] Thresh Very High [TTT : 77 26 45]
2869] Thresh Very High [TTT : 77 26 46]
2870] Thresh Very High [TTT : 77 26 47]
2871] Thresh Very High [TTT : 77 26 48]
2872] Thresh Very High [TTT : 77 26 49]
2873] Thresh Very High [TTT : 77 26 50]
2874] Thresh Very High [TTT : 77 26 51]
2875] Thresh Very High [TTT : 77 26 52]
2876] Thresh Very High [TTT : 77 26 53]
2877] Thresh Very High [TTT : 77 26 54]
2878] Thresh Very High [TTT : 77 26 55]
2879] Thresh Very High [TTT : 77 26 56]
2880] Thresh Very High [TTT : 77 26 57]
2881] Thresh Very High [TTT : 77 26 58]
2882] Thresh Very High [TTT : 77 26 59]
2883] Thresh Very High [TTT : 77 26 60]
2884] Thresh Very High [TTT : 77 26 61]
2885] Thresh Very High [TTT : 77 26 62]
2886] Thresh Very High [TTT : 77 26 63]
2887] Thresh Very High [TTT : 77 26 64]
2888] Thresh Very High [TTT : 77 26 65]
2889] Thresh Very High [TTT : 77 26 66]
2890] Thresh Very High [TTT : 77 26 67]
2891] Thresh Very High [TTT : 77 26 68]
2892] Thresh High [TTF : 77 27 68]
2893] Thresh High [TTF : 77 28 68]
2894] Thresh High [TTF : 77 29 68]
2895] Thresh High [TTF : 77 30 68]
2896] Thresh High [TTF : 77 31 68]
2897] Thresh Norm [TFF : 78 31 68]
2898] Thresh Norm [TFF : 79 31 68]
2899] Thresh Norm [TFF : 80 31 68]
2900] Thresh Norm [TFF : 81 31 68]

Danette
25th January 2021, 03:09
Lots to digest, there. It will take a few days. My only concern is counting those frames that have ANY red in them (could be barely noticeable to a completely red frame). I don't set MI=anything in TFM, so whatever the default is, that's what is used. The counting having been thrown off may have been the cause of my wondering why non-red frames were mainly being counted.

poisondeathray
25th January 2021, 03:34
My only concern is counting those frames that have ANY red in them (could be barely noticeable to a completely red frame).

You want something more simple ?

for a greyscale video, any chroma v > 128 would indicate your red

Because of mpeg2 lossy encoding, sometimes greyscale isn't true greyscale (ie. U and V might not be 128 exactly). You can use Greyscale() beforehand , or you might want a bit of leeway like 129 instead

If you want to see what is going on with the values, for debug purposes to tweak values or threshold, use coloryuv(analyze=true)


CombTest=BlankClip(Last,Color=color_red)
TFM(Clip2=CombTest)
TDecimate()
#coloryuv(analyze=true)
writefileif(last, "PATH\redtest.log", "(AverageChromaV > 128)", "current_frame", """ ":" """, "AverageChromaV" )

hello_hello
25th January 2021, 09:35
HH, below is at the very least a bit confusing.

global FCA = 0
global FCB = 0
global FCC = 0
Vid = last

A = WriteFile(Vid, File, "current_frame", "TheCombing", Append=Append)

B = FrameEvaluate(A, """

A = IsCombedTIVTC(MI=80)
B = IsCombedTIVTC(MI=130)
C = IsCombedTIVTC(MI=180)

FCA = A && !B && !C ? FCA + 1 : FCA
FCB = B && !C ? FCB + 1 : FCB
FCC = C ? FCC + 1 : FCC

TheCombing = " - " + \
(A && !B && !C ? string(FCA, "Thresh Norm % 6.0f") : \
B && !C ? string(FCB, "Thresh High % 6.0f") : \
C ? string(FCC, "Thresh Very High % 6.0f") : " ") """)

return B

You seem to have A var being a clip in some places, and a bool in others, same for B.
Also can be source of weird problems when doing that.

At the time, that didn't occur to me, or I figured the non-bool A and B were at a different level in the script, if that's the correct term, and therefore wouldn't interfere with each other. Something like using A and B as variables at the script level is okay, even if the script is calling a function which uses A and B for something else.

That's not the cause of the weird counting at the beginning though. It happens for the function in post #7 where A and B are only used once.

The script you quoted was just an example of how it works whether WriteFile is above or below FrameEvaluate. Like the example here. http://avisynth.nl/index.php/ScriptClip#Advanced_conditional_filtering:_part_II
I've read the info above that example, but I haven't quite got my head around it yet.

I'll check out your new script shortly, but will it work the same way if it's all inside a function? I guess I'll find out.

hello_hello
25th January 2021, 10:40
Lots to digest, there. It will take a few days. My only concern is counting those frames that have ANY red in them (could be barely noticeable to a completely red frame). I don't set MI=anything in TFM, so whatever the default is, that's what is used. The counting having been thrown off may have been the cause of my wondering why non-red frames were mainly being counted.

No it wasn't that. It just meant the counting for Thresh Low was off by three, but the corresponding frame numbers were still correct.

I haven't checked out the StainlessS script yet, but until I do, here's a function that doesn't try to be clever. It simply reports combing or not, which will correspond to whether you see any red or not. Maybe that's what I should've done in the first place.
For reasons I don't understand, there's no oddity with the counting. Maybe the different counting should have been done in separate instances of FrameEvaluate.

Anyway, for the new function you'll just see this when All=false (the default). Combing means you'll see red.

TFM(pp=1)
TDecimate()
FindCombing()

17 - Combing 1
18 - Combing 2
19 - Combing 3
20 - Combing 4
21 - Combing 5
22 - Combing 6
23 - Combing 7
24 - Combing 8
25 - Combing 9
26 - Combing 10
27 - Combing 11
28 - Combing 12

And this when All=true (the odd frames at the beginning are there but it doesn't effect the counting).

TFM(pp=1)
TDecimate()
FindCombing(All=true)

0
0
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 - Combing 1
18 - Combing 2
19 - Combing 3
20 - Combing 4
21 - Combing 5
22 - Combing 6
23 - Combing 7
24 - Combing 8
25 - Combing 9
26 - Combing 10
27 - Combing 11
28 - Combing 12

# ===============================================================================

function FindCombing(clip Vid, bool "Append", string "FileName", bool "All") {

Append = default(Append, false)
FileName = default(FileName, "")
All = default(All, false)

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 = FrameEvaluate(Vid, """

A = IsCombedTIVTC()
Count = A ? Count + 1 : Count
TheCombing = A ? string(Count, " - Combing % 6.0f") : ""

""")

Vid = !All ? WriteFileIf(Vid, File, "A", "current_frame", "TheCombing", Append=Append) : \
WriteFile(Vid, File, "current_frame", "TheCombing", Append=Append)

return Vid }

# ===============================================================================

hello_hello
25th January 2021, 12:02
I turned poisondeathray's idea into a function, as while nobody likes a smart-arse ;)
I guess for a black and white clip it can tell you how much red there is.
Once again if you don't provide a file name, the text file will be named after the script.

GreyScale()
CombTest=BlankClip(Last,Color=color_red)
TFM(Clip2=CombTest)
TDecimate()
FindRed()

# ===============================================================================

function FindRed(clip Vid, bool "Append", string "FileName", bool "All") {

Append = default(Append, false)
FileName = default(FileName, "")
All = default(All, false)

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 = FrameEvaluate(Vid, """

A = (AverageChromaV() > 128)
Count = A ? Count + 1 : Count
TheRed = A ? string(Count, " - Red %.0f") + string(AverageChromaV()-128, " - %.2f") : ""

""")

Vid = !All ? WriteFileIf(Vid, File, "A", "current_frame", "TheRed", Append=Append) : \
WriteFile(Vid, File, "current_frame", "TheRed", Append=Append)

return Vid }

# ===============================================================================

18 - Red 1 - 100.00
19 - Red 2 - 112.00
20 - Red 3 - 112.00
21 - Red 4 - 112.00
22 - Red 5 - 112.00
23 - Red 6 - 112.00
24 - Red 7 - 112.00
25 - Red 8 - 112.00
26 - Red 9 - 112.00
27 - Red 10 - 112.00
28 - Red 11 - 112.00
29 - Red 12 - 112.00
30 - Red 13 - 112.00
31 - Red 14 - 112.00
32 - Red 15 - 32.86
40 - Red 16 - 29.08
51 - Red 17 - 35.15
52 - Red 18 - 112.00
53 - Red 19 - 36.89
55 - Red 20 - 38.69
56 - Red 21 - 112.00
57 - Red 22 - 37.12
59 - Red 23 - 37.30
60 - Red 24 - 112.00
61 - Red 25 - 42.33
70 - Red 26 - 28.36
72 - Red 27 - 112.00
73 - Red 28 - 30.60
75 - Red 29 - 24.92
76 - Red 30 - 112.00
77 - Red 31 - 26.79
79 - Red 32 - 28.62
80 - Red 33 - 112.00
81 - Red 34 - 34.56
92 - Red 35 - 14.91
93 - Red 36 - 16.27
162 - Red 37 - 42.75
163 - Red 38 - 112.00
164 - Red 39 - 35.61

hello_hello
25th January 2021, 13:22
Or maybe even better, this one adds the red to the video, gives you an idea how much red there is, and also checks for combing. It has an additional argument "Write". When Write=false you can view the red without writing the output file.

FindCombingRed()

# ===============================================================================

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()

Out = FrameEvaluate(Vid2, """

A = IsCombedTIVTC(Vid1)
B = (AverageChromaV() > 128)
Count = A ? Count + 1 : Count
TheCombing = (A ? string(Count, " - Combing %.0f") : "") + \
(B ? string(AverageChromaV()-128, " - %.2f") : "")

""")

Out = !Write ? Vid2 : \
!All ? WriteFileIf(Out, File, "A", "current_frame", "TheCombing", Append=Append) : \
WriteFile(Out, File, "current_frame", "TheCombing", Append=Append)

return Out }

# ===============================================================================

17 - Combing 1
18 - Combing 2 - 100.00
19 - Combing 3 - 112.00
20 - Combing 4 - 112.00
21 - Combing 5 - 112.00
22 - Combing 6 - 112.00
23 - Combing 7 - 112.00
24 - Combing 8 - 112.00
25 - Combing 9 - 112.00
26 - Combing 10 - 112.00
27 - Combing 11 - 112.00
28 - Combing 12 - 112.00
29 - Combing 13 - 112.00
30 - Combing 14 - 112.00
31 - Combing 15 - 112.00
32 - Combing 16 - 32.86
40 - Combing 17 - 29.08
51 - Combing 18 - 35.15
52 - Combing 19 - 112.00
53 - Combing 20 - 36.89
55 - Combing 21 - 38.69
56 - Combing 22 - 112.00
57 - Combing 23 - 37.12
59 - Combing 24 - 37.30
60 - Combing 25 - 112.00
70 - Combing 26 - 28.36
72 - Combing 27 - 112.00
73 - Combing 28 - 30.60
75 - Combing 29 - 24.92
76 - Combing 30 - 112.00
77 - Combing 31 - 26.79
79 - Combing 32 - 28.62
80 - Combing 33 - 112.00
92 - Combing 34 - 14.91
161 - Combing 35
162 - Combing 36 - 42.75
163 - Combing 37 - 112.00
164 - Combing 38 - 35.61

StainlessS
25th January 2021, 14:33
HH, with the script in #19, if you return A instead of B, I think you will find it to be a Bool [ie error message, not tried it].

hello_hello
25th January 2021, 20:10
HH, with the script in #19, if you return A instead of B, I think you will find it to be a Bool [ie error message, not tried it].

I won't try it then. :)

Your script is pretty cool. I haven't tried to make a function out of it yet (I assume it'd just be a matter of wrapping it in a function and making the initial values for the counting global), but it comforts me to know the output file also contains those erroneous frames at the beginning. I'd really like to learn what's causing that.

0] ................ [FFF : 0 0 0]
0] ................ [FFF : 0 0 0]
0] ................ [FFF : 0 0 0]
1] ................ [FFF : 0 0 0]
2] ................ [FFF : 0 0 0]
3] ................ [FFF : 0 0 0]
4] ................ [FFF : 0 0 0]
5] ................ [FFF : 0 0 0]
6] ................ [FFF : 0 0 0]
7] ................ [FFF : 0 0 0]
8] ................ [FFF : 0 0 0]
9] ................ [FFF : 0 0 0]
10] ................ [FFF : 0 0 0]
11] ................ [FFF : 0 0 0]
12] ................ [FFF : 0 0 0]
13] ................ [FFF : 0 0 0]
14] ................ [FFF : 0 0 0]
15] ................ [FFF : 0 0 0]
16] ................ [FFF : 0 0 0]
17] ................ [FFF : 0 0 0]
18] ................ [FFF : 0 0 0]
19] ................ [FFF : 0 0 0]
20] ................ [FFF : 0 0 0]
21] Thresh Very High [TTT : 0 0 1]
22] Thresh Norm [TFF : 1 0 1]
23] Thresh Norm [TFF : 2 0 1]
24] Thresh Norm [TFF : 3 0 1]
25] Thresh High [TTF : 3 1 1]

StainlessS
25th January 2021, 20:26
I dont know why you have 3 frame 0's, I get 2,
its down to eg VirtualDub2 accessing/displaying frame 0 on load, and then again on play.

EDIT: With Potplayer load of avs, I only show one frame 0, starts to play from 0 immediately.

[its not a script problem, only down to app that uses script]

hello_hello
25th January 2021, 20:42
Ahhh......
I've been using MeGUI to run the analysis pass. It must be something MeGUI is doing. Probably checking the script contains no errors before running it, but without closing it again first. I'd tried loading the script, adding it to the job queue and deleting the existing text file before running the analysis pass, but it must check again. I wonder if that should be a concern when using it to run an analysis pass for something like TFM?

Analysis pass with AvsPmod.

0] ................ [FFF : 0 0 0]
1] ................ [FFF : 0 0 0]
2] ................ [FFF : 0 0 0]
3] ................ [FFF : 0 0 0]
4] ................ [FFF : 0 0 0]
5] ................ [FFF : 0 0 0]

And the earlier script I posted where I set the initial counting to -2.
I reset it back to zero and ran the analysis pass with AvsPmod.

0 - Thresh Low 1
33 - Thresh Low 2
34 - Thresh Low 3
35 - Thresh Low 4
36 - Thresh Low 5
37 - Thresh Low 6
38 - Thresh Low 7
39 - Thresh Low 8
41 - Thresh Low 9
42 - Thresh Low 10

So it was MeGUI's fault.
I might go back and edit the posts where I'd set the initial counting to -2 and change it to zero again.

hello_hello
25th January 2021, 21:06
And another Ahhhh....

I sometimes have problems with 2 pass encoding with TIVTC. Sometimes, but not always, it complains the video doesn't contain the same number of frames as the metrics files, and I discovered deleting the last frame in the metrics file fixes it. That bothers me though, because if it was caused by MeGUI, maybe I should've been deleting the first frame and I've thrown everything out by a frame. Sometimes TFM complains the CRC doesn't match and I have to physically change it. Neither of those things happen all the time though.

I've still got some metrics files handy I created with the help of MeGUI. I might run the first pass again with AvsPmod to see what the difference is.

StainlessS
25th January 2021, 21:24
More,
Vd2 must load the file initially,
and then on play, rewinds to 0 [which its already on], and plays from there, thus two frame 0's.
Does that instead of reload and play, which would call RT_FileDelete() again [deleting first 0] on the play pass, which it dont.

MeGUI is a lot better than it used to be,
at one time it use to do about 5 loads on initial adding to list, then about 7 reloads on encode [or the other way about].
[when scanning for whatever it scans for, combing or whatever it does].

Above resulted in long time delays when script involved some serious pre-scanning. [before encode started]

hello_hello
25th January 2021, 23:05
VirtualDub2 & AvsPmod managed to confuse me for a while. I tried an analysis pass with this:

TFM(Output="VTS_01_1_TFM.txt")
TDecimate(Mode=4, Output="VTS_01_1_TDecimate.txt")

If I open the script with MeGUI, start it running and then abort it, partial metrics files are written. Same if I start playback in MPC-HC and then stop playback. So I was expecting the same behaviour. For VD2 nothing was written when the analysis pass finished. Eventually I realised I also had to close the script and then the metrics files appeared. Same with AvsPmod, which confused me even more because it created empty metrics files, but they weren't written until I closed the script in the program. Odd. It took me a while to realise what was happening after running several analysis passes with no metrics files to show for it.

When I used both programs and the FindCombing function, the output file was written without having to close the script.

On the happy side... TFM and TDecimate wrote identical metrics files with all three programs, so at least it appears MeGUI isn't causing any oddness there.

StainlessS
25th January 2021, 23:52
Vdub2 and probably Vdub 1.10, used to return to frame 0 after video analysis pass, so
you might have had a frame 0 at end of file, [vdmod did not], I asked Shekh to not return to 0 in Vd2, so it dont now.
[also I sometimes like to see metrics at end of analysis, when return to 0 that messes that up, is why I use to use VDMod and AssumeFPS(250)
rather than Vd 1.10]

Danette
28th January 2021, 01:34
Using the FindCombingRed() in post #22 matches up very nicely with the red (indicating moire effect present). This is what I was looking to achieve.

I will try to build a macro, with a macro program I have, that takes the number of frames identified as red frames and reports the percentage of frames qualifying as red out of the total. This will help me decide whether or not the moire possibility is large enough to address. However, your code is a little beyond my abilities. Can you put something along the lines of WriteFileStart(xxxxx, "FrameCount") into the code, so that the total number of frames would be reported as either the first or last line?

In case you are a perfectionist, I did find four erroneous frame reports. I ran it through VDub2 (Run video analysis pass) and it missed identifying frames 71, 81 and 93 as red, but they are clearly showing as red in VDob2. Additionally, frames 17 and 161 are not red, but are showing on the list with blank values. I assume that a larger sampling, such as a 30-minute episode would have quite a few similar blank returns. These would all be false positives in a total count, but would probably be counted.

hello_hello
28th January 2021, 18:03
Can you just use FindCombingRed(All=true)?
That'll write every frame number, combed or not, and the total frame count will be the last frame number plus one (because Avisynth starts counting from zero).

I can't see any red in frame 71 using both MeGUI and VD2, but the frames either side show red. I can see red for the other two frames you mentioned though.

https://i.postimg.cc/ZCkT3XW7/01.jpg (https://postimg.cc/ZCkT3XW7)

https://i.postimg.cc/SJWmGV8y/02.jpg (https://postimg.cc/SJWmGV8y)

There are a couple of frames in the output file in post #22 that are reported as combed but for which I don't see red and there's no red reported in the output file. Frame 17 is one. I'm not sure why that's happening. Maybe TFM decides there's no combing while it's field matching, but when IsCombedTIVTC looks after field matching it sees some. That's the only explanation I can think of. I guess you can ignore those frames.


https://i.postimg.cc/bZppVbH1/03.jpg (https://postimg.cc/bZppVbH1)

https://i.postimg.cc/2LWrM7K7/04.jpg (https://postimg.cc/2LWrM7K7)

Thinking about it, the function only writes combing and red to the output file for a frame where IsCombedTIVTC returns true. I assumed if it returned false there'd be no red, but maybe that's also the difference between looking for combing during field matching and looking for combing after field matching. I'd have thought the result would be the same either way, but apparently not.

If you want it so the frame is written either way, change the appropriate section of the function to this:

Out = FrameEvaluate(Vid2, """

A = IsCombedTIVTC(Vid1)
B = (AverageChromaV() > 128)
Count = A ? Count + 1 : Count
TheCombing = (A ? string(Count, " - Combing %.0f") : " - No Combing") + \
(B ? string(AverageChromaV()-128, " - %.2f") : "")

""")

Out = !Write ? Vid2 : \
!All ? WriteFileIf(Out, File, "A || B", "current_frame", "TheCombing", Append=Append) : \
WriteFile(Out, File, "current_frame", "TheCombing", Append=Append)

That'll write to the output file when either combing is detected or there's red. When IsCombedTIVTC returns true, but there's no red, there won't be a value for red. When there's red but IsCombedTIVTC returns false, it'll write "No Combing" but still write the value for red (not that it's detecting red as such, rather it's detecting "not 100% B/W").

17 - Combing 1
18 - Combing 2 - 100.00
19 - Combing 3 - 112.00
20 - Combing 4 - 112.00
21 - Combing 5 - 112.00
22 - Combing 6 - 112.00
23 - Combing 7 - 112.00
24 - Combing 8 - 112.00
25 - Combing 9 - 112.00
26 - Combing 10 - 112.00
27 - Combing 11 - 112.00
28 - Combing 12 - 112.00
29 - Combing 13 - 112.00
30 - Combing 14 - 112.00
31 - Combing 15 - 112.00
32 - Combing 16 - 32.86
40 - Combing 17 - 29.08
51 - Combing 18 - 35.15
52 - Combing 19 - 112.00
53 - Combing 20 - 36.89
55 - Combing 21 - 38.69
56 - Combing 22 - 112.00
57 - Combing 23 - 37.12
59 - Combing 24 - 37.30
60 - Combing 25 - 112.00
61 - No Combing - 42.33
70 - Combing 26 - 28.36
72 - Combing 27 - 112.00
73 - Combing 28 - 30.60
75 - Combing 29 - 24.92
76 - Combing 30 - 112.00
77 - Combing 31 - 26.79
79 - Combing 32 - 28.62
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

Danette
28th January 2021, 23:05
If you want it so the frame is written either way, change the appropriate section of the function to this

Yes, this code only misses once which, if a full episode is involved, may greatly reduce the false negatives. Thanks.

Can you just use FindCombingRed(All=true)?
That'll write every frame number, combed or not, and the total frame count will be the last frame number minus one (because Avisynth starts counting from zero).

Unfortunately, that would not work for my purposes. Using the external macro program that I have, and using Ctrl+g in the txt file generated by your script, I can go to the last line and it will report the total lines. These lines are all red-combed (minus the first and last lines), so I can get a report on the number of total combed lines by using the Ctrl+g. Listing all lines, combed or not, makes it impossible to differentiate because the Ctrl+g would show all frames in the file and not just the red frames.

By adding the WriteFileStart(xxxxx, "FrameCount") type of thing as the last line, I can then, with the macro, grab that total frame count. Then, using both of those data points, I can automatically determine the percentage of red-combed frames in the file. This percentage will then tell me if it is worthwhile trying to address those likely moire-effect frames.

Danette
30th January 2021, 14:39
Well, I’ve tried adding “FrameCount” to hello_hello’s script, above, but cannot get it to appear as the last line in the resulting text file (I have managed to make it appear after one of the blank return lines). If anyone can show how to accomplish this, I would appreciate it.

hello_hello
30th January 2021, 22:52
I failed to think of a working condition that'd just write the last frame number to the output file, but I'll have another think about it and report back if I have any luck, otherwise maybe someone else will come up with something clever? Where's StainlessS? :)

Danette
30th January 2021, 22:57
Thanks. That makes me feel better. I tried inserting it from every angle I could think of and, if an expert is struggling to find the combination, maybe I'm not so clueless after. Then again ...

hello_hello
31st January 2021, 00:15
I think I cracked the code.
I'm far from an expert, by the way, especially when it comes to conditional filtering, but I don't mind playing around because I usually end up learning something.

The first part of the script is still the same. Once again, just change the appropriate section to this:

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") : "") : "") + \
(IsEnd ? string(FrameCount(), "%.0f") : "")

""")

Out = !Write ? Vid2 : \
!All ? WriteFileIf(Out, File, "IsComb || IsRed || IsEnd", "WriteThis", Append=Append) : \
WriteFile(Out, File, "WriteThis", Append=Append)

73 - Combing 28 - 30.60
75 - Combing 29 - 24.92
76 - Combing 30 - 112.00
77 - Combing 31 - 26.79
79 - Combing 32 - 28.62
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


If you want it labelled, change the "IsEnd" line to something like this

(IsEnd ? string(FrameCount(), "Frame Count - %.0f") : "")
or this
(IsEnd ? string(FrameCount(), "%.0f - Frame Count") : "")

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


And because I can't wrap my brain around what will happen if the last frame has red or combing, if the frame count is written on the same line as the last frame (if it is it'll only be when it's combed), I think this version of that same line should ensure there's a line break before the frame count is written. Hopefully...

((IsComb || IsRed) && IsEnd ? chr(10) : "") + (IsEnd ? string(FrameCount(), "%.0f - Frame Count") : "")

Danette
31st January 2021, 01:15
That did it! That's all I need. I'll work with the minor manipulations later, to give the line naming.

I guess it's ok to assume that the last line may be a duplicate if it is, in fact, ever combed. One approach I was considering was to add a known combed frame to the end of every script, e.g.; clip1++clip2 type of thing, where clip 2 is a known combed frame. Now, I have a much less cumbersome approach.

Thanks, again.

Danette
31st January 2021, 16:07
And because I can't wrap my brain around what will happen if the last frame has red or combing, if the frame count is written on the same line as the last frame (if it is it'll only be when it's combed), I think this version of that same line should ensure there's a line break before the frame count is written. Hopefully...

Well, this turned out to be a problem. If the last frame is red/combed, the frame count does not appear.

If you're interested in bringing this effort closer to perfection, the link to a file having the last frame combed is here: https://www.mediafire.com/file/n2la3rhlgzvh46b/Last_Line_Combed.avi/file

hello_hello
31st January 2021, 16:42
It seems okay to me, but it does require ensuring the frame count is written after a line break if the final frame is combed. At least that one worked the way it did in my head.

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") : "") : "") + \
(IsEnd ? string(FrameCount(), "%.0f - Frame Count") : "")

""")

Out = !Write ? Vid2 : \
!All ? WriteFileIf(Out, File, "IsComb || IsRed || IsEnd", "WriteThis", Append=Append) : \
WriteFile(Out, File, "WriteThis", Append=Append)


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.0081 - Frame Count

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, "WriteThis", Append=Append)


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


Don't forget the frame count will be the last frame number plus one, because Avisynth starts counting at zero.
I think I originally said it'd be the last frame number minus one, because I'm easily confused.

Danette
31st January 2021, 16:55
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.

StainlessS
31st January 2021, 17:04
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

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)
in code block #1.

hello_hello
31st January 2021, 18:48
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.

hello_hello
31st January 2021, 18:50
I see what you did, and it works, but will cause problems with my external macro involvement.

In what way? I thought it was exactly what you were after.
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?

Danette
31st January 2021, 20:22
It's outside the avs and has to do with reading a text file, but I can easily work around it. Simply more convenient if the last line in the text file is not a line also representing a frame number.

hello_hello
31st January 2021, 20:42
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.

# ===============================================================================

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 }

# ===============================================================================

hello_hello
31st January 2021, 20:44
It's outside the avs and has to do with reading a text file, but I can easily work around it. Simply more convenient if the last line in the text file is not a line also representing a frame number.

Do you want an empty last line, but other than that is it okay? I'm just trying to make sure I follow, because I'm still not sure I do.
Maybe post an example of the last few lines the way you want it.

Danette
31st January 2021, 21:08
Last line that is not identified as "combing" (therefore not a line showing a frame). It would be just the frame count, as already appears when the last frame is not combed.

hello_hello
31st January 2021, 21:16
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.

...string(FrameCount(), "%.0f"))

From your "Last Line Combed" sample:

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


The old "Red Test" sample:

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


...string(FrameCount(), "%.0f - Frame Count"))

"Last Line Combed" sample:

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


"Red Test" sample:

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


Otherwise I'll need an example of what you mean.

Danette
31st January 2021, 21:54
Oooops ...sorry, I haven't looked at your last code update. I'm back and forth today. give me some time to check it out.

hello_hello
31st January 2021, 21:55
The previous version should have been doing the same thing. This one just makes All=true behave correctly.

Danette
31st January 2021, 23:19
This is what I get when running the code in post #46:
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.0081 - Frame Count

StainlessS
1st February 2021, 00:10
... 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()


Not sure why you were having problems there, this seems to work just fine.


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
}


EDIT: Added subtitle at align=2, nothing happens there, not printed.
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.

hello_hello
1st February 2021, 00:31
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.

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")
}

Neither does this:

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")
}

This does work:

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")
}

Odd....

PS Version() says Avisynth+ 3.5 r3106

StainlessS
1st February 2021, 00:37
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.

hello_hello
1st February 2021, 00:59
defined unless provided by the caller with a value.

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.

Colorbars.ConvertToYV12.KillAudio

Return Test()

Function Test(clip c, bool "All") {
Global MyCat = false
Return MyCat ? c.Subtitle("All") : c.Subtitle("Not All")
}

If that's the way it works then it's the way it works, and now I know I know, but it's unexpected, at least to me.

hello_hello
1st February 2021, 01:11
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")
}

"All" is obviously considered undefined at the return line above because there's no error.

Yet here at the return line it's false. That seems inconsistent to me.

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")
}

Okay, maybe now I get it.
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. :)

hello_hello
1st February 2021, 01:31
This is what I get when running the code in post #46:

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.

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

StainlessS
1st February 2021, 01:34
How bout this, any good


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()

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'


Return Test("Some Test String")

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'


EDIT:

Colorbars.Subtitle(String(All))

Above, As a 1 line script would produce an error as All variable does NOT exist.

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]

All=undefined
Colorbars.Subtitle(String(All)) # String(undefined) : produces ''

Above, Would not produce an error as All variable exists, but is not defined, it has no value or type.

EDIT: Below copied here from previous posts.

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.

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.

A variable that dont exist has no entry in the Avisynth Local or Global variable List (or Table).
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".

Danette
1st February 2021, 05:47
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.

This ^

Seems to work fine, now.

I'll wait until you and StainlessS exercise everything.

Danette
2nd February 2021, 00:06
Yet another request:

Can the text lines showing up as “No Combing” be removed? They don’t indicate moire/combing, but add to the number of frames.

When I try to do it, it throws off syntax errors. I guess there is some conditional intertwining and some of the symbols, e.g.; “: \” are befuddling me.

StainlessS
2nd February 2021, 01:49
I have not really looked at it but suspect you only need call it with All=false.

Danette
4th February 2021, 05:46
In addition to asking if the script adjustment that would eliminate the “No combing” lines can be done, I am reporting some odd behavior with VDub2 and running the “FindCombingRed” function, although I suspect that it is a flaw in VDub2.

When I run a single avs file through VDub2’s “Run video analysis pass”, the results are as expected. However, when I try to load these avs files into VDub2’s “Queue batch operation”, specifying “Run video analysis pass”, the resulting text files all have a doubled “Frame count” line at the end, instead of just the one “Frame count” line that should be there. Additionally, some files result in empty text files with batch mode, but are fully populated when run alone, outside the batch process.

Is this a flaw in VDub2, or is it somehow related to the script? Remember: the avs files run perfectly when fed through VDub2 one at a time. If you think it’s VDub2, I’ll post over there.

poisondeathray
4th February 2021, 05:58
In addition to asking if the script adjustment that would eliminate the “No combing” lines can be done, I am reporting some odd behavior with VDub2 and running the “FindCombingRed” function, although I suspect that it is a flaw in VDub2.

When I run a single avs file through VDub2’s “Run video analysis pass”, the results are as expected. However, when I try to load these avs files into VDub2’s “Queue batch operation”, specifying “Run video analysis pass”, the resulting text files all have a doubled “Frame count” line at the end, instead of just the one “Frame count” line that should be there. Additionally, some files result in empty text files with batch mode, but are fully populated when run alone, outside the batch process.

Is this a flaw in VDub2, or is it somehow related to the script? Remember: the avs files run perfectly when fed through VDub2 one at a time. If you think it’s VDub2, I’ll post over there.



SS mentioned it opened a few times in vdub2, probably a few more when you queue it



Why not use batch avsr64 for the "analysis" pass. It will be faster than vdub for each run, also you don't have to queue them one by one - that ends up being much faster and less tedious


for %a in ("*.avs") do avsr64 "%a"

StainlessS
4th February 2021, 22:11
Groucho is the man:- https://forum.doom9.org/showthread.php?t=173259
[But zeppo was better]

EDIT: Down link at top of page.

EDIT: This was in answer to Danette asking where avsr64 was. The post seems to have disappeared.

Danette
4th February 2021, 23:38
SS mentioned it opened a few times in vdub2, probably a few more when you queue it



Why not use batch avsr64 for the "analysis" pass. It will be faster than vdub for each run, also you don't have to queue them one by one - that ends up being much faster and less tedious


for %a in ("*.avs") do avsr64 "%a"


Wow - ZOOM - it is quite a bit faster than VDub! Thanks for pointing me to that.

Incidentally, the bug I mentioned does seem to be specific to VDub2. I ran the batch function in my old VDub, v1.10.4, and it performed flawlessly.

hello_hello
6th February 2021, 23:43
Yet another request:

Can the text lines showing up as “No Combing” be removed? They don’t indicate moire/combing, but add to the number of frames.

When I try to do it, it throws off syntax errors. I guess there is some conditional intertwining and some of the symbols, e.g.; “: \” are befuddling me.

From the avisynth Wiki:
http://avisynth.nl/index.php/Operators
b = (a==true) ? 1 : 2
means
if (a==true) then b=1 else b=2
Although you can abbreviate it further, assuming "a" is either true or false.
b = a ? 1 : 2

For
b = (a==false) ? 1 : 2
it'd be
b = !a ? 1 : 2

" \ " is simply a line break. It can only occur at the end of a line, or before any text at the beginning of a line.
So you can do this sort of thing to make long lines readable.

b = a ? 1 : \
2

b =
\ a ? 1 : 2

Anyway...

FindRed()

# ===============================================================================

function FindRed(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 + "_Red.txt"
Vid = Vid.GreyScale()
CombTest = BlankClip(Vid, Color=color_red)
Vid = Vid.TFM(Clip2=CombTest).TDecimate()
global Everything = All

Out = FrameEvaluate(Vid, """

IsRed = (AverageChromaV() > 128)
IsEnd = (FrameCount() == (current_frame + 1))

WriteThis = \
(!IsRed && !Everything ? "" : string(current_frame)) + \
(!IsRed ? "" : string(AverageChromaV()-128, " - %.2f")) + \
(!IsEnd ? "" : (!IsRed && !Everything ? "" : chr(10)) + string(FrameCount(), "%.0f - Frame Count"))

""")

Out = !Write ? Vid : \
!All ? WriteFileIf(Out, File, "IsRed || IsEnd", "WriteThis", Append=Append) : \
WriteFile(Out, File, "WriteThis", Append=Append)

return Out }

# ===============================================================================

73 - 30.60
75 - 24.92
76 - 112.00
77 - 26.79
79 - 28.62
80 - 112.00
81 - 34.56
92 - 14.91
93 - 16.27
162 - 42.75
163 - 112.00
164 - 35.61
208 - Frame Count


If you want nothing aside from frame numbers:

WriteThis = \
(!IsRed && !Everything ? "" : string(current_frame)) + \
(!IsEnd ? "" : (!IsRed && !Everything ? "" : chr(10)) + string(FrameCount(), "%.0f"))

Although you can't use All=true because it'll write every frame number without indicating if it contains red.

73
75
76
77
79
80
81
92
93
162
163
164
208

Danette
29th October 2021, 15:46
File_Name = LeftStr(N, NLen-(NLen-ELen))


Something odd has happened. I had been using this function, successfully for many months. Then, haven't needed it for about 4 months. Now, I'm trying to use it again and I get the error message "LeftStr: Negative character count not allowed."

I've double-checked the code and it is as written, above. Nor can I recall any changes that might be interfering with it.

Any idea as to what is causing this?

StainlessS
29th October 2021, 18:56
Try insert this before error line,

RT_debugF("N=%s\nNLEN=%d\nELen=%d",N,NLen,ELen,name="Danette: ") # view in DebugView

Does your script end in .AVS, ie not .avsi.

Danette
29th October 2021, 21:07
Well, I struggled with this all morning. Then, after I inserted your debug line, it worked normally again. Go figure. Seems to be working now.

For completeness, the log for the DebugView is below. Note that this is after it started functioning again.

00000542 436.54656982 [4020] SSETools 0.1
00000543 436.76296997 [4020] Unrecognized accel key 'n ', accel string ignored.
00000544 436.76312256 [4020] Unrecognized accel key 'o ', accel string ignored.
00000545 436.76333618 [4020] Unrecognized accel key 'n ', accel string ignored.
00000546 436.76351929 [4020] Unrecognized accel key 'w ', accel string ignored.
00000547 436.76367188 [4020] Unrecognized accel key 'w ', accel string ignored.
00000548 436.76388550 [4020] Unrecognized accel key 's ', accel string ignored.
00000549 436.76409912 [4020] Unrecognized accel key 's ', accel string ignored.
00000550 436.76428223 [4020] Unrecognized accel key 'f5 ', accel string ignored.
00000551 436.76470947 [4020] Unrecognized accel key 'o ', accel string ignored.
00000552 436.76486206 [4020] Unrecognized accel key 's ', accel string ignored.
00000553 436.76504517 [4020] Unrecognized accel key 'b ', accel string ignored.
00000554 436.76519775 [4020] Unrecognized accel key 'tab ', accel string ignored.
00000555 436.76541138 [4020] Unrecognized accel key 'tab ', accel string ignored.
00000556 436.76559448 [4020] Unrecognized accel key 'p ', accel string ignored.
00000557 436.76583862 [4020] Unrecognized accel key 'x ', accel string ignored.
00000558 436.76605225 [4020] Unrecognized accel key 'z ', accel string ignored.
00000559 436.76623535 [4020] Unrecognized accel key 'y ', accel string ignored.
00000560 436.76644897 [4020] Unrecognized accel key 'x ', accel string ignored.
00000561 436.76660156 [4020] Unrecognized accel key 'c ', accel string ignored.
00000562 436.76678467 [4020] Unrecognized accel key 'v ', accel string ignored.
00000563 436.76693726 [4020] Unrecognized accel key 'f ', accel string ignored.
00000564 436.76712036 [4020] Unrecognized accel key 'f3 ', accel string ignored.
00000565 436.76733398 [4020] Unrecognized accel key 'f3 ', accel string ignored.
00000566 436.76748657 [4020] Unrecognized accel key 'h ', accel string ignored.
00000567 436.76782227 [4020] Unrecognized accel key 'f4 ', accel string ignored.
00000568 436.76803589 [4020] Unrecognized accel key 'a ', accel string ignored.
00000569 436.76824951 [4020] Unrecognized accel key 'f7 ', accel string ignored.
00000570 436.76846313 [4020] Unrecognized accel key 'f9 ', accel string ignored.
00000571 436.76864624 [4020] Unrecognized accel key 'f9 ', accel string ignored.
00000572 436.76879883 [4020] Unrecognized accel key 'f10 ', accel string ignored.
00000573 436.76901245 [4020] Unrecognized accel key 'f12 ', accel string ignored.
00000574 436.76919556 [4020] Unrecognized accel key 'f12 ', accel string ignored.
00000575 436.76934814 [4020] Unrecognized accel key 'f11 ', accel string ignored.
00000576 436.76956177 [4020] Unrecognized accel key 't ', accel string ignored.
00000577 436.76974487 [4020] Unrecognized accel key 't ', accel string ignored.
00000578 436.76995850 [4020] Unrecognized accel key 'p ', accel string ignored.
00000579 436.77011108 [4020] Unrecognized accel key 'f7 ', accel string ignored.
00000580 436.77026367 [4020] Unrecognized accel key 'f9 ', accel string ignored.
00000581 436.77038574 [4020] Unrecognized accel key 'f9 ', accel string ignored.
00000582 436.77050781 [4020] Unrecognized accel key 'f10 ', accel string ignored.
00000583 436.77062988 [4020] Unrecognized accel key 'f12 ', accel string ignored.
00000584 436.77081299 [4020] Unrecognized accel key 'f12 ', accel string ignored.
00000585 436.77093506 [4020] Unrecognized accel key 'f11 ', accel string ignored.
00000586 436.77105713 [4020] Unrecognized accel key 't ', accel string ignored.
00000587 436.77117920 [4020] Unrecognized accel key 't ', accel string ignored.
00000588 436.77136230 [4020] Unrecognized accel key 'p ', accel string ignored.
00000589 436.77151489 [4020] Unrecognized accel key 'tab ', accel string ignored.
00000590 436.77169800 [4020] Unrecognized accel key 'tab ', accel string ignored.
00000591 436.77194214 [4020] Unrecognized accel key 'q ', accel string ignored.
00000592 436.77212524 [4020] Unrecognized accel key 'q ', accel string ignored.
00000593 436.77239990 [4020] Unrecognized accel key 'space ', accel string ignored.
00000594 436.77258301 [4020] Unrecognized accel key 'space ', accel string ignored.
00000595 436.77273560 [4020] Unrecognized accel key 'space ', accel string ignored.
00000596 436.77294922 [4020] Unrecognized accel key 'space ', accel string ignored.
00000597 436.77313232 [4020] Unrecognized accel key 'd ', accel string ignored.
00000598 436.77331543 [4020] Unrecognized accel key 'f1 ', accel string ignored.
00000599 436.77349854 [4020] Unrecognized accel key 'f5 ', accel string ignored.
00000600 436.77368164 [4020] Unrecognized accel key 'space ', accel string ignored.
00000601 436.77380371 [4020] Unrecognized accel key 'space ', accel string ignored.
00000602 436.77392578 [4020] Unrecognized accel key 'space ', accel string ignored.
00000603 436.77407837 [4020] Unrecognized accel key 'space ', accel string ignored.
00000604 436.77420044 [4020] Unrecognized accel key 'd ', accel string ignored.
00000605 436.77432251 [4020] Unrecognized accel key 'f1 ', accel string ignored.
00000606 436.77444458 [4020] Unrecognized accel key 'f5 ', accel string ignored.
00000607 436.77465820 [4020] Unrecognized accel key 'up ', accel string ignored.
00000608 436.77487183 [4020] Unrecognized accel key 'down ', accel string ignored.
00000609 436.77502441 [4020] Unrecognized accel key 'c ', accel string ignored.
00000610 436.77523804 [4020] Unrecognized accel key 'up ', accel string ignored.
00000611 436.77539063 [4020] Unrecognized accel key 'down ', accel string ignored.
00000612 436.77551270 [4020] Unrecognized accel key 'c ', accel string ignored.
00000613 436.77706909 [4020] Unrecognized accel key 'b ', accel string ignored.
00000614 436.77749634 [4020] Unrecognized accel key 'b ', accel string ignored.
00000615 436.77804565 [4020] Unrecognized accel key 'f2 ', accel string ignored.
00000616 436.77822876 [4020] Unrecognized accel key 'f2 ', accel string ignored.
00000617 436.77844238 [4020] Unrecognized accel key 'right ', accel string ignored.
00000618 436.77859497 [4020] Unrecognized accel key 'left ', accel string ignored.
00000619 436.77880859 [4020] Unrecognized accel key 'down ', accel string ignored.
00000620 436.77899170 [4020] Unrecognized accel key 'up ', accel string ignored.
00000621 436.77914429 [4020] Unrecognized accel key 'pgdn ', accel string ignored.
00000622 436.77932739 [4020] Unrecognized accel key 'pgup ', accel string ignored.
00000623 436.77966309 [4020] Unrecognized accel key 'f8 ', accel string ignored.
00000624 436.77987671 [4020] Unrecognized accel key 'g ', accel string ignored.
00000625 436.78002930 [4020] Unrecognized accel key 'f2 ', accel string ignored.
00000626 436.78018188 [4020] Unrecognized accel key 'f2 ', accel string ignored.
00000627 436.78030396 [4020] Unrecognized accel key 'right ', accel string ignored.
00000628 436.78042603 [4020] Unrecognized accel key 'left ', accel string ignored.
00000629 436.78054810 [4020] Unrecognized accel key 'down ', accel string ignored.
00000630 436.78067017 [4020] Unrecognized accel key 'up ', accel string ignored.
00000631 436.78079224 [4020] Unrecognized accel key 'pgdn ', accel string ignored.
00000632 436.78094482 [4020] Unrecognized accel key 'pgup ', accel string ignored.
00000633 436.78106689 [4020] Unrecognized accel key 'f8 ', accel string ignored.
00000634 436.78118896 [4020] Unrecognized accel key 'g ', accel string ignored.
00000635 436.78140259 [4020] Unrecognized accel key 'r ', accel string ignored.
00000636 436.78152466 [4020] Unknown accel modifier: 'numpad '
00000637 436.78161621 [4020] Unknown accel modifier: 'numpad '
00000638 436.78182983 [4020] Unrecognized accel key 'numpad / ', accel string ignored.
00000639 436.78198242 [4020] Unrecognized accel key 'numpad * ', accel string ignored.
00000640 436.78225708 [4020] Unrecognized accel key 'r ', accel string ignored.
00000641 436.78228760 [4020] Unknown accel modifier: 'numpad '
00000642 436.78231812 [4020] Unknown accel modifier: 'numpad '
00000643 436.78244019 [4020] Unrecognized accel key 'numpad / ', accel string ignored.
00000644 436.78262329 [4020] Unrecognized accel key 'numpad * ', accel string ignored.
00000645 436.78286743 [4020] Unrecognized accel key 'home ', accel string ignored.
00000646 436.78305054 [4020] Unrecognized accel key 'end ', accel string ignored.
00000647 436.78326416 [4020] Unrecognized accel key 'v ', accel string ignored.
00000648 436.78363037 [4020] Unrecognized accel key 'home ', accel string ignored.
00000649 436.78378296 [4020] Unrecognized accel key 'end ', accel string ignored.
00000650 436.78390503 [4020] Unrecognized accel key 'v ', accel string ignored.
00000651 436.78436279 [4020] Unrecognized accel key 'numpad / ', accel string ignored.
00000652 436.78457642 [4020] Unknown accel modifier: 'numpad '
00000653 436.78469849 [4020] Unknown accel modifier: 'numpad '
00000654 436.78491211 [4020] Unrecognized accel key 'numpad / ', accel string ignored.
00000655 436.78494263 [4020] Unknown accel modifier: 'numpad '
00000656 436.78500366 [4020] Unknown accel modifier: 'numpad '
00000657 436.78613281 [4020] Unrecognized accel key 'f5 ', accel string ignored.
00000658 436.78662109 [4020] Unrecognized accel key 'numpad 0 ', accel string ignored.
00000659 436.78683472 [4020] Unrecognized accel key 'numpad 1 ', accel string ignored.
00000660 436.78701782 [4020] Unrecognized accel key 'numpad 2 ', accel string ignored.
00000661 436.78723145 [4020] Unrecognized accel key 'numpad 3 ', accel string ignored.
00000662 436.78741455 [4020] Unrecognized accel key 'numpad 4 ', accel string ignored.
00000663 436.78759766 [4020] Unrecognized accel key 'numpad 5 ', accel string ignored.
00000664 436.78784180 [4020] Unrecognized accel key 'numpad 0 ', accel string ignored.
00000665 436.78805542 [4020] Unrecognized accel key 'numpad 1 ', accel string ignored.
00000666 436.78820801 [4020] Unrecognized accel key 'numpad 2 ', accel string ignored.
00000667 436.78842163 [4020] Unrecognized accel key 'numpad 3 ', accel string ignored.
00000668 436.78863525 [4020] Unrecognized accel key 'numpad 4 ', accel string ignored.
00000669 436.78884888 [4020] Unrecognized accel key 'numpad 5 ', accel string ignored.
00000670 436.78903198 [4020] Unrecognized accel key 'numpad 1 ', accel string ignored.
00000671 436.78915405 [4020] Unrecognized accel key 'numpad 2 ', accel string ignored.
00000672 436.78927612 [4020] Unrecognized accel key 'numpad 3 ', accel string ignored.
00000673 436.78939819 [4020] Unrecognized accel key 'numpad 4 ', accel string ignored.
00000674 436.78952026 [4020] Unrecognized accel key 'numpad 5 ', accel string ignored.
00000675 436.78970337 [4020] Unrecognized accel key 'numpad 0 ', accel string ignored.
00000676 436.78982544 [4020] Unrecognized accel key 'numpad 1 ', accel string ignored.
00000677 436.78994751 [4020] Unrecognized accel key 'numpad 2 ', accel string ignored.
00000678 436.79006958 [4020] Unrecognized accel key 'numpad 3 ', accel string ignored.
00000679 436.79022217 [4020] Unrecognized accel key 'numpad 4 ', accel string ignored.
00000680 436.79034424 [4020] Unrecognized accel key 'numpad 5 ', accel string ignored.
00000681 436.79046631 [4020] Unrecognized accel key 'numpad 0 ', accel string ignored.
00000682 436.79064941 [4020] Unrecognized accel key 'numpad 1 ', accel string ignored.
00000683 436.79077148 [4020] Unrecognized accel key 'numpad 2 ', accel string ignored.
00000684 436.79089355 [4020] Unrecognized accel key 'numpad 3 ', accel string ignored.
00000685 436.79101563 [4020] Unrecognized accel key 'numpad 4 ', accel string ignored.
00000686 436.79113770 [4020] Unrecognized accel key 'numpad 5 ', accel string ignored.
00000687 436.79153442 [4020] Unrecognized accel key 'f5 ', accel string ignored.
00000688 436.79174805 [4020] Unrecognized accel key 'escape ', accel string ignored.
00000689 436.79190063 [4020] Unrecognized accel key 'f5 ', accel string ignored.
00000690 436.79211426 [4020] Unrecognized accel key 'f5 ', accel string ignored.
00000691 436.79223633 [4020] Unrecognized accel key 'escape ', accel string ignored.
00000692 436.79235840 [4020] Unrecognized accel key 'f5 ', accel string ignored.
00000693 436.79257202 [4020] Unrecognized accel key 'f6 ', accel string ignored.
00000694 436.79278564 [4020] Unrecognized accel key 'f6 ', accel string ignored.
00000695 436.79824829 [4020] Unrecognized accel key 'f1 ', accel string ignored.
00000696 436.81378174 [4020] Unknown accel modifier: 'numpad '
00000697 436.81381226 [4020] No accel key found, accel string ignored.
00000698 436.81393433 [4020] Unknown accel modifier: 'numpad '
00000699 436.81399536 [4020] No accel key found, accel string ignored.
00000700 436.81420898 [4020] Unrecognized accel key 'numpad /', accel string ignored.
00000701 436.81436157 [4020] Unrecognized accel key 'numpad *', accel string ignored.
00000702 436.81457520 [4020] Unrecognized accel key 'numpad 0', accel string ignored.
00000703 436.81475830 [4020] Unrecognized accel key 'numpad 1', accel string ignored.
00000704 436.81491089 [4020] Unrecognized accel key 'numpad 2', accel string ignored.
00000705 436.81509399 [4020] Unrecognized accel key 'numpad 3', accel string ignored.
00000706 436.81524658 [4020] Unrecognized accel key 'numpad 4', accel string ignored.
00000707 436.81542969 [4020] Unrecognized accel key 'numpad 5', accel string ignored.
00000708 436.81564331 [4020] Unrecognized accel key 'numpad 0', accel string ignored.
00000709 436.81579590 [4020] Unrecognized accel key 'numpad 1', accel string ignored.
00000710 436.81597900 [4020] Unrecognized accel key 'numpad 2', accel string ignored.
00000711 436.81613159 [4020] Unrecognized accel key 'numpad 3', accel string ignored.
00000712 436.81631470 [4020] Unrecognized accel key 'numpad 4', accel string ignored.
00000713 436.81649780 [4020] Unrecognized accel key 'numpad 5', accel string ignored.
00000714 436.81698608 [4020] Unrecognized accel key 'numpad /', accel string ignored.
00000715 436.81710815 [4020] Unknown accel modifier: 'numpad '
00000716 436.81716919 [4020] No accel key found, accel string ignored.
00000717 436.81726074 [4020] Unknown accel modifier: 'numpad '
00000718 436.81729126 [4020] No accel key found, accel string ignored.
00000719 452.78814697 [4020] SSETools 0.1
00000720 452.90887451 [4020] Danette: N=01 Destination Tucson (1)_Track01.avs
00000721 452.90890503 [4020] Danette: NLEN=38
00000722 452.90896606 [4020] Danette: ELen=34

StainlessS
29th October 2021, 21:25
Very strange [a bit Halloweeny].

I get same "unrecognized accel key" stuff as you from AvsPMod, maybe we got some optional script missing or something.
(I usually use PsPad and VDub2)

Danette
29th October 2021, 22:42
Yes: I am using AvsPmod, also.

kuchikirukia
2nd November 2021, 08:30
I even try to avoid mice with back/forward navigation buttons on them

Remap them to copy and paste. It's a game-changer.

hello_hello
2nd November 2021, 16:00
Remap them to copy and paste. It's a game-changer.

That's not a bad idea.

Do you remap the Windows key on the keyboard? I've been thinking of doing that for a long time but never got around to it. One day I'll accidentally tap it and my head will explode.

Danette
10th November 2021, 17:45
Well, I'm back with the same problem. This time, inserting and removing the DebugView line did not cause that odd recovery that I mentioned, above, in post 70.

It was working fine for a while. The only change, since last running it, is that I moved to AviSynth+ 3.7 and updated a lot of filters.

StainlessS
10th November 2021, 17:53
Yeah but,
what did the output to DebugView say

RT_debugF("N=%s\nNLEN=%d\nELen=%d",N,NLen,ELen,name="Danette: ")

Same line where error occurs I take it.
[EDIT: Just the RT_DebugF line, not all the AvsPMod accelerator stuff. and of course the error message]
EDIT: The line will begin with "Danette: "

EDIT: And temp remove all non used filters from plugins.

EDIT: Change to this, just incase.

RT_debugF("N=%s\nNLEN=%d\nELen=%d",string(N),string(NLen),string(ELen),name="Danette: ")

Danette
10th November 2021, 19:08
I removed nearly all filters, leaving just enough to keep this particular script operating, but the same error appeared. The error, referring to line 14, is:
LeftStr: Negative character count not allowed

I could not get this line to work:
RT_debugF("N=%s\nNLEN=%d\nELen=%d",string(N),string(NLen),string(ELen),name="Danette: ")
It threw the error message: RT_DebugF: Type='d', Expecting Int data (2)

So, I ran this, again:
RT_debugF("N=%s\nNLEN=%d\nELen=%d",N,NLen,ELen,name="Danette: ")
The DebugView results are:

[6800] Danette: N=New File (2)
[6800] Danette: NLEN=12
[6800] Danette: ELen=-1

Similar to the earlier post.

StainlessS
10th November 2021, 19:15
Oops, I changed from int (requires %d) to string() [requires %s], so should have been

RT_debugF("N=%s\nNLEN=%s\nELen=%s",string(N),string(NLen),string(ELen),name="Danette: ")

No matter.
I'll look again at the script [I remember it does look a bit wierd, but as it worked, I did not look further].

EDIT: Is it [hello_hello] script from post 46 ?

StainlessS
10th November 2021, 19:43
From previous post edit,
EDIT: Is it [hello_hello] script from post 46 ?
If it is post #46, then [EDIT: or 67]

N = ScriptFile() # Name of current script (no path)
LN = LCase(N)
NLen = StrLen(N)
ELen = FindStr(LN, ".avs") - 1 # Length left of Extension, of current scipt
File_Name = LeftStr(N, NLen-(NLen-ELen)) # Error



The DebugView results are:

[6800] Danette: N=New File (2)
[6800] Danette: NLEN=12
[6800] Danette: ELen=-1


So, looks like current script is called "New File (2)",

and this line

ELen = FindStr(LN, ".avs") - 1 # Length left of Extension, of current scipt

Cannot find the ".avs" extension in "New File (2)". (so Elen= -1, and produces error in LeftStr)

So,
question is, how come you have a avs script called "New File (2)" [without .avs extension]

EDIT: and this bit did my head in a bit,

File_Name = LeftStr(N, NLen-(NLen-ELen)) # Error Line

should it be

File_Name = LeftStr(N, ELen) # Where -ve ELen is error for LeftStr

Danette
10th November 2021, 21:49
Yes, the script is from [hello_hello] post 46, which I renamed to MoireEffect for the avsi. Don’t remember why I didn’t use post 67 (which doesn’t work, either).

Why it’s called "New File (2)", I have no idea. It is in a file having the avsi extension.

I tried replacing the
File_Name = LeftStr(N, NLen-(NLen-ELen)) # Error Line
with
File_Name = LeftStr(N, ELen) # Where -ve ELen is error for LeftStr
but the error message remains.

StainlessS
10th November 2021, 22:07
but the error message remains.
Yeah, because "New File (2)" dont have ".avs" extension.

try, replace this

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"


With

File_Name = ScriptFile().RT_FilenameSplit(14) # Drive + Path + name (no extension)
FName = (FileName == "") ? File_Name : FileName
File = FName + "_Combing.txt"
RT_DebugF("File = '%s'",File,name="Danette: ")

Danette
10th November 2021, 22:32
Removing those lines didn't work, but the replacement lines did work. At least, there is no error message being generated.

I'll try a batch run and see if that does what it should do.

I'll report back ...good or bad.

hello_hello
11th November 2021, 10:25
From post #70

00000720 452.90887451 [4020] Danette: N=01 Destination Tucson (1)_Track01.avs
00000721 452.90890503 [4020] Danette: NLEN=38
00000722 452.90896606 [4020] Danette: ELen=34

Maybe I'm even more mathematically challenged than I realised, but I've counted the characters in the file name several times and each time I've counted 37.

I could create a similar problem by starting a new script in AvsPMod.

https://i.postimg.cc/8F76TLNS/1.jpg (https://postimg.cc/8F76TLNS)

https://i.postimg.cc/kVQbpqcr/2.jpg (https://postimg.cc/kVQbpqcr)

Originally I thought the extra character in the name was the culprit, but for me it works even before saving the script to my hard drive, as long as when I create a new tab I change the name to give it an avs extension.

Did the script have an avs extension in the tab? DebugView shows it having one, but you said it was working at that time.

So the new tab name might be
>*New File (2)
and you can rename it as
>*New File (2).avs

After refreshing the video preview it becomes
*New File (2).avs
and there's no error.

It seems there's no need to actually save the script for it to work. Is there a setting I can't find for telling AvsPMod to give new tab names an avs extension? I don't know why it shouldn't, instead of waiting for the script to be saved before automatically adding it.

If the StainlessS version works you might as well use it, but this will also prevent the error. Without an avs extension, it'll just use the full file name for the text file's name. The line I changed is blue.

N = ScriptFile()
LN = LCase(N)
NLen = StrLen(N)
ELen = FindStr(LN, ".avs") - 1
File_Name = (ELen > 0) ? LeftStr(N, ELen) : N
FName = (FileName == "") ? File_Name : FileName
File = FName + "_Combing.txt"

Until the script is saved though, the text file will be written to the AvsPMod directory, assuming, I suppose, it resides somewhere where Windows will let it.

hello_hello
11th November 2021, 12:10
EDIT: and this bit did my head in a bit,

File_Name = LeftStr(N, NLen-(NLen-ELen)) # Error Line

should it be

File_Name = LeftStr(N, ELen) # Where -ve ELen is error for LeftStr


LOL! I've tried to come up with a justification for doing it that way. I'm certain I would've had one at the time, but apparently it wasn't based in reality, because it eludes me now.

So yes, this would produce exactly the same result (with the extra bit added to prevent the error when there's no extension).

N = ScriptFile()
LN = LCase(N)
NLen = StrLen(N)
ELen = FindStr(LN, ".avs") - 1
File_Name = (ELen > 0) ? LeftStr(N, ELen) : N
FName = (FileName == "") ? File_Name : FileName
File = FName + "_Combing.txt"

Edit: I've changed it in my previous post too.

Danette
11th November 2021, 21:33
File_Name = ScriptFile().RT_FilenameSplit(14) # Drive + Path + name (no extension)
FName = (FileName == "") ? File_Name : FileName
File = FName + "_Combing.txt"
RT_DebugF("File = '%s'",File,name="Danette: ")


Finished running a 36-file batch and all went well with this new code. Thanks.

Originally I thought the extra character in the name was the culprit, but for me it works even before saving the script to my hard drive, as long as when I create a new tab I change the name to give it an avs extension.

Did the script have an avs extension in the tab? DebugView shows it having one, but you said it was working at that time.

Ahhh …light bulb went on. This explains the question raised by StainlessS and, probably, why the error appeared after so many successful runs. It never occurred to me that the tab name, in AvsPmod, had anything to do with the running of the script. Apparently, it does. I think that what might have been happening, when running successfully, is that AvsPmod changes a new tab name to the name of the file with the “.avs” extension, once ANY script in that particular tab is saved. Previously, I was running the MoireEffect (my name for it) filter in tabs that had been used for other projects and saved (the filename doesn’t seem to matter, just the .avs extension).

If the StainlessS version works you might as well use it, but this will also prevent the error. Without an avs extension, it'll just use the full file name for the text file's name.

With the above knowledge, I could, now, use the original script and run successfully by simply saving a script, in AvsPmod, first. However, since StainlessS’ replacement code negates the need for that step, I’ll just keep that code, unless either of you think the alternative code is better.

hello_hello
12th November 2021, 09:17
With the above knowledge, I could, now, use the original script and run successfully by simply saving a script, in AvsPmod, first. However, since StainlessS’ replacement code negates the need for that step, I’ll just keep that code, unless either of you think the alternative code is better.

The change I added to mine only tries to remove the file extension from the name if it exists, and the StainlessS replacement effectively does the same thing, as far as I can tell, so it doesn't matter which one you use.

If you don't save the script first, where is the text file written? For me it's the AvsPmod directory. If it's the same for the StainlessS version (I assume so) you could force the text file to be written to a specific directory for unsaved scripts, but it probably makes more sense just save it first.

Having said that.... change the file path in red to whatever you prefer (it's only for unsaved scripts). If the path doesn't exist you'll get an error message. If you specify a path that would never exist (or leave it as it is), I guess you could use the error message as a reminder to save the script. Once it's saved, you can reload the video and it should work normally and the text file will be written to the same location as the script.
You'll also need to update the lines in blue.

N = ScriptFile()
LN = LCase(N)
NLen = StrLen(N)
ELen = FindStr(LN, ".avs") - 1
Dir = (StrLen(ScriptDir()) < 2) ? "Z:\Save The Script\" : ""
File_Name = (ELen > 0) ? LeftStr(N, ELen) : N
FName = (FileName == "") ? Dir + File_Name : FileName
File = FName + "_Combing.txt"
Vid = Vid.GreyScale()
CombTest = BlankClip(Vid, Color=color_red)
Vid = Vid.TFM(Clip2=CombTest).TDecimate()
global Everything = All

StainlessS
12th November 2021, 13:11
You can use below to replace/remove extension without any plugins required.

Or with no dependancies,

Function ReplaceExtension(String fn,String "Ext") { # https://forum.doom9.org/showthread.php?p=1896882#post1896882
Ext=Default(Ext,"") # Default is "", ie STRIP extension, replace with "" (Ext should include DOT eg ".mp4")
rfn=fn.RevStr
i=rfn.FindStr(".")
Return (i==0) ? fn : rfn.MidStr(i+1).RevStr + Ext
}

BlankClip(width=320,height=240)
fn="D:\TEST\Something.avs"
s1=fn.ReplaceExtension()
s2=fn.ReplaceExtension(".mp4")
Subtitle(fn + "\n" + s1 +"\n" + s2,lsp=0)


https://i.postimg.cc/d1CH5sHt/t-00.jpg (https://postimages.org/)

EDIT: It is not bullet proof, eg fn="D:\TEST.DIRECTORY\Something" would fail chopping off ".DIRECTORY\Something".

EDIT:
File_Name = ScriptFile().RT_FilenameSplit(14) # Drive + Path + name (no extension)
FName = (FileName == "") ? File_Name : FileName
File = FName + "_Combing.txt"
RT_DebugF("File = '%s'",File,name="Danette: ")
I think I cocked up there, should be

File_Name = ScriptFile().RT_FilenameSplit(7) # Drive + Path + name (no extension)




RT_FilenameSplit(string filename,int "get"=15)
Splits the un-named filename string into component parts selected by 'get' bit flags arg and returns the
parts joined together.
'Get' (default 15, 1 -> 15), If set, Bit 0=DRIVE, 1=Dir, 2=Name, 4=Extension.
Add 1 for Drive (bit 0), add 2 for Dir (bit 1), add 4 for Name (bit 2), add 8 for Extension (bit 3).
Some combinations do not make sense, eg Drive + Extension (1+8=9). Below sensible options.
1 = Drive (includes trailing ':')
2 = Dir (includes trailing '\')
3 = Drive + Dir
4 = Name
6 = Dir + Name
7 = Drive + Dir + Name
8 = Extension (includes leading '.')
12 = Name + Extension
14 = Dir + Name + Extension # No Drive part
15 = Drive + Dir + Name + Extension
Assuming a current working directory of eg "D:\avs\avi\", 'filename'="test.avi" and 'get'=15, returns "D:\avs\avi\test.avi",
so given a relative filename and default 'get'=15, is equivalent to RT_GetFullPathName(filename).

Danette
14th November 2021, 20:14
If you don't save the script first, where is the text file written? For me it's the AvsPmod directory. If it's the same for the StainlessS version (I assume so) you could force the text file to be written to a specific directory for unsaved scripts, but it probably makes more sense just save it first.

The initial problem was during preview only, before anything was saved. When I opened a new file in AvsPmod (the "New File" reported in DebugView) and applied the filter, the error message occurred. So, I stopped before trying to save the script. I now know that, had I used an AvsPmod tab that had a saved script in it, then the error message would not occur.

I'm fine, now, with StainlessS' script change, which works in the preview mode before, and after, any script saving activity.