TheRain
User

Fresh Boarder
Posts: 3
graphgraph
 
Click here to see the profile of this user
Can you help me with AvDn C# and mpeg encoding? - 2007/08/17 16:29 Hey Daniel,

I'm trying to encode 24-bit RBG frames, frame by frame into MPEG, but I'm getting an memory access violation and can't figure out why. Can you take a look at my code and see if you can find the reason? The RGB data being passed to the AvFrame here is valid 24-bit RGB data. I've checked it and even checked that valid 24-bit RGB data is being filled in to the AvFrame structure by accessing the memory at avframe.GetData0();

It is the last line, the EncodeVideo line that is causing the exception. "Attempted to read or write protected memory. This is often an indication that other memory is corrupt."

Almost forgot to mention. It's opening an MPEG-1 file to set the codec... which I'm sure is not the best way, but it seemed like it should work.

Here is my code

Code:

 AvDn.AvDnFrame avFrame = new AvDnFrame();         AvDnCodec avCodec;         AvDnCodecContext avCodecContext;         IntPtr output Marshal.AllocHGlobal(200000); AvDn.AvDnUtils.RegisterAll();             AvDnFormatContext avfmnt = new AvDnFormatContext("sample.mpg");             avfmnt.FindStreamInfo();             avCodecContext avfmnt.GetCodecContextForStream(0);              avCodecContext.BitRate 400000;             avCodecContext.PixFmt Av.PIX_FMT_RGB24;             avCodecContext.Width 320;             avCodecContext.Height 240;             avCodecContext.SetTimeBase(125);             avCodecContext.GopSize 15;             avCodecContext.MbDecision 2;             avCodecContext.OpenEncoder(); avFrame.FillPicStruct(RAWRGB.Scan0Av.PIX_FMT_RGB24320240); int size avCodecContext.EncodeVideo(output200000avFrame); // Here's where it breaks



Any advice you can give would be greatly appreciated.
  | | No public write access. Please register.

      Topics Author Date
    thread link
Can you help me with AvDn C# and mpeg encoding?
TheRain 2007/08/17 16:29
    thread link
thread linkthread link Re:Can you help me with AvDn C# and mpeg encoding?
Daniel 2007/08/18 00:50
    thread link
thread linkthread linkthread link Re:Can you help me with AvDn C# and mpeg encoding?
TheRain 2007/08/18 07:24
    thread link
thread linkthread linkthread linkthread link Re:Can you help me with AvDn C# and mpeg encoding?
TheRain 2007/08/19 19:53
Joomla Template by Joomlashack
Joomla Templates by JoomlaShack Joomla Templates by Compass Design