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. |
|
|
Thread Tools | Search this Thread | Display Modes |
6th January 2005, 02:21 | #1 | Link |
Paldo-GNU/LinuxMaintainer
Join Date: Oct 2003
Location: Germany
Posts: 1,580
|
<Delphi> Get information of AVS using VFW or AVISYNTH_C-Port by Myrsloik
How do you get the informations out of an avs-file. The answer is vfw or avisynth_c.
In the first part of this post I show you the way how to get the informations using vfw. The second part shows you the way using avisynth_c. VFW stands for VideoForWindows. VFW was ported to Delphi. Take a look on the code and the sources of mine. Code how to use vfw in Delphi: Code:
uses vfw {The GetAVSFrames function will give You the Info about the AVS-File (C) 2005-2006 by Amnon82} function GETAVSFRAMES(avifn: string): Boolean; var Error: Integer; pFile: PAVIFile; AviInfo: TAVIFILEINFOW; sError: string; begin Result := False; // Initialize the AVIFile library. AVIFileInit; // The AVIFileOpen function opens an AVI file Error := AVIFileOpen(pFile, PChar(avifn), 0, nil); if Error <> 0 then begin AVIFileExit; {case Error of AVIERR_BADFORMAT: sError := 'The file couldn''t be read'; AVIERR_MEMORY: sError := 'The file could not be opened because of insufficient memory.'; AVIERR_FILEREAD: sError := 'A disk error occurred while reading the file.'; AVIERR_FILEOPEN: sError := 'A disk error occurred while opening the file.'; end; } sError := 'The AVS-file could not be opened. Check it.'; Messagebox(Application.Handle, pchar(sError), pchar('Error'), MB_ICONERROR); Exit; end; // AVIFileInfo obtains information about an AVI file if AVIFileInfo(pFile, @AVIINFO, SizeOf(AVIINFO)) <> AVIERR_OK then begin // Clean up and exit AVIFileRelease(pFile); AVIFileExit; Exit; end; // Show some information about the AVI // You can create some edits to write in the infos Form1.avsframes.text:=IntToStr(AVIINFO.dwLength); Form1.avsheight.text:=IntToStr(AVIINFO.dwheight); Form1.avswidth.text:=IntToStr(AVIINFO.dwWidth); Form1.rate.text:=formatfloat('0.000',AVIINFO.dwRate/AVIINFO.dwScale); end; // Usage: GETAVSFRAMES(AVSFILENAMESTRING); You can download the Sources by Amnon82 to get the feeling how to use vfw in Delphi. ============================================================================== Myrsloik did a avisynth_c-port. Now you can use avisynth_c without the need of vfw. Your programs running faster and more stable. Myrsloik created some samples how to use the avisnyth_c-port in Delphi. It shows you the framecount, resolution and field order (TFF). Code how to use avisynth_c in Delphi: Code:
uses avisynth_c var avsval:AVS_Value; begin if OpenDialog1.Execute then begin //call avisouce with the selected filename avsval:=avs_invoke(env,'AVISource',avs_new_value_string(PChar(OpenDialog1.FileName))); //check for errors, only AVS_Values containing clips need to be freed //which it won't here if it's an error if avs_is_error(avsval) then raise EAviSynthCException.Create(avs_as_error(avsval)); //get a clip from the AVS_Value clip:=avs_take_clip(avsval,env); //release the AVS_Value since it contained a clip, releasing an AVS_Value //without a clip does nothing avs_release_value(avsval); //get video information and adjust window vi:=avs_get_video_info(clip); TrackBar1.Max:=vi.num_frames-1; ClientWidth:=vi.width; ClientHeight:=vi.height+TrackBar1.Height; with Image1.Picture.Bitmap do begin Width:=vi.width; Height:=vi.height; if avs_is_rgb32(vi) then PixelFormat:=pf32bit else if avs_is_rgb24(vi) then PixelFormat:=pf24bit end; TrackBar1Change(nil); end; end;
__________________
Paldo GNU/Linux Homepage Paldo GNU/Linux Wiki Download of Installer-LiveCD Installation guide for the Installer-LiveCD Need fast help? Talk with me Last edited by Amnon82; 22nd June 2006 at 14:29. |
6th January 2005, 02:36 | #2 | Link |
Registered User
Join Date: Feb 2004
Location: Virginia, USA
Posts: 334
|
I don't know any Delphi, but you would do it the same way as you would with any AVI (AVIFileInit, AVIFileOpen, AVIFileGetStream, AVIStreamInfo, AVIStreamRelease, AVIFileClose, AVIFileExit). Here's how it's done in C++, let me know if you have any questions:
Code:
#include <iostream> #include <windows.h> #include <vfw.h> using namespace std; int main(int argc, char* argv[]) { char *pathSrc; PAVIFILE pAviFile; PAVISTREAM pVideoStream; AVISTREAMINFO videoStreamInfo; bool finished; if (argc < 2) { return 0; } finished = false; pathSrc = argv[1]; AVIFileInit(); if (AVIFileOpen(&pAviFile, pathSrc, OF_SHARE_DENY_WRITE, 0) == AVIERR_OK) { if (AVIFileGetStream(pAviFile, &pVideoStream, streamtypeVIDEO, 0) == AVIERR_OK) { ZeroMemory(&videoStreamInfo, sizeof(AVISTREAMINFO)); if (AVIStreamInfo(pVideoStream, &videoStreamInfo, sizeof(AVISTREAMINFO)) == AVIERR_OK) { finished = true; } AVIStreamRelease(pVideoStream); } AVIFileClose(pAviFile); } AVIFileExit(); if (finished) { cout << "Length: " << videoStreamInfo.dwLength << "\n"; } else { cout << "An error occurred.\n"; } return 0; }
__________________
moitah.net |
6th January 2005, 11:38 | #3 | Link |
Paldo-GNU/LinuxMaintainer
Join Date: Oct 2003
Location: Germany
Posts: 1,580
|
I got it!
It tooks 2h to get this code. Now You can get the Infos of Your AVS also in Delphi THX goes to Moitah from the doom9.org forum for pointing me to vfw. THX again dude! You can use this code for all your projects. I hope it can help You out. Best regards Amnon82
__________________
Paldo GNU/Linux Homepage Paldo GNU/Linux Wiki Download of Installer-LiveCD Installation guide for the Installer-LiveCD Need fast help? Talk with me Last edited by Amnon82; 22nd June 2006 at 14:30. |
7th January 2005, 13:43 | #4 | Link |
Registered User
Join Date: Oct 2001
Location: france
Posts: 521
|
you could also grab lbkiller sources and look on the (*)vfw libraries.
(follow the link after my sign) esby
__________________
http://esby.free.fr/ |
28th January 2005, 22:40 | #6 | Link |
Registered User
Join Date: Feb 2003
Posts: 4
|
Hi
I am also writing an application in C++, that reads in avs scripts and modifies info in ecl file for CCE or tpr file for tmpg. At the moment I have done a work around to get the height, width etc by automatically adding a line to the avs script which writes the values to a txt file and then i read them in from there as variables. I was just thinking of changing this as I dont see it as the most efficient way of doing thing. I was looking into as to wether its possible to link to the avisynth dll and get the details from there. But having not done too much with dlls before i dont know where to start. I've had a look at the dll file via dependency walker and see the function avs_get_video_info. Can anyone shed light as to how i would get the information from a script i loaded into my program via this method? On the other hand perhaps the best way would be to use the helpful code Moitah has provided to do the job. |
26th January 2006, 01:55 | #7 | Link |
retired developer
Join Date: Oct 2002
Location: Canada
Posts: 8,978
|
http://www.brckomania.net/AUTOQ/Open...FOS_SOURCE.rar
Firefox can't establish a connection to the server at www.sedoparking.com. I'd like to have a look
__________________
Detritus Software |
26th January 2006, 16:03 | #8 | Link |
Registered User
Join Date: Mar 2004
Posts: 243
|
Impossible to get file at url http://www.brckomania.net/AUTOQ/Open...FOS_SOURCE.rar
I get HTTP/1.1 404 Not Found What's wrong? Last edited by alfixdvd; 26th January 2006 at 16:06. |
26th January 2006, 19:33 | #9 | Link |
Registered User
Join Date: Feb 2004
Location: Virginia, USA
Posts: 334
|
I had it laying on my hard drive: GETAVSINFOS_SOURCE.rar
__________________
moitah.net |
27th January 2006, 23:29 | #11 | Link |
Registered User
Join Date: Apr 2003
Location: Brazil
Posts: 247
|
Hi,
You could get frames from a "primitive" text file created by avs2avi. Put in a bat file: "C:\Program Files\Avsvs2avi\avs2avi.exe" "D:\name.avs" -e -c null | find "Frames" > "D:\frames.txt" Maybe someone (like me) thinks that is useful. Alexandre |
1st February 2006, 18:59 | #13 | Link | |
Errant Knight
Join Date: Oct 2004
Location: St Louis, M0 US
Posts: 364
|
Quote:
Last edited by Ebobtron; 1st February 2006 at 19:01. |
|
5th February 2006, 14:37 | #14 | Link |
Paldo-GNU/LinuxMaintainer
Join Date: Oct 2003
Location: Germany
Posts: 1,580
|
Since the PC only displays RGB and the first sample couldn't display YUV2 and YV12, I found a way to do it.
Take a look on the new source.
__________________
Paldo GNU/Linux Homepage Paldo GNU/Linux Wiki Download of Installer-LiveCD Installation guide for the Installer-LiveCD Need fast help? Talk with me Last edited by Amnon82; 22nd June 2006 at 14:31. |
|
|