/// <summary>Creates a new video stream in the AVI file</summary>
        private void CreateStream()
        {
            Avi.AVISTREAMINFO strhdr = new Avi.AVISTREAMINFO();
            strhdr.fccType               = fccType;
            strhdr.fccHandler            = fccHandler;
            strhdr.dwScale               = 1;
            strhdr.dwRate                = frameRate;
            strhdr.dwSuggestedBufferSize = (UInt32)(height * stride);
            strhdr.dwQuality             = 10000;             //highest quality! Compression destroys the hidden message
            strhdr.rcFrame.bottom        = (UInt32)height;
            strhdr.rcFrame.right         = (UInt32)width;
            strhdr.szName                = new UInt16[64];

            int result = Avi.AVIFileCreateStream(aviFile, out aviStream, ref strhdr);

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

            //define the image format
            Avi.BITMAPINFOHEADER bi = new Avi.BITMAPINFOHEADER();
            bi.biSize      = (UInt32)Marshal.SizeOf(bi);
            bi.biWidth     = (Int32)width;
            bi.biHeight    = (Int32)height;
            bi.biPlanes    = 1;
            bi.biBitCount  = 32;
            bi.biSizeImage = (UInt32)(stride * height);
            oldStream      = aviStream;
            aviStream      = CreateCompressedStream(aviStream);
            result         = Avi.AVIStreamSetFormat(aviStream, 0, ref bi, Marshal.SizeOf(bi));
            if (result != 0)
            {
                throw new Exception("Error in AVIStreamSetFormat: " + result.ToString());
            }
        }