andrewkirillov / AForge.NET

AForge.NET Framework is a C# framework designed for developers and researchers in the fields of Computer Vision and Artificial Intelligence - image processing, neural networks, genetic algorithms, machine learning, robotics, etc.
http://www.aforgenet.com/framework/
Other
1.09k stars 494 forks source link

Frequent Crash with VideoFileWriter #23

Open Prakash19921206 opened 7 years ago

Prakash19921206 commented 7 years ago

Hi all i get AccessViolationException occurred in AForge.Video.FFMPEG.dll . it occurs randomly anytime between app start to 30mins. even try catch block doesn't work. i'm running on x86 with .net framework v4.6 in C++/Cli

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.

Code:

 VideoFileWriter ^writer = gcnew VideoFileWriter();

 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;
   }

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

More Details here

is there a way to stop this error? Thanks

marianvoicu2002 commented 6 years ago

Hello,

I think there is a problem with VideoFileWriter because I saw memory leak for it. I use EmguCv for write a video file and it works perfect.

Thanks Marian