Does anyone know how to use the AVIFileReadData method available from the avifil32.dll?
I would like to embed some custom data using the INFO chunk within an AVI file and then read it back again later - for purposes of querying the AVI file for certain information. I understand that you can write to any of the fourCC subchunks using the AVI Mux in DirectShow, so that's not the issue. It's the reading aspect that I am concerned with. From what I gathered reading the Microsoft SDK doc, the AVI Splitter filter exposes the IAMMediaContent interface, but it is only able to read the copyright, author name, and title. Here's the text from the IAMMediaContent page of the SDK doc:
"Depending on the stream type, a filter might support a subset of the methods on this interface. For example, the AVI Splitter retrieves the copyright, author name, and title from INFO chunks in the AVI file. The remaining methods return E_NOTIMPL."
Since the INFO chunk can store many other subchunks, I would like to use them - such as SUBJECT (fourCC=ISBJ), COMMENTS (fourCC=ICMT), etc. Of course, I would prefer using DirectShow, but it seems limited here. I know this is a DirectShow forum, but I don't know where else to post this question. I have found very little documentation regarding the use of the AVIFileReadData method. I am also coding in C#.
On the CodeProject website -
http://www.codeproject.com/KB/audio-video/avifilewrapper.aspx - there is a project that provides a .NET wrapper in C# for the AviFile library, but no examples or implementation of the particular AVIFileReadData method, however. Therefore, I added this declaration to the .NET wrapper library:
[DllImport("avifil32.dll")]
public static extern int AVIFileReadData(
int pfile,
int ckid,
IntPtr lpData,
out int lpcbData
);
The wrapper does contain the other method declarations and examples for initializing the libray, opening an AVI file, closing the file, converting a four-character-code to fourCC 32-bit int, and closing the library. So here's the button click procedure I created, but it fails with a negative HRESULT (-2147205005) on the AVIFileReadData line:
private void button5_Click(object sender, EventArgs e)
{
Avi.AVIFileInit();
int aviFile = 0;
int result;
result = Avi.AVIFileOpen(ref aviFile, "Cap0.avi", Avi.OF_READWRITE, 0);
if (result == 0)
{
int fourCCInfo = Avi.mmioFOURCC('I', 'S', 'B', 'J'); // subject subchunk
IntPtr dataPtr = Marshal.AllocHGlobal(256); // initialize a buffer big enough to hold the subject data
int dataSize;
result = Avi.AVIFileReadData(aviFile, fourCCInfo, dataPtr, out dataSize);
if (result == 0)
{
... if I could just get here, I could read the buffer...
}
else
{
MessageBox.Show("Can't read the INFO data: " + result.ToString());
}
// release resources and close the file
Avi.AVIFileRelease(aviFile);
Avi.AVIFileExit();
}
else
{
MessageBox.Show("Can't open AVI File: Cap0.avi - " + result.ToString());
}
}
If anyone could be of help...thank you! If there's another way...thank you!
Mark