private static extern int AVIStreamSetFormat(IntPtr aviStream, Int32 lPos, ref BITMAPINFOHEADER lpFormat, Int32 cbFormat);
private static extern int AVIStreamGetFrameOpen(IntPtr pAVIStream, ref BITMAPINFOHEADER bih);
unsafe private void SetOptions() { AVICOMPRESSOPTIONS opts = new AVICOMPRESSOPTIONS { fccType = fccType_, fccHandler = 0, // 541215044;//fccHandler_; dwKeyFrameEvery = 0, dwQuality = 0, // 0 .. 10000 dwFlags = 8, // AVICOMRPESSF_KEYFRAMES = 4 dwBytesPerSecond = 0, lpFormat = new IntPtr(0), cbFormat = 0, lpParms = new IntPtr(0), cbParms = 0, dwInterleaveEvery = 0 }; AVICOMPRESSOPTIONS * p = &opts; AVICOMPRESSOPTIONS **pp = &p; IntPtr x = ps_; IntPtr *ptr_ps = &x; // AVISaveOptions(0,1,1,ptr_ps,pp); // ps_ = (System.IntPtr) 3798676; // TODO: AVISaveOptionsFree(...) int hr = AVIMakeCompressedStream(out psCompressed_, ps_, ref opts, 0); if (hr != 0) { //throw new AviException("AVIMakeCompressedStream"); AVISaveOptions(0, 1, 1, ptr_ps, pp); hr = AVIMakeCompressedStream(out psCompressed_, ps_, ref opts, 0); if (hr != 0) { throw new Exception("AVIMakeCompressedStream"); } } BITMAPINFOHEADER bi = new BITMAPINFOHEADER { biSize = 40, biWidth = (Int32)width_, biHeight = (Int32)height_, biPlanes = 1, biBitCount = 24, biCompression = 0, // 0 = BI_RGB biSizeImage = stride_ * height_, biXPelsPerMeter = 0, biYPelsPerMeter = 0, biClrUsed = 0, biClrImportant = 0 }; hr = AVIStreamSetFormat(psCompressed_, 0, ref bi, 40); if (hr != 0) { throw new Exception("AVIStreamSetFormat"); } }