/// <summary>Create a new AVI Player</summary>
 /// <param name="videoStream">Video stream to play</param>
 /// <param name="picDisplay">PictureBox to display the video</param>
 /// <param name="ctlFrameIndexFeedback">Optional Label to show the current frame index</param>
 public AviPlayer(VideoStream videoStream, PictureBox picDisplay, Control ctlFrameIndexFeedback)
 {
     this.videoStream = videoStream;
     this.picDisplay = picDisplay;
     this.ctlFrameIndexFeedback = ctlFrameIndexFeedback;
     this.isRunning = false;
 }
        /// <summary>Create an editable stream from an uneditable stream</summary>
        /// <param name="stream">uneditable stream</param>
        public EditableVideoStream(VideoStream stream)
            : base(stream.FrameSize, stream.FrameRate, stream.Width, stream.Height, stream.CountBitsPerPixel, stream.CountFrames, stream.CompressOptions, stream.WriteCompressed)
        {
            Avi.AVIFileInit();
            int result = Avi.CreateEditableStream(ref editableStream, stream.StreamPointer);

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

            SetInfo(stream.StreamInfo);
        }
        /// <summary>Copy all frames into a new file</summary>
        /// <param name="fileName">Name of the new file</param>
        /// <param name="recompress">true: Compress the new stream</param>
        /// <returns>AviManager for the new file</returns>
        /// <remarks>Use this method if you want to append frames to an existing, compressed stream</remarks>
        public AviManager DecompressToNewFile(String fileName, bool recompress, out VideoStream newStream2)
        {
            AviManager newFile = new AviManager(fileName, false);

            this.GetFrameOpen();

            Bitmap frame = GetBitmap(0);
            VideoStream newStream = newFile.AddVideoStream(recompress, frameRate, frame);
            frame.Dispose();

            for(int n=1; n<countFrames; n++){
                frame = GetBitmap(n);
                newStream.AddFrame(frame);
                frame.Dispose();
            }

            this.GetFrameClose();

            newStream2 = newStream;
            return newFile;
        }
 /// <summary>Paste a number of frames from another video stream into this stream</summary>
 /// <param name="sourceStream">Stream to copy from</param>
 /// <param name="copyPosition">Index of the first frame to copy</param>
 /// <param name="pastePosition">Where to paste the copied frames</param>
 /// <param name="length">Count of frames to paste</param>
 public void Paste(VideoStream sourceStream, int copyPosition, int pastePosition, int length)
 {
     Paste(sourceStream.StreamPointer, copyPosition, pastePosition, length);
 }
 /// <summary>Paste a number of frames from another video stream into this stream</summary>
 /// <param name="sourceStream">Stream to copy from</param>
 /// <param name="copyPosition">Index of the first frame to copy</param>
 /// <param name="pastePosition">Where to paste the copied frames</param>
 /// <param name="length">Count of frames to paste</param>
 public void Paste(VideoStream sourceStream, int copyPosition, int pastePosition, int length)
 {
     Paste(sourceStream.StreamPointer, copyPosition, pastePosition, length);
 }
        /// <summary>Get the first video stream - usually there is only one video stream</summary>
        /// <returns>VideoStream object for the stream</returns>
        public VideoStream GetVideoStream()
        {
            IntPtr aviStream;

            int result = Avi.AVIFileGetStream(
                aviFile,
                out aviStream,
                Avi.streamtypeVIDEO, 0);

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

            VideoStream stream = new VideoStream(aviFile, aviStream);
            streams.Add(stream);
            return stream;
        }
 /// <summary>Add an empty video stream to the file</summary>
 /// <param name="isCompressed">true: Create a compressed stream before adding frames</param>
 /// <param name="frameRate">Frames per second</param>
 /// <param name="firstFrame">Image to write into the stream as the first frame</param>
 /// <returns>VideoStream object for the new stream</returns>
 public VideoStream AddVideoStream(bool isCompressed, double frameRate, Bitmap firstFrame)
 {
     VideoStream stream = new VideoStream(aviFile, isCompressed, frameRate, firstFrame);
     streams.Add(stream);
     return stream;
 }
 /// <summary>Add an empty video stream to the file</summary>
 /// <remarks>Compresses the stream without showing the codecs dialog</remarks>
 /// <param name="compressOptions">Compression options</param>
 /// <param name="frameRate">Frames per second</param>
 /// <param name="firstFrame">Image to write into the stream as the first frame</param>
 /// <returns>VideoStream object for the new stream</returns>
 public VideoStream AddVideoStream(Avi.AVICOMPRESSOPTIONS compressOptions, double frameRate, Bitmap firstFrame)
 {
     VideoStream stream = new VideoStream(aviFile, compressOptions, frameRate, firstFrame);
     streams.Add(stream);
     return stream;
 }
 /// <summary>Add an empty video stream to the file</summary>
 /// <param name="isCompressed">true: Create a compressed stream before adding frames</param>
 /// <param name="frameRate">Frames per second</param>
 /// <param name="frameSize">Size of one frame in bytes</param>
 /// <param name="width">Width of each image</param>
 /// <param name="height">Height of each image</param>
 /// <param name="format">PixelFormat of the images</param>
 /// <returns>VideoStream object for the new stream</returns>
 public VideoStream AddVideoStream(bool isCompressed, double frameRate, int frameSize, int width, int height, PixelFormat format)
 {
     VideoStream stream = new VideoStream(aviFile, isCompressed, frameRate, frameSize, width, height, format);
     streams.Add(stream);
     return stream;
 }