Marshal.PtrToStructure 读取 wmv 文件时出现堆栈溢出
我正在使用帧捕获器类来捕获和处理视频中的每一帧。该类可以在这里找到: http://www.codeproject.com/KB/graphics /FrameGrabber.aspx
但是,我在运行它时遇到了问题。加载文件时,它尝试将视频格式指针封送到 VideoInfoHeader 中(我使用的是 DirectShow.Net)。执行此操作的代码如下:
videoInfo = (VideoInfoHeader)Marshal.PtrToStructure(mediaType.formatPtr, typeof(VideoInfoHeader));
当我运行此代码时,它会立即从调试环境中崩溃,可能会出现堆栈溢出。当单步执行时,我可以看到 formatPtr 始终等于 93,尽管我不知道该怎么做,因为我对编组相当陌生。
我检查过该视频在 Windows Media Player 中运行良好。
这对于查找视频的尺寸以及标题的大小至关重要,在读取帧之前需要跳过标题。
我运行的是 Windows 7 x64。
对此的任何帮助将不胜感激,我一定尝试过十五种不同的帧抓取技术。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许您的 mediaType 结构已损坏,您在调用之前检查它包含的内容吗?哪里填满了?
我还建议在 WinDbg 下运行您的应用程序。您可以在那里找到具体发生的事情。
如果您是新手,请尝试阅读 Tess Ferrandez 的博客。周围也有很多关于用WinDbg调试的资料,搜索一下即可。
Maybe your mediaType structure goes corrupt, do you check what it contains before call? Where it filled?
Also I recommend to run your app under WinDbg. You can find what exact happens there.
If you are new with it try to read Tess Ferrandez's Blog. There are also a lot of information about debugging with WinDbg around, just search.