Example #1
0
        /// <summary>Create a new stream</summary>
        private void CreateStreamWithoutFormat()
        {
            int    scale = 1;
            double rate  = this.frameRate;

            this.GetRateAndScale(ref rate, ref scale);
            Avi.AVISTREAMINFO strhdr = new Avi.AVISTREAMINFO();
            strhdr.fccType               = Avi.mmioStringToFOURCC("vids", 0);
            strhdr.fccHandler            = Avi.mmioStringToFOURCC("CVID", 0);
            strhdr.dwFlags               = 0;
            strhdr.dwCaps                = 0;
            strhdr.wPriority             = 0;
            strhdr.wLanguage             = 0;
            strhdr.dwScale               = (int)scale;
            strhdr.dwRate                = (int)rate; // Frames per Second
            strhdr.dwStart               = 0;
            strhdr.dwLength              = 0;
            strhdr.dwInitialFrames       = 0;
            strhdr.dwSuggestedBufferSize = this.frameSize; //height_ * stride_;
            strhdr.dwQuality             = -1;             //default
            strhdr.dwSampleSize          = 0;
            strhdr.rcFrame.top           = 0;
            strhdr.rcFrame.left          = 0;
            strhdr.rcFrame.bottom        = (uint)this.height;
            strhdr.rcFrame.right         = (uint)this.width;
            strhdr.dwEditCount           = 0;
            strhdr.dwFormatChangeCount   = 0;
            strhdr.szName                = new UInt16[64];
            int result = Avi.AVIFileCreateStream(this.aviFile, out this.aviStream, ref strhdr);

            if (result != 0)
            {
                throw new Exception("Exception in AVIFileCreateStream: " + result.ToString());
            }
        }
Example #2
0
 /// <summary>Copy the stream into a new file</summary>
 /// <param name="fileName">Name of the new file</param>
 public override void ExportStream(String fileName)
 {
     Avi.AVICOMPRESSOPTIONS_CLASS opts = new Avi.AVICOMPRESSOPTIONS_CLASS();
     opts.fccType           = (UInt32)Avi.mmioStringToFOURCC("auds", 0);
     opts.fccHandler        = (UInt32)Avi.mmioStringToFOURCC("CAUD", 0);
     opts.dwKeyFrameEvery   = 0;
     opts.dwQuality         = 0;
     opts.dwFlags           = 0;
     opts.dwBytesPerSecond  = 0;
     opts.lpFormat          = new IntPtr(0);
     opts.cbFormat          = 0;
     opts.lpParms           = new IntPtr(0);
     opts.cbParms           = 0;
     opts.dwInterleaveEvery = 0;
     Avi.AVISaveV(fileName, 0, 0, 1, ref this.aviStream, ref opts);
 }
Example #3
0
        /// <summary>Create a compressed stream from an uncompressed stream</summary>
        private void CreateCompressedStream(bool dialog)
        {
            Avi.AVICOMPRESSOPTIONS structOptions;

            if (dialog)
            {
                //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);
                Avi.AVISaveOptionsFree(1, ref options);
                structOptions = options.ToStruct();
            }
            else
            {
                //..or set static options
                structOptions.fccType           = (UInt32)Avi.mmioStringToFOURCC("vids", 0);
                structOptions.fccHandler        = (UInt32)Avi.mmioStringToFOURCC("CVID", 0);
                structOptions.dwKeyFrameEvery   = 0;
                structOptions.dwQuality         = 0;       // 0 .. 10000
                structOptions.dwFlags           = 0;       // AVICOMRPESSF_KEYFRAMES = 4
                structOptions.dwBytesPerSecond  = 0;
                structOptions.lpFormat          = new IntPtr(0);
                structOptions.cbFormat          = 0;
                structOptions.lpParms           = new IntPtr(0);
                structOptions.cbParms           = 0;
                structOptions.dwInterleaveEvery = 0;
            }

            //get the compressed stream
            int result = Avi.AVIMakeCompressedStream(out compressedStream, aviStream, ref structOptions, 0);

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

            SetFormat(compressedStream);
        }
Example #4
0
        /// <summary>Create a new stream</summary>
        private void CreateStream()
        {
            Avi.AVISTREAMINFO strhdr = new Avi.AVISTREAMINFO();
            strhdr.fccType               = Avi.mmioStringToFOURCC("vids", 0);
            strhdr.fccHandler            = Avi.mmioStringToFOURCC("CVID", 0);
            strhdr.dwFlags               = 0;
            strhdr.dwCaps                = 0;
            strhdr.wPriority             = 0;
            strhdr.wLanguage             = 0;
            strhdr.dwScale               = 1;
            strhdr.dwRate                = frameRate; // Frames per Second
            strhdr.dwStart               = 0;
            strhdr.dwLength              = 0;
            strhdr.dwInitialFrames       = 0;
            strhdr.dwSuggestedBufferSize = frameSize; //height_ * stride_;
            strhdr.dwQuality             = -1;        //default
            strhdr.dwSampleSize          = 0;
            strhdr.rcFrame.top           = 0;
            strhdr.rcFrame.left          = 0;
            strhdr.rcFrame.bottom        = (uint)height;
            strhdr.rcFrame.right         = (uint)width;
            strhdr.dwEditCount           = 0;
            strhdr.dwFormatChangeCount   = 0;
            strhdr.szName                = new UInt16[64];

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

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

            if (writeCompressed)
            {
                CreateCompressedStream(false);
            }
            else
            {
                SetFormat(aviStream);
            }
        }