/// <summary>Create a compressed stream from an uncompressed stream</summary>
        private void CreateCompressedStream()
        {
            //display the compression options dialog...
            //Avi.AVICOMPRESSOPTIONS_CLASS options = new Avi.AVICOMPRESSOPTIONS_CLASS();
            //options.fccType = (uint)Avi.streamtypeVIDEO;

            //options.lpParms = IntPtr.Zero;
            //options.lpFormat = IntPtr.Zero;
            //Avi.AVISaveOptions(IntPtr.Zero, Avi.ICMF_CHOOSE_KEYFRAME | Avi.ICMF_CHOOSE_DATARATE, 1, ref aviStream, ref options);

            //..or set static options

            /*Avi.AVICOMPRESSOPTIONS opts = new Avi.AVICOMPRESSOPTIONS();
             * opts.fccType         = (UInt32)Avi.mmioStringToFOURCC("vids", 0);
             * opts.fccHandler      = (UInt32)Avi.mmioStringToFOURCC("CVID", 0);
             * opts.fccType = (UInt32)Avi.mmioStringToFOURCC("mrle", 0);
             * opts.fccHandler = (UInt32)Avi.mmioStringToFOURCC("MRLE", 0);
             *
             * opts.dwKeyFrameEvery = 0;
             * opts.dwQuality       = 0;  // 0 .. 10000
             * opts.dwFlags         = 0;  // AVICOMRPESSF_KEYFRAMES = 4
             * opts.dwBytesPerSecond= 0;
             * opts.lpFormat        = new IntPtr(0);
             * opts.cbFormat        = 0;
             * opts.lpParms         = new IntPtr(0);
             * opts.cbParms         = 0;
             * opts.dwInterleaveEvery = 0;*/

            //get the compressed stream
            Avi.AVICOMPRESSOPTIONS opts = new Avi.AVICOMPRESSOPTIONS();
            opts.fccType           = 0;
            opts.fccHandler        = (int)0x6376736d;
            opts.dwKeyFrameEvery   = 25;
            opts.dwQuality         = 10000;
            opts.dwFlags           = 8;
            opts.dwBytesPerSecond  = 0;
            opts.lpFormat          = new IntPtr(0);
            opts.cbFormat          = 0;
            opts.lpParms           = new IntPtr(0);
            opts.cbParms           = 4;
            opts.dwInterleaveEvery = 0;

            opts.lpParms = Marshal.AllocHGlobal(sizeof(int));
            //AVISaveOptions(0, 0, 1, ptr_ps, pp);
            //this.compressOptions = options.ToStruct();
            int result = Avi.AVIMakeCompressedStream(out compressedStream, aviStream, ref opts, 0);

            if (result != 0)
            {
                throw new Exception("Exception in AVIMakeCompressedStream: " + result.ToString());
            }

            //Avi.AVISaveOptionsFree(1, ref opts);
            SetFormat(compressedStream, 0);
        }
        /// <summary>Create a compressed stream from an uncompressed stream</summary>
        private void CreateCompressedStream(Avi.AVICOMPRESSOPTIONS options)
        {
            int result = Avi.AVIMakeCompressedStream(out compressedStream, aviStream, ref options, 0);

            if (result != 0)
            {
                throw new Exception("Exception in AVIMakeCompressedStream: " + result.ToString());
            }

            this.compressOptions = options;

            SetFormat(compressedStream, 0);
        }