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 10th November 2021, 22:07   #81  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Quote:
but the error message remains.
Yeah, because "New File (2)" dont have ".avs" extension.

try, replace this
Code:
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"
With
Code:
File_Name = ScriptFile().RT_FilenameSplit(14)  # Drive + Path + name (no extension)
FName = (FileName == "") ? File_Name : FileName
File = FName + "_Combing.txt"
RT_DebugF("File = '%s'",File,name="Danette: ")
__________________
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; 10th November 2021 at 22:34.
StainlessS is offline   Reply With Quote
Old 10th November 2021, 22:32   #82  |  Link
Danette
Registered User
 
Join Date: Apr 2013
Posts: 346
Removing those lines didn't work, but the replacement lines did work. At least, there is no error message being generated.

I'll try a batch run and see if that does what it should do.

I'll report back ...good or bad.
Danette is offline   Reply With Quote
Old 11th November 2021, 10:25   #83  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,829
From post #70

00000720 452.90887451 [4020] Danette: N=01 Destination Tucson (1)_Track01.avs
00000721 452.90890503 [4020] Danette: NLEN=38
00000722 452.90896606 [4020] Danette: ELen=34

Maybe I'm even more mathematically challenged than I realised, but I've counted the characters in the file name several times and each time I've counted 37.

I could create a similar problem by starting a new script in AvsPMod.





Originally I thought the extra character in the name was the culprit, but for me it works even before saving the script to my hard drive, as long as when I create a new tab I change the name to give it an avs extension.

Did the script have an avs extension in the tab? DebugView shows it having one, but you said it was working at that time.

So the new tab name might be
>*New File (2)
and you can rename it as
>*New File (2).avs

After refreshing the video preview it becomes
*New File (2).avs
and there's no error.

It seems there's no need to actually save the script for it to work. Is there a setting I can't find for telling AvsPMod to give new tab names an avs extension? I don't know why it shouldn't, instead of waiting for the script to be saved before automatically adding it.

If the StainlessS version works you might as well use it, but this will also prevent the error. Without an avs extension, it'll just use the full file name for the text file's name. The line I changed is blue.

N = ScriptFile()
LN = LCase(N)
NLen = StrLen(N)
ELen = FindStr(LN, ".avs") - 1
File_Name = (ELen > 0) ? LeftStr(N, ELen) : N
FName = (FileName == "") ? File_Name : FileName
File = FName + "_Combing.txt"

Until the script is saved though, the text file will be written to the AvsPMod directory, assuming, I suppose, it resides somewhere where Windows will let it.

Last edited by hello_hello; 11th November 2021 at 12:17.
hello_hello is offline   Reply With Quote
Old 11th November 2021, 12:10   #84  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,829
Quote:
Originally Posted by StainlessS View Post
EDIT: and this bit did my head in a bit,
Code:
File_Name = LeftStr(N, NLen-(NLen-ELen))  # Error Line
should it be
Code:
File_Name = LeftStr(N, ELen)  # Where -ve ELen is error for LeftStr
LOL! I've tried to come up with a justification for doing it that way. I'm certain I would've had one at the time, but apparently it wasn't based in reality, because it eludes me now.

