/// <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>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); }
void kinect_VideoFrameReady(object sender, ImageFrameReadyEventArgs e) { CurrTime = DateTime.Now; twColorTimestamp.WriteLine(CurrTime.ToString("yyyy-MM-dd HH:mm:ss.fffffff")); Bitmap bitmap = e.ImageFrame.ToBitmap(); if (previewCheckBox.Checked == true) preview.Image = bitmap; if (firstColorFrame) { aviColerStream = aviColorManager.AddVideoStream(false, 30, bitmap); firstColorFrame = false; } else { aviColerStream.AddFrame(bitmap); } }
void kinect_DepthFrameReady(object sender, ImageFrameReadyEventArgs e) { CurrTime = DateTime.Now; twDepthTimestamp.WriteLine(CurrTime.ToString("yyyy-MM-dd HH:mm:ss.fffffff")); //PlanarImage Image = e.ImageFrame.Image; //byte[] convertedDepthFrame = convertDepthFrame(Image.Bits); //Bitmap bitmap = new Bitmap(Image.Width, Image.Height, System.Drawing.Imaging.PixelFormat.Format32bppRgb); ////Create a BitmapData and Lock all pixels to be written //BitmapData bmpData = bitmap.LockBits( // new Rectangle(0, 0, bitmap.Width, bitmap.Height), // ImageLockMode.WriteOnly, bitmap.PixelFormat); //Marshal.Copy(convertedDepthFrame, 0, bmpData.Scan0, convertedDepthFrame.Length); //bitmap.UnlockBits(bmpData); if (rawDepth) { PlanarImage Image = e.ImageFrame.Image; rawDepthBinaryWriter.Write(Image.Bits); rawDepthBinaryWriter.Flush(); } else { Bitmap bitmap = e.ImageFrame.ToBitmap(); if (firstDepthFrame) { aviDepthStream = aviDepthManager.AddVideoStream(false, 30, bitmap); firstDepthFrame = false; } else { aviDepthStream.AddFrame(bitmap); } } }
/// <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>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; }