TheRain
User

Fresh Boarder
Posts: 3
graphgraph
 
Click here to see the profile of this user
Re:Can you help me with AvDn C# and mpeg encoding? - 2007/08/19 19:53 I figured out what the issue is. ffmpeg doesn't find a codec unless you specify YUV420P. The only way I could find to encode RGB data is to convert it to YUV420P... here's a method I wrote to take an IntPtr for an RGB frame and convert it to YUV420P:

Code:

         void RGB_to_YUV(IntPtr RGBFrameref IntPtr YUVFrameint widthint height)         {             YUVFrame Marshal.AllocHGlobal(width height 12 8);  // Allocate whole RGB Frame;             byte[] YUVBytes = new byte[width height 12 8];             int u=width*height;             int v=u+width*height/4;             byte[] RGBBytes = new byte[width height 3];             Marshal.Copy(RGBFrame,RGBBytes,0,width height 3);             int rgbPixels 0;             int chromaWidth width 2;             int chromaHeight height 2;             int yMask 1;             int xMask 1;             int yPtr 0;             int uPtr =u;             int vPtr =v;             byte Rc;             byte Gc;             byte Bc;             for (int y 0heighty++)             {                 for (int x 0widthx++)                 {                     Bc RGBBytes[rgbPixels++];                     Gc RGBBytes[rgbPixels++];                     Rc RGBBytes[rgbPixels++];                     YUVBytes[yPtr++] =(byte) ((0.257f Rc) + (0.504f Gc) + (0.098f Bc) + 16);                     if ((yMask) == && (xMask) == 0)                     {                         YUVBytes[uPtr++] = (byte)(-(0.148f Rc) - (0.291f Gc) + (0.439f Bc) + 128);                         YUVBytes[vPtr++] = (byte)((0.439f Rc) - (0.368f Gc) - (0.071f Bc) + 128);                     }                 }             }             Marshal.Copy(YUVBytes0YUVFrameYUVBytes.Length);         }

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