View Full Version : Setting script's working directory
zorr
11th January 2019, 00:02
I have another question related to the AvisynthOptimizer (https://forum.doom9.org/showthread.php?t=175723) port. When the optimizer tests a new set of parameters it creates a new script into a separate directory and runs it. In order to make relative paths work I change the script's working directory to the original directory where the script was located. In Avisynth this is done easily by using SetWorkingDir() at the beginning of the script.
In Python the working directory can be changed with os.chdir() but I noticed that it doesn't have effect inside the function which FrameEval is calling unless the os.chdir() is also there. Is this by design and can it be changed so that calling os.chdir() in the beginning of the script would make the change also effective inside FrameEval()? Or is there some other workaround to change the working directory for the whole script?
ChaosKing
11th January 2019, 00:31
Why not just pass an path argument to FrameEval?
Also possibly relevant for AvisynthOptimizer: Generally I don't recommend invoking filters within FrameEval unless unavoidable, because that introduces extra overhead. See https://forum.doom9.org/showthread.php?p=1841001#post1841001
Myrsloik
11th January 2019, 10:48
I suspect you open and write a file or something. Open the file handle outside frameeval and pass it as an argument to the function or something. See the functools.partial example in the documentation.
zorr
12th January 2019, 01:34
Why not just pass an path argument to FrameEval?
Yes that's certainly possible. I was just hoping that there would be a "cleaner" option. :)
Also possibly relevant for AvisynthOptimizer:
> Generally I don't recommend invoking filters within FrameEval unless unavoidable, because that introduces extra overhead.
That's good advice right there, luckily I don't need to invoke any filters, I only need to read the frame properties, measure time and store those into a file. And the writing is only done during the last frame so file I/O should not be a bottleneck.
I suspect you open and write a file or something. Open the file handle outside frameeval and pass it as an argument to the function or something. See the functools.partial example in the documentation.
Thanks, turns out I don't need to worry about the working directory inside FrameEval after all. The optimizer sets the output file using an absolute path and that will work just fine inside FrameEval. And while the working directory will be wrong inside FrameEval I think nobody wants to open any clips in there...
By the way the optimizer works with VapourSynth scripts now. :D I'm going to do an official release this weekend. Now the question is... what to call it when it's no longer Avisynth-specific. SynthOptimizer? MetaOptimizer? ZorrIsDaManOptimizer?
StainlessS
12th January 2019, 10:24
ZorrIsDaManOptimizer, sounds pretty good, but, hows bout OptiSynth ?
Boulder
12th January 2019, 10:37
ZorrIsDaManOptimizer, sounds pretty good, but, hows bout OptiSynth ?
+1 for OptiSynth. Or ZOptiSynth :D
ChaosKing
12th January 2019, 11:26
OptiSynth sounds cool.
StainlessS
12th January 2019, 15:07
OptiSynth also name for an engine oil, Vroom, Vroom ! https://www.cosgan.de/images/smilie/verschiedene/n055.gif https://www.cosgan.de/images/smilie/verschiedene/h025.gif
lansing
12th January 2019, 15:56
The name can't be ending with -synth , it will confuse people
Groucho2004
12th January 2019, 16:12
The name can't be ending with -synth , it will confuse peopleAgreed.
I like this:
Vroom
StainlessS
12th January 2019, 16:13
The name can't be ending with -synth , it will confuse people
Dont be daft, aint nobody gonna try puttin' it in their engine. :D
EDIT: since seeing G2K4 comment, Maybe OptiVroom.
Groucho2004
12th January 2019, 16:22
Maybe OptiVroom.Hm, sounds a bit like a household cleaning appliance.
Boulder
12th January 2019, 16:24
Zoptimizer?
lansing
12th January 2019, 17:28
I would start with the creator's initial followed by the name that best describe the script, something like ZoPluginOptimizer or ZoVSPluginOptimizer
zorr
12th January 2019, 21:59
Thanks for the name ideas guys! I agree that it shouldn't be a "synth", that's a category of its own and this little software doesn't deserve to be called that.
I think the "optimizer" should be part of the name since that's what it does. And what does it optimize? Well it doesn't optimize Avisynth or Vapoursynth so the original name is kinda wrong too. Lansing was closer with the "plugin" idea, but it really doesn't optimize plugins either. It optimizes scripts. So... ScriptOptimizer?
If we stick with original name format we could just replace AviSynth with something more general. It's just hard to come up with a word that would explain succinctly what it and Vapoursynth are... "frameserving tool for video manipulation"? Ok how about we take the common parts from both Avisynth and Vapoursynth and slap the optimizer in there as well. Something like XSynthOptimizer. Hey if I call it XXXSynthOptimizer it would crash the whole forum as there would be so much interest! ;)
There's also another dilemma, where should I put the thread for this tool? I could make a new thread here for Vapoursynth related discussion and keep the original for Avisynth related things. Might be hard to know where to ask more general questions though.
vBulletin® v3.8.11, Copyright ©2000-2025, vBulletin Solutions Inc.