So yes, this would produce exactly the same result (with the extra bit added to prevent the error when there's no extension).

N = ScriptFile()
LN = LCase(N)
NLen = StrLen(N)
ELen = FindStr(LN, ".avs") - 1
File_Name = (ELen > 0) ? LeftStr(N, ELen) : N
FName = (FileName == "") ? File_Name : FileName
File = FName + "_Combing.txt"

Edit: I've changed it in my previous post too.

Last edited by hello_hello; 11th November 2021 at 12:12.
hello_hello is offline   Reply With Quote
Old 11th November 2021, 21:33   #85  |  Link
Danette
Registered User
 
Join Date: Apr 2013
Posts: 346
Quote:
Originally Posted by StainlessS View Post
Code:
File_Name = ScriptFile().RT_FilenameSplit(14)  # Drive + Path + name (no extension)
FName = (FileName == "") ? File_Name : FileName
File = FName + "_Combing.txt"
RT_DebugF("File = '%s'",File,name="Danette: ")
Finished running a 36-file batch and all went well with this new code. Thanks.

Quote:
Originally Posted by hello_hello View Post
Originally I thought the extra character in the name was the culprit, but for me it works even before saving the script to my hard drive, as long as when I create a new tab I change the name to give it an avs extension.

Did the script have an avs extension in the tab? DebugView shows it having one, but you said it was working at that time.
Ahhh …light bulb went on. This explains the question raised by StainlessS and, probably, why the error appeared after so many successful runs. It never occurred to me that the tab name, in AvsPmod, had anything to do with the running of the script. Apparently, it does. I think that what might have been happening, when running successfully, is that AvsPmod changes a new tab name to the name of the file with the “.avs” extension, once ANY script in that particular tab is saved. Previously, I was running the MoireEffect (my name for it) filter in tabs that had been used for other projects and saved (the filename doesn’t seem to matter, just the .avs extension).

Quote:
Originally Posted by hello_hello View Post
If the StainlessS version works you might as well use it, but this will also prevent the error. Without an avs extension, it'll just use the full file name for the text file's name.
With the above knowledge, I could, now, use the original script and run successfully by simply saving a script, in AvsPmod, first. However, since StainlessS’ replacement code negates the need for that step, I’ll just keep that code, unless either of you think the alternative code is better.

Last edited by Danette; 11th November 2021 at 21:40.
Danette is offline   Reply With Quote
Old 12th November 2021, 09:17   #86  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,829
Quote:
Originally Posted by Danette View Post
With the above knowledge, I could, now, use the original script and run successfully by simply saving a script, in AvsPmod, first. However, since StainlessS’ replacement code negates the need for that step, I’ll just keep that code, unless either of you think the alternative code is better.
The change I added to mine only tries to remove the file extension from the name if it exists, and the StainlessS replacement effectively does the same thing, as far as I can tell, so it doesn't matter which one you use.

If you don't save the script first, where is the text file written? For me it's the AvsPmod directory. If it's the same for the StainlessS version (I assume so) you could force the text file to be written to a specific directory for unsaved scripts, but it probably makes more sense just save it first.

Having said that.... change the file path in red to whatever you prefer (it's only for unsaved scripts). If the path doesn't exist you'll get an error message. If you specify a path that would never exist (or leave it as it is), I guess you could use the error message as a reminder to save the script. Once it's saved, you can reload the video and it should work normally and the text file will be written to the same location as the script.
You'll also need to update the lines in blue.

Code:
N = ScriptFile()
LN = LCase(N)
NLen = StrLen(N)
ELen = FindStr(LN, ".avs") - 1
Dir = (StrLen(ScriptDir()) < 2) ? "Z:\Save The Script\" : ""
File_Name = (ELen > 0) ? LeftStr(N, ELen) : N
FName = (FileName == "") ? Dir + File_Name : FileName
File = FName + "_Combing.txt"
Vid = Vid.GreyScale()
CombTest = BlankClip(Vid, Color=color_red)
Vid = Vid.TFM(Clip2=CombTest).TDecimate()
global Everything = All

Last edited by hello_hello; 12th November 2021 at 09:46.
hello_hello is offline   Reply With Quote
Old 12th November 2021, 13:11   #87  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
You can use below to replace/remove extension without any plugins required.

Quote:
Originally Posted by StainlessS View Post
Or with no dependancies,
Code:
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
}

BlankClip(width=320,height=240)
fn="D:\TEST\Something.avs"
s1=fn.ReplaceExtension()
s2=fn.ReplaceExtension(".mp4")
Subtitle(fn + "\n" + s1 +"\n" + s2,lsp=0)


EDIT: It is not bullet proof, eg fn="D:\TEST.DIRECTORY\Something" would fail chopping off ".DIRECTORY\Something".
EDIT:
Quote:
File_Name = ScriptFile().RT_FilenameSplit(14) # Drive + Path + name (no extension)
FName = (FileName == "") ? File_Name : FileName
File = FName + "_Combing.txt"
RT_DebugF("File = '%s'",File,name="Danette: ")
I think I cocked up there, should be
Code:
File_Name = ScriptFile().RT_FilenameSplit(7)  # Drive + Path + name (no extension)

Code:
RT_FilenameSplit(string filename,int "get"=15)
 Splits the un-named filename string into component parts selected by 'get' bit flags arg and returns the
 parts joined together.
 'Get' (default 15, 1 -> 15), If set, Bit 0=DRIVE, 1=Dir, 2=Name, 4=Extension.
 Add 1 for Drive (bit 0), add 2 for Dir (bit 1), add 4 for Name (bit 2), add 8 for Extension (bit 3).
 Some combinations do not make sense, eg Drive + Extension (1+8=9). Below sensible options.
   1  = Drive (includes trailing ':')
   2  = Dir (includes trailing '\')
   3  = Drive + Dir
   4  = Name
   6  = Dir + Name
   7  = Drive + Dir + Name
   8  = Extension (includes leading '.')
   12 = Name + Extension
   14 = Dir + Name + Extension  # No Drive part
   15 = Drive + Dir + Name + Extension
 Assuming a current working directory of eg "D:\avs\avi\", 'filename'="test.avi" and 'get'=15, returns "D:\avs\avi\test.avi",
 so given a relative filename and default 'get'=15, is equivalent to RT_GetFullPathName(filename).
__________________
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; 12th November 2021 at 13:24.
StainlessS is offline   Reply With Quote
Old 14th November 2021, 20:14   #88  |  Link
Danette
Registered User
 
Join Date: Apr 2013
Posts: 346
Quote:
Originally Posted by hello_hello View Post
If you don't save the script first, where is the text file written? For me it's the AvsPmod directory. If it's the same for the StainlessS version (I assume so) you could force the text file to be written to a specific directory for unsaved scripts, but it probably makes more sense just save it first.
The initial problem was during preview only, before anything was saved. When I opened a new file in AvsPmod (the "New File" reported in DebugView) and applied the filter, the error message occurred. So, I stopped before trying to save the script. I now know that, had I used an AvsPmod tab that had a saved script in it, then the error message would not occur.

I'm fine, now, with StainlessS' script change, which works in the preview mode before, and after, any script saving activity.
Danette 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 18:47.


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