View Full Version : How can i detect an error from avisynth script with vfw?
jonny
20th December 2002, 11:59
When an error occour in an avisynth script, avisynth return a valid clip with the message, how can i detect this?
Thanks
jonny
Belgabor
20th December 2002, 12:13
Have a look at the VirtualDub sources, its shown there. (iirc basically you have to get a special interface for the AVIFile object)
jonny
20th December 2002, 12:20
I'll do, thank you very much!
UGAthecat
21st December 2002, 01:07
if you haven't found it already...iirc, you can use AVIFILEINFO or AVISTREAMINFO on a video stream and the error will be returned in one of the values. I know i've seen the errors generated by AVISynth using these before in VB. Also, if anyone wants info on using AVIFile stuff in VB, check out http://www.shrinkwrapvb.com
To get info on using avifileinfo and avistreaminfo, go to this page in the tutorials on shrinkwrapvb: http://www.shrinkwrapvb.com/avihelp/avihlp_2.htm
jonny
23rd December 2002, 15:41
Finally found the solutions in VDub source code... this may help others:
#include<windows.h>
#include<vfw.h>
#include<stdio.h>
const GUID AvisynthGUID = {0xe6d6b708, 0x124d, 0x11d4, {0x86, 0xf3, 0xdb, 0x80, 0xaf, 0xd9, 0x87, 0x78}};
struct IAvisynth : IUnknown
{
virtual int __stdcall GetError(const char **) = 0;
};
void main()
{
PAVIFILE PAviFile;
IAvisynth *PAvisynth;
const char *AvisynthE;
AVIFileInit();
if (AVIFileOpen(&PAviFile, "test.avs", OF_READ, 0) == 0)
{
if (PAviFile->QueryInterface(AvisynthGUID, (void **)&PAvisynth) == S_OK)
{
if (PAvisynth->GetError(&AvisynthE))
printf("%s\n", AvisynthE);
else
printf("Ok!\n");
PAvisynth->Release();
}
AVIFileRelease(PAviFile);
}
AVIFileExit();
}
@UGAthecat:
AVIFILEINFO or AVISTREAMINFO seems to does not return this info, i'm missing something?
EDIT: at the start i was searching for "iirc" :D, before learning that means "if i remember correctly"
jonny
9th February 2003, 19:04
Is someone able to give me some tips about translating this from cpp to plain c?
const GUID AvisynthGUID = {0xe6d6b708, 0x124d, 0x11d4, {0x86, 0xf3, 0xdb, 0x80, 0xaf, 0xd9, 0x87, 0x78}};
struct IAvisynth : IUnknown
{
virtual int __stdcall GetError(const char **) = 0;
};
PAVIFILE f;
IAvisynth *PAvisynth;
const char *AvisynthE;
AVIFileInit();
AVIFileOpen(&f, "test.avs", OF_READ, NULL);
f->QueryInterface(AvisynthGUID, (void **)&PAvisynth);
if (PAvisynth->GetError(&AvisynthE))
{
...
}
...
Many thanks
jonny
jonny
27th February 2003, 00:30
I have found a solution some days ago... dunno if this could be useful for others... anyway it's here:
const GUID AviSynthGUID = {0xe6d6b708, 0x124d, 0x11d4, {0x86, 0xf3, 0xdb, 0x80, 0xaf, 0xd9, 0x87, 0x78}};
DECLARE_INTERFACE_(IAviSynth, IUnknown)
{
STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE;
STDMETHOD_(ULONG,AddRef) (THIS) PURE;
STDMETHOD_(ULONG,Release) (THIS) PURE;
STDMETHOD_(int,GetError) (THIS_ const char **) PURE;
};
...
PAVIFILE f;
IAviSynth *iavs;
const char *error;
AVIFileOpen(&f, "test.avs", OF_READ, 0);
f->lpVtbl->QueryInterface(f, &AviSynthGUID, (void **) &iavs);
if (iavs->lpVtbl->GetError(iavs, &error))
{
// error here!
}
(there is no full error checking to simplify the code reading)
Amnon82
11th October 2005, 17:32
Is there a way to use this in delphi?
jonny
11th October 2005, 17:49
you could make an external dll with this code.
i have no idea about doing this in pure delphi
Amnon82
11th October 2005, 18:43
Can you compile the dll? I'll try it, but it will be the first time for me, creating dlls. I must search the net how to do it ...
jonny
11th October 2005, 19:43
no experience with dlls
some time (years!) ago, i was using this external app:
http://jonny.leffe.dnsalias.com/doom9/avsinfo.rar
you have to write a file called "avsinfo.in", containing the .avs filename, call "avsinfo.exe" and read back "avsinfo.out"
avsinfo.out:
the first 2 chars of this file indicate success ("ok") or an error (" " - 2 spaces)
the rest of the file contain the error message in case of errors, video infos in case of success:
dwWidth, dwHeight, dwScale, dwRate, dwLength, separated by "#"
(if "avsinfo.in" does not exists, "avsinfo.out" is not written)
PS: if you need to modify it, you can compile it with "cl avsinfo.cpp /link vfw32.lib"
dirty but easy :)
Amnon82
15th October 2005, 23:48
I'll take a look. thx ...
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.