View Full Version : GScript - language extensions for Avisynth
StainlessS
9th May 2020, 15:13
Actually, I think the Groucho2004 version of Gscript I used must have been the one before current one,
re-tried with current GScript recompile and no AV or any problem under current avs+ 3.5.2 [x86 or x64].
EDIT: Script I used.
GScript("")
Return Messageclip("done")
Groucho2004
9th May 2020, 15:18
Actually, I think the Groucho2004 version of Gscript I used must have been the one before current one,
re-tried with current GScript recompile and no AV or any problem under current avs+ 3.5.2 [x86 or x64].
EDIT: Script I used.
GScript("")
Return Messageclip("done")
The "GScript_25_32.dll" should crash with 3.5.2 (not sure...).
StainlessS
9th May 2020, 15:28
The "GScript_25_32.dll" should crash with 3.5.2 (not sure...).
Yip, Access Violation,
Groucho2004
9th May 2020, 15:36
Yip, Access Violation,So, just to summarise:
GScript_26_64.dll: does not crash
GScript_26_32.dll: does not crash
GScript_25_32.dll: crashes on 3.5.2
The old DLL from 2009 should also crash on 3.5.2, right?
StainlessS
9th May 2020, 15:38
Sounds bout right.
Groucho2004
9th May 2020, 15:40
Sounds bout right.OK, all good then. :)
StainlessS
9th May 2020, 15:43
Should though be noted somewhere that problems can happen when wrong version used.
[and Access violation is something that should not really happen whether correct version or not]
Groucho2004
9th May 2020, 15:57
Should though be noted somewhere that problems can happen when wrong version used.
[and Access violation is something that should not really happen whether correct version or not]I think a simple CheckVersion in the constructor should do the trick. I'll try it.
StainlessS
9th May 2020, 16:06
OK, but I've implemented this as safety check,
Function GScriptExists() {try{GScript("")ret=true}catch(msg){Assert(msg.FindStr("Access")==0 && msg.FindStr("Out of")==0,"GScriptExists: GScript/Avs version Mismatch")ret=false}Return ret}
BlankClip.Subtitle(String(GScriptExists))
https://i.postimg.cc/5NkWMSTs/Untitled-00.jpg (https://postimages.org/)
EDIT: What is your error message gonna be ?
EDIT: this is better and not necessary to know what your error message will be.
Function GScriptExists() {try{GScript("")ret=true}catch(msg) {Assert(msg.FindStr("no function")>0,"GScriptExists: GScript/Avs version Mismatch"+Chr(10)+"SysErr="+msg)ret=false}Return ret}
BlankClip.Subtitle(String(GScriptExists))
https://i.postimg.cc/Jn3LLbg6/Untitled-01.jpg (https://postimages.org/)
Groucho2004
9th May 2020, 16:42
By the way, I found this in the latest avisynth.h:
// Important note on AVISYNTH_INTERFACE_VERSION change:
// Note 1: Those few plugins which were using earlier IScriptEnvironment2 despite the big Warning will crash have to be rebuilt.
// Note 2: How to support earlier avisynth interface with an up-to-date avisynth.h:
// Use the new frame property features adaptively after querying that at least v8 is supported
// AviSynth property support can be queried (cpp iface example):
// has_at_least_v8 = true;
// try { env->CheckVersion(8); } catch (const AvisynthError&) { has_at_least_v8 = false; }
// and use it:
// if (has_at_least_v8) dst = env->NewVideoFrameP(vi, &src); else dst = env->NewVideoFrame(vi);
Whaddaya think?
StainlessS
9th May 2020, 16:52
Nah, Im continuing to use older avs+ header, minus the stdint header requirement which prevents VS2008 compiler use.
No problems.
EDIT: Above for v2.6/2.6+ plugs, am still using 2.5 header for avs 25 plugs.
flossy_cake
2nd November 2022, 01:01
Feature request: loop through files inside a folder. Recurse into subdirectories if needed.
Purpose: avoid hardcoding of paths in scripts.
StainlessS
2nd November 2022, 05:13
RT_WriteFileList(String,String,bool "append"=false)
Non-clip function.
This function, takes as the first string, a filename template with wildcards, this template can be eg
"Fred.jpg" or "Fr?d.jp*g". where the '?' character matches any single character and the '*' wildcard matches zero or more characters.
v1.03, Can take multiple pipe ('|') separated Wilcards in the extension ONLY, as in "D:\Pics\*.BMP|JP*G|PNG"
The second string is the output filename which will be created and contain the files matching the input file template.
The function will return the number of filenames written into the output file. Directories are ignored altogether
and not written to the output file. A return of -1 indicates a problem opening/writing the output file.
v1.06, Append, if true appends to existing file. NOTE, the return value does NOT include any already existing
filenames if append is true (use RT_FileQueryLines to inquire total number of filenames when append = true).
It dont cope with directories (ignored - one day I might do same to fetch a list of folder names so you can scan on those too).
Do search on "RT_WriteFileList", one script using it here:-
https://forum.doom9.org/showthread.php?p=1916173#post1916173
EDIT: Smaller script function here:- https://forum.doom9.org/showthread.php?p=1914335#post1914335
EDIT: nuther one:- https://forum.doom9.org/showthread.php?p=1911810#post1911810
EDIT: Yet a nuther 1:- https://forum.doom9.org/showthread.php?p=1896023&highlight=RT_WriteFileList#post1896023
I accidentally deleted some files, and recovered some 1000's of text files all with names like asaoidajljlasa.txt,
is really tedious having to look though 10,000 text files so i made a script that showed any files containing a particular word on
a video clip frame. Much easier just moving to next frame instead of loading another text file into a text editor.
# ShowTextFiles.avs
/*
Req RT_Stats, v1.43+, Grunt.
Scan directory of text files, showing first few lines of each file on frame [original intent to aid recovery of accidentally deleted text files from 10,000 possible recovered txt files].
Outputs list of Files with SearchWord found to DebugView, even when DEBUG=False
*/
EDIT:
You could also perhaps find use for this,
RT_FSelOpen(string "title"="Open",string "dir"="",string "filt",string "fn="",bool "multi"=false,bool "debug"=false)
Function to select EXISTING filename using GUI FileSelector.
Title = Title bar text.
Dir = Directory, "" = Current
Filt = Lots, eg "All Files (*.*)|*.*"
[Displayed text | wildcard] [| more pairs of Displayed text and wildcard, in pairs ONLY].
first one is default.
fn = Initially presented filename (if any).
multi = Multiply Select filenames. Allows selection of more than one filename at once.
debug = Send error info to DebugView window.
Returns
int, 0, user CANCELLED.
int, non zero is error (error sent to DebugView window).
String, Filename selected, Chr(10) separated multiline string if MULTI==true (and multiple files selected).
Example, to prompt for an AVI file and play it.
avi=RT_FSelOpen("I MUST have an AVI",filt="Avi files|*.avi")
Assert(avi.IsString,"RT_FSelOpen: Error="+String(avi))
AviSource(avi)
From the source code before it was included into RT_Stats, here:- https://forum.doom9.org/showthread.php?p=1638307#post1638307
AVSValue __cdecl FSelOpen(AVSValue args, void* user_data, IScriptEnvironment* env) {
char * myName="FSelOpen: ";
const char * myFilter=
"All files (*.*)|*.*|"
"Avi Files (*.avi;*.XVid;*.DivX)|*.avi;*.XVid;*.DivX|"
"Mpg files (*.vob;*.mpg;*.mpeg;*.m1v;*.m2v;*.mpv;*.tp;*.ts;*.trp;*.m2t;*.m2ts;*.pva;*.vro)|*.vob;*.mpg;*.mpeg;*.m1v;"
"*.m2v;*.mpv;*.tp;*.ts;*.trp;*.m2t;*.m2ts;*.pva;*.vro|"
"Other Vid (*.mkv;*.Wmv;*.mp4;*.flv;*.ram;*.rm)|*.mkv;*.Wmv;*.mp4;*.flv;*.ram;*.rm|"
"Audio Files (*.mp3;*.mpa;*mp1;*.mp2;*.wav)|*.mp3;*.mpa;*mp1;*.mp2;*.wav|"
"Avs files (*.avs;*.avsi)|*.avs;*.avsi|"
"Text files (*.txt;*.log;*.asc)|*.txt;*.log;*.asc|"
"Image files (*.bmp;*.jpg;*.jpe;*.jpeg;*.png;*.tga;*.tif;*.gif;*.tiff)|*.bmp;*.jpg;*.jpe;*.jpeg;*.png;*.tga;*.tif;*.gif;*.tiff|"
"Bat files (*.bat)|*.bat|";
"Exe files (*.exe)|*.cmd";
Note the choice of wildcards allowed.
EDIT: For those that like to watch a movie and read scrolling text at the same time. Requires RT_Stats v1.20.
avi = FSelOpen("Select an AVI",Filt="*.AVI|*.AVI")
Assert(avi.IsString,"FSelOpen: Error="+String(avi))
AVISource(AVI)
txt = FSelOpen("Select a Text file",Filt="*.txt|*.txt")
Assert(txt.IsString,"FSelOpen: Error="+String(txt))
Txt=RT_ReadTxtFromFile(txt)
Return ScriptClip("""RT_Subtitle("%s",Txt,align=2,y=height+100-current_frame,expy=true)""") # Requires RT_Stats v1.20
Prompts for AVI file, then for a Txt file
EDIT: FSelOpen, will only allow selecting existing files. FSelSaveAs, prompts for Overwrite if existing selected.
The is also FSelFolder() which prompts for exising folder name. [perhaps I should allow it to return multiple folder names <as Chr(10) separated string>].
flossy_cake
2nd November 2022, 11:15
Wow ok, wasn't expecting that.
I suppose I should probably explain what I'm trying to do.
Basically I want to iterate through all the files inside a dir (and its subdirs) and check if a filename matches the one I'm looking for.
In the meantime I'm working around it by using an ahk script to generate my avs scripts programatically so I can get away with having hardcoded paths for now. It's still a little annoying though as it means if I ever moved the avs files (or the video files they point to) to another location then the whole thing breaks (but, I can just run the ahk scripts again so it's not the total end of the world but still would be nice to have completely self-contained, self-sufficient avs scripts with no external path dependencies).
StainlessS
2nd November 2022, 16:46
check if a filename matches the one I'm looking for.
Well I'm not aware of anything that allows you to examine folder names,
There is Exist("filename") :- http://avisynth.nl/index.php/Internal_functions#Exist
which works also on folder name so long as it does NOT end in slash/backslash
(although I've a feeling that Pinterf fixed that in current AVS+).
You could also scan a RT_WriteFileList to see if matching file exists but Exist() quicker.
Avisynthesizer_Mod has a Batch mode which creates avs script for each {possibly mulitple} GUI selected file, using a script template.
gispos
2nd November 2022, 21:10
Feature request: loop through files inside a folder. Recurse into subdirectories if needed.
Purpose: avoid hardcoding of paths in scripts.
When I move a video file, I also move the associated avs file. Or I can copy the avs file somewhere else.
So for me this works quite well. Hibrydcoding:)
SourceFile = ScriptDir() + "Hammer.mkv"
SourceFile = Exist(SourceFile) ? SourceFile : "E:\Ablage\Hammer.mkv"
video=LWLibavVideoSource(SourceFile, cache=False)
audio=LWLibavAudioSource(SourceFile, cache=False)
audioDub(video, audio)
TCmullet
8th May 2024, 03:36
Why is this thread so, so, so, under posted.
I'll give you a reason. Initially my question is what's the difference between the 2 dlls in the download?
GScript_25_32.dll and
GScript_26_32.dll
?
But as I surveyed this thread, I have to ask... I have Avisynth+ and am trying to run a script (AiUpscale) and it's bombing due to a syntax error AS THOUGH GScript is not "in" the system. I was about to install the GScript filter but saw here where it's allegedly BUILT IN to Avisynth+. Please tell me what's going on here. Is it still built in? If so, then why is my Gscript script (AiUpscale.avsi) bombing with a syntax error at the first IF?
hello_hello
8th May 2024, 11:03
You don't need the GScript string wrapper when using the native Avisynth+ version. Either way though, I'm pretty sure the conditions must be inside brackets.
if (i > 10) {
x = 1
}
else {
x = 4
}
Old Gscript plugin method:
GScript("""
if (i > 10) {
x = 1
}
else {
x = 4
}
""")
If that's not it then maybe you should provide a copy of the actual script you're using.
TCmullet
8th May 2024, 13:14
If that's not it then maybe you should provide a copy of the actual script you're using.
https://github.com/Alexkral/AviSynthAiUpscale/releases/tag/1.2.0
The presence of the script AiUpscale.avsi in my plugins folder causes any script (even version.avs) to blowup with the syntax error when I try to open my script (version.avs) in my player (Vdub). It blows up at the first IF statement in AiUpscale.avsi.
TCmullet
8th May 2024, 13:39
In anticipation that you'll ask me for my AVSMeter, here it is, showing that I'm using Avisynth+.
D:\MyApplications\AVSMeter>avsmeter -avsinfo
AVSMeter 3.0.9.0 (x86), (c) Groucho2004, 2012-2021
VersionString: AviSynth+ 3.7.3 (r4003, 3.7, i386)
VersionNumber: 2.60
File / Product version: 3.7.3.0 / 3.7.3.0
Interface Version: 10
Multi-threading support: Yes
Avisynth.dll location: C:\WINDOWS\SysWOW64\avisynth.dll
Avisynth.dll time stamp: 2023-07-16, 04:00:38 (UTC)
PluginDir2_5 (HKLM, x86): C:\Program Files (x86)\AviSynth+\plugins
PluginDir+ (HKLM, x86): C:\Program Files (x86)\AviSynth+\plugins+
[C++ 2.5 Plugins (32 Bit)] [Version, Time stamp]
C:\Program Files (x86)\AviSynth+\plugins\avssr.dll [n/a, 2014-01-09]
C:\Program Files (x86)\AviSynth+\plugins\dgbob.dll [n/a, 2003-07-06]
C:\Program Files (x86)\AviSynth+\plugins\DGDecode.dll [1.5.8.0, 2015-12-26]
C:\Program Files (x86)\AviSynth+\plugins\NicAudio.dll [n/a, 2012-08-27]
C:\Program Files (x86)\AviSynth+\plugins\TIVTC.dll [1.0.5.0, 2017-12-18]
[C++ 2.6 Plugins (32 Bit)] [Version, Time stamp]
C:\Program Files (x86)\AviSynth+\plugins+\ConvertStacked.dll [n/a, 2023-07-16]
C:\Program Files (x86)\AviSynth+\plugins+\DirectShowSource.dll [n/a, 2023-07-16]
C:\Program Files (x86)\AviSynth+\plugins+\ImageSeq.dll [n/a, 2023-07-16]
C:\Program Files (x86)\AviSynth+\plugins+\Shibatch.dll [n/a, 2023-07-16]
C:\Program Files (x86)\AviSynth+\plugins+\TimeStretch.dll [n/a, 2023-07-16]
C:\Program Files (x86)\AviSynth+\plugins+\VDubFilter.dll [n/a, 2023-07-16]
C:\Program Files (x86)\AviSynth+\plugins\aWarpsharpMT.dll [2.1.9.0, 2023-11-19]
C:\Program Files (x86)\AviSynth+\plugins\DGDecodeNV.dll [0.0.0.2052, 2016-10-18]
C:\Program Files (x86)\AviSynth+\plugins\ffms2.dll [n/a, 2020-08-22]
C:\Program Files (x86)\AviSynth+\plugins\LSMASHSource.dll [1129.0.0.0, 2023-07-16]
C:\Program Files (x86)\AviSynth+\plugins\masktools2.dll [2.2.30.0, 2022-02-19]
C:\Program Files (x86)\AviSynth+\plugins\mvtools2.dll [2.7.45.0, 2021-06-08]
C:\Program Files (x86)\AviSynth+\plugins\Shader.dll [n/a, 2024-05-07]
C:\Program Files (x86)\AviSynth+\plugins\svpflow1.dll [4.0.0.132, 2016-12-21]
C:\Program Files (x86)\AviSynth+\plugins\svpflow2.dll [4.0.0.136, 2016-12-21]
[Scripts (AVSI)] [Time stamp]
C:\Program Files (x86)\AviSynth+\plugins\colors_rgb.avsi [2022-10-06]
C:\Program Files (x86)\AviSynth+\plugins\FFMS2.avsi [2015-05-22]
C:\Program Files (x86)\AviSynth+\plugins\GameDropFixV5.avsi [2017-10-04]
C:\Program Files (x86)\AviSynth+\plugins\InterFrame2.avsi [2015-07-22]
C:\Program Files (x86)\AviSynth+\plugins\LimitedSharpenFaster.avsi [2017-01-03]
C:\Program Files (x86)\AviSynth+\plugins\Shader.avsi [2024-05-07]
C:\Program Files (x86)\AviSynth+\plugins\TCS-Video-Functions.avsi [2024-04-27]
[Uncategorized files] [Time stamp]
C:\Program Files (x86)\AviSynth+\plugins\AiUpscale - Copy.xxxavsi [2024-05-07]
C:\Program Files (x86)\AviSynth+\plugins\AiUpscale.xxxxavsi [2024-05-08]
C:\Program Files (x86)\AviSynth+\plugins\colors_rgb.txt [2022-10-06]
C:\Program Files (x86)\AviSynth+\plugins\ffms2.lib [2020-08-22]
C:\Program Files (x86)\AviSynth+\plugins\ffmsindex.exe [2020-08-22]
D:\MyApplications\AVSMeter>(I've temporarily locked out AiUpscale.avsi so that I can successfully run Avisynth on other scripts.)
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.