AviFileOpen Handler Problem
- From: Basel S <BaselS@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 7 Oct 2008 13:27:01 -0700
I found some problems in dealing with Avi functions when trying the following
code (on visual Studio 2005 VC++):
#include <Vfw.h>
using namespace System;
using namespace System::IO;
using namespace System::Windows::Forms;
using namespace System::Diagnostics;
using namespace System::Runtime::InteropServices;
{
Stream^ myStream;
OpenFileDialog^ openFileDialog1 = gcnew OpenFileDialog;
openFileDialog1->Filter = "Audio-Video Interleaved (*.avi)|*.avi";
if (openFileDialog1->ShowDialog()==System::Windows::Forms::DialogResult::OK)
{
if ( (myStream = openFileDialog1->OpenFile()) != nullptr )
{
//declaration of some parameters
#define _SIZE MAX_PATH //Size of [char] buffers
PAVIFILE aviFile; //Handle for AVI file
PAVISTREAM aviStream; //Handle for video stream
AVISTREAMINFO aviStreamInfo; //Information about video stream
#define ErrAVIFile "Unable to open AVI file!"
#define ErrNoAVI "We need AVI file to work with!"
#define ErrGetStream "Unable to get video stream!"
#define ErrStreamInfo "Unable to resolve information about stream!"
String^ AVIFileName1; //AVI file
AVIFileName1 = openFileDialog1->FileName;
if (AVIFileName1[0]==0) //We need AVI file to work with
Debug::WriteLine(ErrNoAVI);
//Convert AVIFileName1 from String^ to LPCTSTR type.
IntPtr ptr = Marshal::StringToHGlobalAnsi(AVIFileName1);
LPCTSTR AVIFileName = reinterpret_cast<LPCTSTR>(ptr.ToPointer());
Marshal::FreeHGlobal(ptr);
AVIFileInit();
//The AVIFileOpen function opens an AVI file and returns the address of a
file interface used to access it.
int retVal=AVIFileOpen(&aviFile,AVIFileName,OF_READ,NULL);
if (retVal!=0)
Debug::WriteLine(ErrAVIFile);
if (retVal==REGDB_E_CLASSNOTREG)
Debug::WriteLine("According to the registry, the type of file
specified in AVIFileOpen does not have a handler to process it. ");
//The AVIFileGetStream function returns the address of a stream interface
that is associated with a specified AVI file.
retVal=AVIFileGetStream(aviFile,&aviStream,streamtypeVIDEO,0);
if (retVal!=0)
AVIFileExit(),Debug::WriteLine(ErrGetStream);
//The AVIFileRelease function decrements the reference count of an AVI file
interface handle and closes the file if the count reaches zero.
AVIFileRelease(aviFile);
//The AVIStreamInfo function obtains stream header information.
retVal=AVIStreamInfo(aviStream,&aviStreamInfo,sizeof(aviStreamInfo));
if (retVal!=0)
AVIFileExit(),Debug::WriteLine(ErrStreamInfo);
myStream->Close();
}
}
}
The Problem appeared when using AviFileOpen, I got "Unable to open AVI file!"
The function returns REGDB_E_CLASSNOTREG ("According to the registry, the
type of file specified in AVIFileOpen does not have a handler to process it.
")
When the debug continued to the next function AVIFileGetStream the program
broke and the following message appeared (First-chance exception at
0x73b55d6a in PixelPrecision.exe: 0xC0000005: Access violation reading
location 0x00000000.
A first chance exception of type 'System.AccessViolationException' occurred
in PixelPrecision.exe
An unhandled exception of type 'System.AccessViolationException' occurred in
PixelPrecision.exe
Additional information: Attempted to read or write protected memory. This is
often an indication that other memory is corrupt.)
I added the Vfw32.lib to the project>properties>Linker>Input>Additional
Dependencies
According to the problem: there is something wrong with the RIFF (Header)of
the Avi file, So I checked many different avi files and got the same problem.
Another possibilty for that problem is the Registry problem So I checked the
registry to make sure that the avi is right configured:
HKEY_CLASSES_ROUTE\.avi:
Avifile
HKEY_CLASSES_ROUTE\.avi\PersistentHandler:
{098f2470-bae0-11cd-b579-08002b30bfeb}
HKEY_CLASSES_ROUTE\AviFile\RIFFHANDLERS\Avi:
{00020000-0000-0000-C000-000000000046}
HKEY_CLASSES_ROUTE\AviFile\RIFFHANDLERS\Wave:
{00020003-0000-0000-C000-000000000046}
So could you figure out what’s the problem and make the corrections for the
previous code…
Thanks A lot
.
- Follow-Ups:
- Re: AviFileOpen Handler Problem
- From: Alessandro Angeli
- Re: AviFileOpen Handler Problem
- Prev by Date: Re: How to use the IDirectDrawColorControl::GetColorControls
- Next by Date: Re: AviFileOpen Handler Problem
- Previous by thread: How to use the IDirectDrawColorControl::GetColorControls
- Next by thread: Re: AviFileOpen Handler Problem
- Index(es):
Relevant Pages
|