Help, Access Violation Error

For the developers that use FFmpeg in their software.
Post Reply
Posts: 1
Joined: Wed Dec 14, 2011 1:16 pm

Help, Access Violation Error

Post by norantis » Wed Dec 14, 2011 2:00 pm


I use VS 2010 (.net 4 / c++) and Zeranoes 32bit-dev build. It took me a while, but i managed to open a mpv-file and decode frames. Then I tried avformat_seek_file and the program crashed with an Access Violation Error.
I believe it has somethings to do with managed/unmanaged memory. The whole Marshal thing is new to me, so how do I create AVFormatContext correct?

for now, it looks like this:

Code: Select all

AVFormatContext* fc;
I have already found a way to convert a String^

Code: Select all

String^ astring = "Hello";
char* pstring;
IntPtr ptr = System::Runtime::InteropServices::Marshal::StringToHGlobalAnsi( astring );
pstring = reinterpret_cast<char*>( static_cast<void*>( ptr ) );
I guess, creating AVFormatContext should be similar to that.

Posts: 1
Joined: Mon Jan 02, 2012 1:29 pm

Re: Help, Access Violation Error

Post by lastyome » Mon Jan 02, 2012 1:33 pm

I'm not sure this answer your problem, but I had an access violation error too and I figured out it was because I didn't use "avformat_alloc_context()" when creation my AVFormatContext pointer.

Code: Select all

AVFormatContext *pFormatCtx = avformat_alloc_context();
This is actually very hard to understand this library with so few good updated documentation...
Hope this helps!

Post Reply