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

Reply
 
Thread Tools Search this Thread Display Modes
Old 27th June 2014, 17:03   #1  |  Link
fvisagie
Registered User
 
Join Date: Aug 2008
Location: Isle of Man
Posts: 588
Indented block statements

Hi All,

What is the simplest way of creating indented multi-level block statements, when most levels have quoted strings and the block statements aren't easily moved to a function? Although the example below is from runtime script, I also come across this scenario in other cases.

For example, to this script
Code:
ScriptClip(c, """
    global MF_activeclips = MF_activeclips + 1
    global sequence = sequence + "b" + String(MF_activeclips)
    INFO = """" + Eval("MF_source" + String(MF_registeredclips)) + """" + " " + \
            String(current_frame) + "=" + MF_Frames2INFO(current_frame + Int(Value("""" + tcoffsetstr + """")), Value("""" + String(fps) + """"))
    Eval("global MF_INFO" + String(MF_activeclips) + "=INFO")
    MF_show == "Clip" || MF_show == "ClipFast" \
        ?   MF_ShowINFO(INFO) \
        :   last
""", show=false, after_frame=false)
I need to add another condition level as follows
Code:
ScriptClip(c, """
    current_frame != MF_clipbefore \
        ?   Eval("
                global MF_clipbefore = current_frame
                global MF_label = "label"
                all_of_the_above
            ") \
        :   last
""", show=false, after_frame=false)
However, adding quoted expressions to the Eval() statement as above causes a runtime syntax error, not even to mention quoted expressions in the newly indented level.

Thanks,
Francois

Last edited by fvisagie; 27th June 2014 at 17:05.
fvisagie is offline   Reply With Quote
Old 27th June 2014, 19:39   #2  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,431
Quote:
Originally Posted by fvisagie View Post
What is the simplest way of creating indented multi-level block statements
Are you aware of GScript?
__________________
GScript and GRunT - complex Avisynth scripting made easier
Gavino is offline   Reply With Quote
Old 28th June 2014, 14:38   #3  |  Link
fvisagie
Registered User
 
Join Date: Aug 2008
Location: Isle of Man
Posts: 588
I am, thanks Gavino, but not that it could be of help in cases like this, as your question seems to imply. Would you mind showing how GScript might help here?

Thanks.
fvisagie is offline   Reply With Quote
Old 28th June 2014, 18:20   #4  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
This method works ok but initializes GScript at every frame
Code:
Function WhatAmI(clip c,int current_frame) {
    GSCript("""
        c
        Txt = "I dont know what I am !"
        if(isYUV) {
            if(isYV12) {
                Txt ="I am YV12"
            } Else if(isYUY2) {
                Txt="I am YUY2"
            } Else if(isYV16) {
                Txt="I am YV16"
            } Else if(isYV24) {
                Txt="I am YV24"
            } Else if(isYV411) {
                Txt="I am YV411"
            } Else if(isY8) {
                Txt="I am Y8"
            } Else {
                Txt="I am some kind of YUV"
            }
        } Else if (IsRGB) {
            if(isRGB24) {
                Txt="I am RGB24"
            } Else if(isRGB32) {
                Txt="I am RGB32"
            } Else {
                Txt="I am some kind of RGB"
            }
        }
        Subtitle(String(current_frame)+"] "+Txt)
    """)
}

c=avisource("D:\avs\test.avi")
c
ConvertToYV24
ScriptClip("WhatAmI(Last,current_frame)", show=false, after_frame=false)
Return ConvertToRGB32() # if v2.6 colorspace
This is a bit more fiddly, but GSCript initialized only once.
Code:
FnS="""
    Function WhatAmI(clip c,int current_frame) {
        c
        Txt = "I dont know what I am !"
        if(isYUV) {
            if(isYV12) {
                Txt ="I am YV12"
            } Else if(isYUY2) {
                Txt="I am YUY2"
            } Else if(isYV16) {
                Txt="I am YV16"
            } Else if(isYV24) {
                Txt="I am YV24"
            } Else if(isYV411) {
                Txt="I am YV411"
            } Else if(isY8) {
                Txt="I am Y8"
            } Else {
                Txt="I am some kind of YUV"
            }
        } Else if (IsRGB) {
            if(isRGB24) {
                Txt="I am RGB24"
            } Else if(isRGB32) {
                Txt="I am RGB32"
            } Else {
                Txt="I am some kind of RGB"
            }
        }
        Subtitle(String(current_frame)+"] "+Txt)
    }
    Return ScriptClip("WhatAmI(Last,current_Frame)", show=false, after_frame=false)
"""


c=avisource("D:\avs\test.avi")
c
ConvertToYV24
GScript(FnS)
Return ConvertToRGB32() # if v2.6 colorspace
This is a bit like GImport
Code:
FnS="""
    Function WhatAmI(clip c,int current_frame) {
        c
        Txt = "I dont know what I am !"
        if(isYUV) {
            if(isYV12) {
                Txt ="I am YV12"
            } Else if(isYUY2) {
                Txt="I am YUY2"
            } Else if(isYV16) {
                Txt="I am YV16"
            } Else if(isYV24) {
                Txt="I am YV24"
            } Else if(isYV411) {
                Txt="I am YV411"
            } Else if(isY8) {
                Txt="I am Y8"
            } Else {
                Txt="I am some kind of YUV"
            }
        } Else if (IsRGB) {
            if(isRGB24) {
                Txt="I am RGB24"
            } Else if(isRGB32) {
                Txt="I am RGB32"
            } Else {
                Txt="I am some kind of RGB"
            }
        }
        Subtitle(String(current_frame)+"] "+Txt)
    }
"""


c=avisource("D:\avs\test.avi")
c
ConvertToYV24
GScript(FnS) # Init Function
ScriptClip("WhatAmI(Last,current_Frame)", show=false, after_frame=false)
Return ConvertToRGB32() # if v2.6 colorspace
I'm sure Gavino has a neater way.

EDIT: And of course the obvious way, which I forgot.
Code:
GSCript("""
    Function WhatAmI(clip c,int current_frame) {
        c
        Txt = "I dont know what I am !"
        if(isYUV) {
            if(isYV12) {
                Txt ="I am YV12"
            } Else if(isYUY2) {
                Txt="I am YUY2"
            } Else if(isYV16) {
                Txt="I am YV16"
            } Else if(isYV24) {
                Txt="I am YV24"
            } Else if(isYV411) {
                Txt="I am YV411"
            } Else if(isY8) {
                Txt="I am Y8"
            } Else {
                Txt="I am some kind of YUV"
            }
        } Else if (IsRGB) {
            if(isRGB24) {
                Txt="I am RGB24"
            } Else if(isRGB32) {
                Txt="I am RGB32"
            } Else {
                Txt="I am some kind of RGB"
            }
        }
        Subtitle(String(current_frame)+"] "+Txt)
    }
""")


c=avisource("D:\avs\test.avi")
c
ConvertToYV24
ScriptClip("WhatAmI(Last,current_Frame)", show=false, after_frame=false)
Return ConvertToRGB32() # if v2.6 colorspace
__________________
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; 29th June 2014 at 10:03.
StainlessS is offline   Reply With Quote
Old 29th June 2014, 09:47   #5  |  Link
fvisagie
Registered User
 
Join Date: Aug 2008
Location: Isle of Man
Posts: 588
Thanks. I've also managed to come up with something, really crude though .
fvisagie is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

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

Forum Jump


All times are GMT +1. The time now is 15:10.


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