VideoHelp Forum




+ Reply to Thread
Results 1 to 14 of 14
  1. Member
    Join Date
    Sep 2008
    Location
    United States
    Search Comp PM
    I am wondering if AviSynth has a built in path variable, which basically stores the string that corresponds to the current path where .avs file resides on the hard drive. (For instance, if you are familiar with batch file programming in DOS, that would correspond to %~dp0)

    The reason for that is makeAVIS.
    Usually, I keep .avs file in the same folder as the video files I reference with it. Thus, I typically would only need to specify the file name, rather than the full path.

    e.g.

    Code:
    file_a = "VideoA.avi"
    file_b = "VideoB.avi"
    AVISource(file_a)
    AVISource(file_b)
    ...
    That's fine until I try to use makeAVIS which for some reason requires that I use absolute paths.

    So, my solution has been to have a script_path variable:

    Code:
    script_path = "<current avs path>\"
    ...
    ...
    AVISource(script_path+file_a)
    ...
    The slight problem with that is that if I move my files to a different folder, I have to make sure to change that script_path variable, too.
    And if I have many .avs files that gets to be a drag.

    So, if there was a built in "script_path" variable, which I didn't have to define explicitly in my code, that would be so great.

    Thanks,
    a1
    Quote Quote  
  2. Member AlanHK's Avatar
    Join Date
    Apr 2006
    Location
    Hong Kong
    Search Comp PM
    Control functions
    SetWorkingDir | v2 | SetWorkingDir(path)
    Sets the default directory for AviSynth to the path argument.
    This is primarily for easy loading of source clips, importing scripts, etc. It does not affect plugins' autoloading.
    Return value is 0 if successful, -1 otherwise.

    Examples:

    SetWorkingDir("c:\my_presets")
    AviSource("border_mask.avi") # this loads c:\my_presets\border_mask.avi
    But you'd still have to set it in each script.

    You could have one script in each folder that defined the directory and Import it into each script.
    Or you could put it as an AVSI in your Plugins folder and it would be automatically imported; you would only have to update that one script.

    You could write a batch file to create your definition file.

    Sign up at http://forum.doom9.org/index.php and ask there; that's where you find the gurus.
    Last edited by AlanHK; 12th Nov 2010 at 02:12.
    Quote Quote  
  3. Member
    Join Date
    Jul 2009
    Location
    Spain
    Search Comp PM
    There is a GetWorkingDir in stickboy's GetSystemEnv plugin.

    There is also a hack (again by stickboy) which gets the name of the current script file:
    http://forum.doom9.org/showthread.php?p=413006#post413006

    However, I don't understand why there is a problem with makeAVIS.
    Inside Avisynth, the current folder is set to the one containing the script file, so
    AviSource("VideoA.avi")
    should always work if VideoA.avi is in the same folder as the script.
    Perhaps makeAVIS is copying the script to another folder, in which case knowing what the current folder is won't help you to find the video files.
    Quote Quote  
  4. Member
    Join Date
    Sep 2008
    Location
    United States
    Search Comp PM
    Gavino, you are probably right about makeAVIS copying the .avs somewhere. (GetWorkingDir doesn't work with it).

    Probably have to just keep renaming my path variable manually each time I move my files.
    Quote Quote  
  5. Member
    Join Date
    Sep 2008
    Location
    United States
    Search Comp PM
    Actually, is there any easy way to have avisynth display the "GetWorkingDir" in a message box before it throws up the error about files not found?
    That way I could at least know where makeAVIS is putting it.
    Quote Quote  
  6. Member
    Join Date
    Jul 2009
    Location
    Spain
    Search Comp PM
    Not a message box, but you could write it to a file using
    WriteFileStart(BlankClip(), "C:\mydir\workingdir.txt", "GetWorkingDir()")

    Alternatively, use the full path in AviSource (to avoid the error) and then
    Subtitle(GetWorkingDir())
    to display it on the output.
    Quote Quote  
  7. Member
    Join Date
    Sep 2008
    Location
    United States
    Search Comp PM
    Got it. So, it is basically whereever I happen to run makeAVIS from. (I open my command line, and it goes to c:\Documents and Settings\my username

    So an easy work around is:

    I use batch files (that reside in a folder that's on system path). One batch file is called makeavis1.bat. As an argument it accepts one avs file and makes avi file with the same name/path as avs.

    So, before the line in my batch file that calls makeavis.exe, I simply cd "%~dp1", which changes the directory to the one where my .avs file is.


    Good enough for me.
    Quote Quote  
  8. Member
    Join Date
    Sep 2008
    Location
    United States
    Search Comp PM
    Ok, found a problem.

    So, even though my trick does get makeavis to compile the avs into avi (I use the -V switch so I see that it seemingly does it correctly).
    Then, when I try to open it, the compiled avi file, in virtualdub I get the error:

    ---------------------------
    ffdshow error
    ---------------------------
    AVISource autodetect: couldn't open file 'C:\Documents and Settings\my username\<name of the avi file that my avs script is trying to reference>'
    Error code: 2
    (ffdshow_dec_avisynth_script, line 6)
    ---------------------------
    OK
    ---------------------------
    Needless to say, pulling .avs directly into VirtualDub works fine.


    So, as soon as I change my path variable to use an explicit path ("C:\PathToMyAVIFile\"), instead of GetWorkingDir(), the compiled AVI opens correctly.
    Quote Quote  
  9. Member AlanHK's Avatar
    Join Date
    Apr 2006
    Location
    Hong Kong
    Search Comp PM
    Originally Posted by a1s2d3f4 View Post
    Ok, found a problem.

    So, even though my trick does get makeavis to compile the avs into avi (I use the -V switch so I see that it seemingly does it correctly).
    Then, when I try to open it, the compiled avi file, in virtualdub I get the error:
    I get that sometimes when displaying an AVS file using AvsP.
    Usually just "F5", reload, and it comes up fine.
    Quote Quote  
  10. Member
    Join Date
    Sep 2008
    Location
    United States
    Search Comp PM
    I need AVS to turn into "fake" AVIs so that I can open them in my video editor (which doesn't understand what to do with AVS files).
    Quote Quote  
  11. Originally Posted by Gavino View Post
    There is a GetWorkingDir in stickboy's GetSystemEnv plugin.

    There is also a hack (again by stickboy) which gets the name of the current script file:
    http://forum.doom9.org/showthread.php?p=413006#post413006

    However, I don't understand why there is a problem with makeAVIS.
    Inside Avisynth, the current folder is set to the one containing the script file, so
    AviSource("VideoA.avi")
    should always work if VideoA.avi is in the same folder as the script.
    Perhaps makeAVIS is copying the script to another folder, in which case knowing what the current folder is won't help you to find the video files.

    Very big newbie here. I got thrown into this for encoding HD video files down to SD. My problem is that i get an error message from VirtualDub (below) and i even have the plugin GetSystemEnv.dll. I've hit a brick wall and this is the closest thread i've found that resembles my problem. Is there a work around? or am i missing a step i don't see?

    Error Message:
    Avisynth open failure:
    Script error: there is no function named "GetWorkingDir"
    (aviSynthPluginsdir.avsi, line 1)

    Go easy on me, i'm very new and have been working on trying to get my .d2v file into virtualdub for over a week now and keep running into errors.

    Hopefully one of you amazing guru's can help this poor soul!
    Quote Quote  
  12. Member AlanHK's Avatar
    Join Date
    Apr 2006
    Location
    Hong Kong
    Search Comp PM
    Originally Posted by TheSuperBeanie View Post
    this is the closest thread i've found that resembles my problem
    No, it's nothing to do with your problem.
    Start a new thread and in that quote your entire AVS script if you want any useful help.
    Quote Quote  
  13. No, it's nothing to do with your problem.
    Start a new thread and in that quote your entire AVS script if you want any useful help.[/QUOTE]

    Thanks for the advice, I realized that very quickly and have created a new thread.
    https://forum.videohelp.com/threads/388548-HD-to-SD-encoding-with-DGindex-Avisynth-VirtualDub
    Quote Quote  
  14. By the way, to answer the original question (a little late, I know), AviSynth now has the ScriptDir function; it returns the path of the loaded script as a string.
    Quote Quote  



Similar Threads

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