View Full Version : Direct feeding to AVISYNTH
aithai
22nd October 2008, 16:17
Hi,
I have tried to search through the forums but could not find a decent answer. I need to direct feed the wordings in an avisynth script to avisynth.
For example, to load an RMVB file, it is recommended to write a script with the following text inside the script file:
DirectShowSource("c:\1\rmvb\rapid.rmvb", fps=25, convertfps=true)
I do not want to use a script but want to direct feed the wordings "DirectShowSource("c:\1\rmvb\rapid.rmvb", fps=25, convertfps=true)" to avisynth. The best that I can find and understand after many days of searching is the recommendations on the thread below:
http://forum.doom9.org/archive/index.php/t-95863-p-7.html
Elsewhere, there is a recommendation to do the followings:
then you use avs_create_script_environment to create the script environment
you then use avs_invoke to call "eval" to load the script(or use import if the script is saved in a file)
this returns an AVS_Value
Questions:
1. How do I call "eval"
2. Where do I feed my script text:DirectShowSource("c:\1\rmvb\rapid.rmvb", fps=25, convertfps=true) to?
I am using Delphi and I have the pascal headers for avisynth_c. Example will be very much appreciated.
Thank you for your time.
Gavino
22nd October 2008, 17:17
1. How do I call "eval"
2. Where do I feed my script text:DirectShowSource("c:\1\rmvb\rapid.rmvb", fps=25, convertfps=true) to?
I don't know about the Delphi/Pascal bit, but if you were using C directly, you would do something like:
AVS_Value param0 = avs_new_value_string("DirectShowSource(\"c:\\1\\rmvb\\rapid.rmvb\", fps=25, convertfps=true)");
AVS_Value params = avs_new_value_array(¶m0, 1);
AVS_Value DSSource = avs_invoke(scriptenv, "Eval", params, 0);
Note the extra backslashes to escape quote and backslash characters in the string.
You might find this thread useful.
Myrsloik
22nd October 2008, 17:39
avs_invoke(env, 'Eval', avs_new_value_string('script goes here'));
However you may as well skip the whole eval thing and invoke directshowsource directly. Look at the ShowVideoInfo sample that's included for exactly how to do things because I've forgotten most of it by now.
The "cleanest" way to do it: (probably with topos)
var argarray: array[0..2] of AVS_Value;
begin
argarray[0] := avs_new_value_string('filename');
argarray[1] := avs_new_value_int(25);
argarray[2] := avs_new_value_bool(true);
avs_invoke(env, 'DirectShowSource', avs_new_value_array(@argarray, 3), [nil, 'fps', 'convertfps']);
aithai
22nd October 2008, 18:25
Hi,
Wow! Never thought it could be this easy! The codes works very well. Thank you Myrsloik and Gavino.
The next thing is to directly load the avisynth.dll, say, without having to install the whold avisynth package. I just need to call the avisynth.dll and load the rmvb file. I had the interface to ffmpeg done, which will do the rest of the conversion work.
1. How do I load this C dll with delphi? Can you please guide me a bit on this loadlibrary subject and what procedure/function to access/call in order to load my rmvb file. Short example appreciated.
2. A question on AVSRedirect.dll. I came across this dll during my search works. What exactly it does?
Thank you once again for your kind assistance.
Good Day!
aithai
22nd October 2008, 18:38
Hi,
Were I able to load the avisynth.dll and call it from my application folder, do I include the other files namely, devil.dll, directshowsource.dll, colors_rgb.avsi and TCPDeliver.dll inside the same folder?
Thanks!
Myrsloik
22nd October 2008, 19:42
1. You already did. The loading of avisynth.dll is done implicitly because of the "external AVISYTNH_DLL" part of the function declarations in the pas. Obviously it has to be somewhere in your path.
2. Another wrapper for the c++ interface to c. I don't think there's a real reason to use it in delphi since it doesn't appear to be simpler or better in any way. (If you want yet another lousy wrapper which actually predates the avisynth_c interface look at the yatta source code)
This is how you do it:
avs_invoke(env, 'loadplugin'/'include', 'path to plugin/include file')
The autoloading is based on a registry key only written when you use the installer.
squid_80
23rd October 2008, 03:33
However you may as well skip the whole eval thing and invoke directshowsource directly.Keep in mind you don't get a cache automatically added when using this method.
aithai
23rd October 2008, 07:09
Hi,
I use the following codes in Delphi:
// in FormCreate Event
// env:=avs_create_script_environment();
----------------------------------------------
s:= ExtractFilePath(Application.ExeName)+ 'Common\';
avs_invoke(env, 'loadplugin',
avs_new_value_string(PChar(s)));
The plugins are contained in the Common folder. Cannot get it to work or converts any rmvb files. Avisynth is able to feed the video info though.
1. I put Avisynth.dll in my application folder.
2. The plugins files in the Common folder.
3. Realmedia video codec are also contained in the Common folder.
If I revert to use the registry pointer to the plugins folder ( normal way) , it works as it should.
Do please comment.
Gavino
23rd October 2008, 08:51
s:= ExtractFilePath(Application.ExeName)+ 'Common\';
avs_invoke(env, 'loadplugin',
avs_new_value_string(PChar(s)));
The plugins are contained in the Common folder. Cannot get it to work or converts any rmvb files.
Loadplugin is for loading individual plugins by name, not for setting the folder for automatic loading. If you want to use this method, you will have to scan the folder yourself and load each plugin separately.
aithai
23rd October 2008, 13:34
Hi,
I try:
s:= ExtractFilePath(Application.ExeName)+ 'DirectShowSource.dll';
avs_invoke(env, 'loadplugin',
avs_new_value_string(PChar(s)));
The above codes did not work either. The dll file is there, DirectshowSource.dll.
1. Is there any specific criteria before or after loading the dll or when it should be loaded ( I called it on FormCreate Event in Delphi).
2. Do I have to free the dll after loading?
Thanks.
Gavino
23rd October 2008, 14:06
s:= ExtractFilePath(Application.ExeName)+ 'DirectShowSource.dll';
Just a thought: are you sure ExtractFilePath includes a trailing '\'?
Or perhaps you need to add 'Common\' going by your previous post?
aithai
23rd October 2008, 16:00
Hi,
The path is correct:
C:\AppFolder\Common\DirectShowSource.dll
I did changed it to:
C:\AppFolder\DirectShowSource.dll
Same result - fail to convert.
I had the path shown on the form caption. I was suspicious of this too, so got to play it safe.
Just suspicious that if avisynth.dll reads the registry to locate the location of the 'plugins' folder and reject the direct loading from the codes. Is this a possibility? I to rename the 'plugins' to something else to evade the registry pointer loading. Got to do some hard work today.
Thanks.
IanB
23rd October 2008, 21:45
You should be checking the return value from your avs_invoke() calls, if a scripting error is occurring it will contain the message text. And later on you will need these value to make the getframe calls to read the video data.
aithai
24th October 2008, 17:11
I found that I have to keep the registry pointer to the plugins directory to keep it working on all versions of Windows. This is still a mystery but I will have to satisfied myself with this for the time being. I will delve deeper to unravel this registry pointer need dilemna and find out how the DirectShowSource.dll works. Since there is an eerie devil.dll bundled here, I might have to get God assistance and time.
Thank you, all of you, for your sincere assistance.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.