Stack Overflow on Marshal.PtrToStructure reading wmv files
- by Nick Udell
Hi, I'm using a frame grabber class in order to capture and process each frame in a video. The class can be found here: http://www.codeproject.com/KB/graphics/FrameGrabber.aspx
I'm having issues with running it, however. When loading the file, it attempts to marshal a video format pointer into a VideoInfoHeader (I'm using DirectShow.Net). The code that does this is as follows:
videoInfo = (VideoInfoHeader)Marshal.PtrToStructure(mediaType.formatPtr, typeof(VideoInfoHeader));
When I run this it immediately crashes out of the debugging environment, probably with a stack overflow. When stepping through I can see that the formatPtr always equals 93, though I do not know what to make of this as I am fairly new to marshalling.
I have checked that the video runs fine in Windows Media Player.
This is essential in finding the dimensions of the video and also the size of the header, which needs to be skipped before the frames can be read.
I am running Windows 7 x64.
Any help on this would be much appreciated, I must've tried fifteen different frame grabbing techniques.