Log in

View Full Version : Getting info from avi


Zarxrax
11th January 2006, 02:55
Please bear with me here, as I'm verrrry inexperienced...
First of all, I am using Visual C# Express Edition.
I have been searching on the MSDN for some hours now trying to figure out these things, but I don't see anything that looks like it might be useful (or I don't understand what I'm seeing :p).

First of all, I need to open an avi file and grab the framerate. I imagine this ought to be pretty easy, if I could figure out how :confused:
Secondly, and I'm sure this must be far more difficult... I want to find the timecodes for each keyframe in the avi file.

Thanks in advance if you can help this poor newbie to understand these things :)

Doom9
11th January 2006, 09:43
check out MeGUI.. it does just that, and a couple more things with anything that AVIFile (VfW) can open. Keep in mind though, using open source code means you have to open source your program as well..

Sirber
11th January 2006, 14:06
Look for MediaInfo lib, I use it in Realanime fo get infos on all my sources.

Doom9
11th January 2006, 15:06
as far as keyframes go, there's the archanger program from the xvid forum that's also written in .net and which can identify frame types.

Zarxrax
11th January 2006, 19:33
Thanks guys, this is probably what I need :)

Inc
13th January 2006, 10:10
Here is an examlpe of how you get the main info of an avifile using the vfw interface (vfw.h) in c/c++.
The Keyword is AVIFILEINFO.

AVIFileInit();

PAVIFILE avi;
int res=AVIFileOpen(&avi, szFileName, OF_READ, NULL);

if (res!=AVIERR_OK)
{
//an error occures
if (avi!=NULL)
AVIFileRelease(avi);

return FALSE;
}

AVIFILEINFO avi_info;
AVIFileInfo(avi, &avi_info, sizeof(AVIFILEINFO));

CString szFileInfo;
szFileInfo.Format("Dimention: %dx%d\n"
"Length: %d frames\n"
"Max bytes per second: %d\n"
"Samples per second: %d\n"
"Streams: %d\n"
"File Type: %d", avi_info.dwWidth,
avi_info.dwHeight,
avi_info.dwLength,
avi_info.dwMaxBytesPerSec,
(DWORD) (avi_info.dwRate / avi_info.dwScale),
avi_info.dwStreams,
avi_info.szFileType);

AfxMessageBox(szFileInfo, MB_ICONINFORMATION | MB_OK);

PAVISTREAM pStream;
res=AVIFileGetStream(avi, &pStream, streamtypeVIDEO /*video stream*/,
0 /*first stream*/);

if (res!=AVIERR_OK)
{
if (pStream!=NULL)
AVIStreamRelease(pStream);

AVIFileExit();
return FALSE;
}



Taken from here:
http://www.codeproject.com/audio/ExtractAVIFrames.asp
(a nice knowledgepool btw.)

stax76
13th January 2006, 10:31
Somebody is maintaining a C# avifile wrapper on CodeProject.

Zarxrax
13th January 2006, 14:25
Wow, thanks guys. So many options :)