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

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

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage
Register FAQ Calendar Today's Posts Search

Reply
 
Thread Tools Search this Thread Display Modes
Old 18th January 2021, 20:01   #1  |  Link
Danette
Registered User
 
Join Date: Apr 2013
Posts: 346
Count/Display/Save Frames Containing Red

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?

Last edited by Danette; 18th January 2021 at 20:07.
Danette is offline   Reply With Quote
Old 19th January 2021, 10:02   #2  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,829
%^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)

Code:
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     }

Last edited by hello_hello; 20th January 2021 at 17:47.
hello_hello is offline   Reply With Quote
Old 19th January 2021, 14:14   #3  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
HH [AKA Gort],
FireFox Addons [TextAreaCache]:- https://forum.doom9.org/showthread.php?t=177066

Quote:
Originally Posted by StainlessS View Post

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/fir...extarea-cache/

Also available for Chrome:- https://chrome.google.com/webstore/d...hcmnbmab?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/ne...extarea-cache/
https://www.raymond.cc/blog/saving-w...our-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,

Quote:
EDIT: TextAreaCache (first post) has recently saved me about 3 or four more times, I'm very happy with it.
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 19th January 2021 at 14:32.
StainlessS is offline   Reply With Quote
Old 19th January 2021, 17:44   #4  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,829
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.
hello_hello is offline   Reply With Quote
Old 19th January 2021, 20:51   #5  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,431
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.
__________________
GScript and GRunT - complex Avisynth scripting made easier
Gavino is offline   Reply With Quote
Old 19th January 2021, 21:43   #6  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,829
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)

Code:
# ===============================================================================

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  }

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

Last edited by hello_hello; 21st January 2021 at 18:38.
hello_hello is offline   Reply With Quote
Old 21st January 2021, 23:20   #7  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,829
Ahhh, now I get it....
Counting without the external functions.

Code:
# ==================================================================================
# ==================================================================================

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  }

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

Last edited by hello_hello; 25th January 2021 at 20:45.
hello_hello is offline   Reply With Quote
Old 22nd January 2021, 13:40   #8  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Dont think you need the globals.
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???
StainlessS is offline   Reply With Quote
Old 22nd January 2021, 17:32   #9  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,431
Quote:
Originally Posted by StainlessS View Post
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.
__________________
GScript and GRunT - complex Avisynth scripting made easier
Gavino is offline   Reply With Quote
Old 22nd January 2021, 19:13   #10  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,829
Quote:
Originally Posted by StainlessS View Post
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.

Code:
try{FCA = A && !B && !C ? FCA + 1 : FCA}catch(err){FCA = 1}
Quote:
Originally Posted by Gavino View Post
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:

Code:
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

Last edited by hello_hello; 24th January 2021 at 19:54.
hello_hello is offline   Reply With Quote
Old 22nd January 2021, 19:34   #11  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Quote:
Originally Posted by Gavino View Post
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.
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 22nd January 2021 at 19:38.
StainlessS is offline   Reply With Quote
Old 22nd January 2021, 20:28   #12  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,431
Quote:
Originally Posted by hello_hello View Post
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.
__________________
GScript and GRunT - complex Avisynth scripting made easier
Gavino is offline   Reply With Quote
Old 23rd January 2021, 18:50   #13  |  Link
Danette
Registered User
 
Join Date: Apr 2013
Posts: 346
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/ybqme..._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.

Last edited by Danette; 23rd January 2021 at 18:57.
Danette is offline   Reply With Quote
Old 24th January 2021, 19:41   #14  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,829
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.

Code:
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.

Code:
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.



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



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



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

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.

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

Last edited by hello_hello; 25th January 2021 at 20:47.
hello_hello is offline   Reply With Quote
Old 24th January 2021, 20:20   #15  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
HH, below is at the very least a bit confusing.
Code:
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.
Quote:
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:
Quote:
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.
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 24th January 2021 at 21:02.
StainlessS is offline   Reply With Quote
Old 24th January 2021, 23:13   #16  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
HH,
I think this does as you were wantin', [without the -2, or Advanced Runtime Scripting headache]

Code:
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
Code:
 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]
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 24th January 2021 at 23:38.
StainlessS is offline   Reply With Quote
Old 25th January 2021, 03:09   #17  |  Link
Danette
Registered User
 
Join Date: Apr 2013
Posts: 346
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.
Danette is offline   Reply With Quote
Old 25th January 2021, 03:34   #18  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 5,377
Quote:
Originally Posted by Danette View Post
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)

Code:
CombTest=BlankClip(Last,Color=color_red)
TFM(Clip2=CombTest)
TDecimate()
#coloryuv(analyze=true)
writefileif(last, "PATH\redtest.log", "(AverageChromaV > 128)", "current_frame", """ ":" """,  "AverageChromaV" )
poisondeathray is offline   Reply With Quote
Old 25th January 2021, 09:35   #19  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,829
Quote:
Originally Posted by StainlessS View Post
HH, below is at the very least a bit confusing.
Code:
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/ScriptC...ering:_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.

Last edited by hello_hello; 25th January 2021 at 10:49.
hello_hello is offline   Reply With Quote
Old 25th January 2021, 10:40   #20  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,829
Quote:
Originally Posted by Danette View Post
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()

Code:
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)

Code:
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
Code:
# ===============================================================================

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  }

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

Last edited by hello_hello; 25th January 2021 at 10:42.
hello_hello is offline   Reply With Quote
Reply


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

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

Forum Jump


All times are GMT +1. The time now is 05:42.


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