VideoHelp Forum
+ Reply to Thread
Results 1 to 16 of 16
Thread
  1. Member
    Join Date
    Mar 2008
    Location
    United States
    Search Comp PM
    I want to display a variable value in Avisynth for debuggin purpose but this does not work.

    varfirsquarter=top_banner.FrameCount*.25

    return combined.Subtitle(varfirsquarter , text_color=$000000, x=25, y=11, font ="Arial", size=60, first_frame =0, last_frame = 200, lsp=30, align=7, spc =62, halo_color=$ffffff)

    How does one display variable values for debugging?
    Quote Quote  
  2. Member AlanHK's Avatar
    Join Date
    Apr 2006
    Location
    Hong Kong
    Search Comp PM
    Originally Posted by lindylex
    I want to display a variable value in Avisynth for debuggin purpose but this does not work.
    What do you mean "does not work?
    Is there an error message?
    If so, what?

    And please post the entire script, the fragment you posted refers to undefined things. I can't tell if your variables refer to numbers, functions, clips or what.

    Also for esoteric Avisynth questions the best place to ask is the
    Doom 9 forum.
    Quote Quote  
  3. Member
    Join Date
    Mar 2008
    Location
    United States
    Search Comp PM
    This is one possible solution. I am interested in how others output variables for debugging?

    AlanHK, sorry you do not understand.

    I have a variable named "varfirsquarter" I want to store the first quarter in length of the movie "top_banner" in that variable. To do that I do this.

    varfirsquarter=top_banner.FrameCount*.25

    I wanted to see what the variable value was. So I decided to use the "Subtitle" method but it only takes strings. So I had to convert the number in my variable to a string by doing this "string (varfirsquarter)".

    This is a solution.

    return combined.Subtitle(string (varfirsquarter), text_color=$000000, x=25, y=11, font ="Arial", size=60, first_frame =0, last_frame = 200, lsp=30, align=7, spc =62, halo_color=$ffffff)

    Does anyone have a different, better way of checking variable values for debgging?

    Thanks Lindylex
    Quote Quote  
  4. Member AlanHK's Avatar
    Join Date
    Apr 2006
    Location
    Hong Kong
    Search Comp PM
    Originally Posted by lindylex
    Does anyone have a different, better way of checking variable values for debugging?
    I think "Subtitle" is the only way in general.

    But if you're just debugging, you don't need to bother with all the parameters of subtitle.

    Just:
    Code:
    BlankClip(500)
    top_banner=last
    varfirsquarter=top_banner.FrameCount*.25 
    Subtitle(string (varfirsquarter))
    Or define your own function if you want to set different subtitle defaults.
    Quote Quote  
  5. Member
    Join Date
    Mar 2008
    Location
    United States
    Search Comp PM
    AlanHK, thanks I was just using one of my previous used subtitle method calls. It definitely did not need so many parameter to display my variable value.

    Thanks
    Quote Quote  
  6. Member
    Join Date
    Mar 2008
    Location
    United States
    Search Comp PM
    It looks like you can use the following to help debug also.

    filename = "c:\myprojects\output.txt"
    # create a test video to get frames
    Version()

    # the expression here is only a variable, which is evaluated and put in the file
    # you will get a file with the framenumber in each line


    WriteFile(filename, "current_frame")

    # this line is written when the script is opened
    WriteFileStart(filename, """ "This is the header" """)

    # and this when the script is closed
    WriteFileEnd(filename, """ "Now the script was closed" """)

    ////// AND ScriptClip method //////

    .ScriptClip(" Subtitle(String(current_frame)) ")
    Quote Quote  
  7. Member AlanHK's Avatar
    Join Date
    Apr 2006
    Location
    Hong Kong
    Search Comp PM
    Yes, I forgot those.

    And if you aren't already using AvsP, get it immediately.
    It has many useful features for editing Avisynth scripts.
    Quote Quote  
  8. Member
    Join Date
    Mar 2008
    Location
    United States
    Search Comp PM
    I currently use it or maybe even under use it. I'm sure there are good primer out there? What do you recommend?
    Quote Quote  
  9. Member AlanHK's Avatar
    Join Date
    Apr 2006
    Location
    Hong Kong
    Search Comp PM
    Originally Posted by lindylex
    I currently use it or maybe even under use it. I'm sure there are good primer out there? What do you recommend?
    The author's documentation is quite good.

    Otherwise browse the topic in Doom 9.
    http://forum.doom9.org/showthread.php?t=129385

    Unfortunately, after an initial period of rapid development, the author appears to have stopped work on it.
    But its extensibility, allowing you to add your own functions and macros, makes it very flexible.
    Quote Quote  
  10. Member
    Join Date
    Jul 2009
    Location
    Spain
    Search Comp PM
    Originally Posted by lindylex
    ScriptClip(" Subtitle(String(current_frame)) ")
    I know this is probably just an example, but if all you want to do is show the current frame number, you can just use ShowFrameNumber().
    Quote Quote  
  11. Gavino, do you know how to get the current frame number as a variable? For example, I want to do something like:

    Crop(FrameNumber,0,720,480)

    to pan across a large frame.
    Quote Quote  
  12. Member
    Join Date
    Jul 2009
    Location
    Spain
    Search Comp PM
    The variable current_frame is available inside run-time filters like ScriptClip.

    But something like panning is best done by using Animate, applied either to Crop or to a resizer with the extra cropping parameters (smoother because of sub-pixel movement).
    Quote Quote  
  13. Originally Posted by Gavino
    The variable current_frame is available inside run-time filters like ScriptClip.
    I must be missing something. Whenever I try to use current_frame I get an error message: "I don't know what current_frame means".

    Code:
    AviSource("uncompressed rgb.avi")
    Crop(current_frame,0,320,240)
    Ah, nevermind. I see you have to use ScriptClip() (or one of the other special runtime functions):

    Code:
    AviSource("uncompressed rgb.avi")
    ScriptClip("Crop(current_frame,0,320,240)")
    And it doesn't like it if the returned clip dimensions are different. Guess I have some more reading to do...
    Quote Quote  
  14. Member
    Join Date
    Jul 2009
    Location
    Spain
    Search Comp PM
    Yes, outside the 'run-time environment', the concept of the 'current' frame makes no sense, because it's dealing with entire clips.

    Your example could be written as
    Animate(0, frameCount-1, "Crop", 0, 0, 320, 240, frameCount-1, 0, 320, 240)
    which varies the first parameter from 0 to frameCount-1 over the length of the video.
    Quote Quote  
  15. Originally Posted by Gavino
    Your example could be written as
    Animate(0, frameCount-1, "Crop", 0, 0, 320, 240, frameCount-1, 0, 320, 240)
    which varies the first parameter from 0 to frameCount-1 over the length of the video.
    Yes, but I was just using Crop() as a simple example of where one could use the current frame number. I've had other reasons for wanting conditional processing based on frame number in the past.

    Thanks for steering me in the right direction...
    Quote Quote  
  16. Member
    Join Date
    Jul 2009
    Location
    Spain
    Search Comp PM
    You're more than welcome - glad to be able to help.

    If you get into serious use of ScriptClip and friends, you might be interested in my GRunT plugin, which addresses some of their usability problems, particularly inside script functions.
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!