加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

.net – AForge.Video.FFMPEG.dll中发生AccessViolationExceptio

发布时间:2020-12-14 02:51:39 所属栏目:Windows 来源:网络整理
导读:我有一个相机类,在这个课程中我使用了一个计时器,在我的tick事件中,我使用AForge.Net的C/C++li中的VideoFileWriter保存视频(x86,.net framework:v4.6). 这不应该发生,因为这是托管代码.但即使我在try catch块中包装,程序也会因为AccessViolationException而
我有一个相机类,在这个课程中我使用了一个计时器,在我的tick事件中,我使用AForge.Net的C/C++li中的VideoFileWriter保存视频(x86,.net framework:v4.6).
这不应该发生,因为这是托管代码.但即使我在try catch块中包装,程序也会因为AccessViolationException而崩溃.我已经验证 Image不是null.与VideoFileWriter有关.这种情况发生在应用程序开始到运行30分钟之间.

An unhandled exception of type ‘System.AccessViolationException’
occurred in AForge.Video.FFMPEG.dll
Additional information: Attempted to read or write protected memory.
This is often an indication that other memory is corrupt.

在Visual Studio的输出中,我看到了

Exception thrown at 0x0C4D689F (swscale-2.dll) in test.exe: 0xC0000005: Access violation writing location 0x09F83D80.
Exception thrown: ‘System.AccessViolationException’ in
AForge.Video.FFMPEG.dll

码:

private: System::Void Video_Recorder_Tick(System::Object^  sender,System::Timers::ElapsedEventArgs^  e)
  {
      Bitmap^ save = ConvertMatToBitmap(image); //function to convert opencv's Mat to .net's Bitmap        
      if(writer!= nullptr)
       writer->WriteVideoFrame(save);
       delete save;
   }

  VideoFileWriter ^writer = gcnew VideoFileWriter();

  private: Void load_VideoWriter()
  {
    writer->Open("C:/video.avi",640,480,10,VideoCodec::Default);        
  }

Visual Studio显示了很少的编写器值

BitRate 400000
Codec Default
FrameRate 10
Height 480
IsOpen true
Width 640

如果有人需要更多信息,请告诉我.
调用堆栈没有多大帮助

enter image description here

令我惊讶的是,互联网上没有人有这个问题!
代码似乎很直接,可能是什么问题?

解决方法

将编解码器指定为AForge.Video.FFMPEG.VideoCodec.MPEG4,该错误应该消失.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读