/// <summary>Initialize a VideoStream for an existing stream</summary> /// <param name="aviFile">The file that contains the stream</param> /// <param name="aviStream">An IAVISTREAM from [aviFile]</param> public VideoStream(int aviFile, IntPtr aviStream) { this.aviFile = aviFile; this.aviStream = aviStream; Avi.AVISTREAMINFO streamInfo = GetStreamInfo(aviStream); //Avi.BITMAPINFOHEADER bih = new Avi.BITMAPINFOHEADER(); //int size = Marshal.SizeOf(bih); Avi.BITMAPINFO bih = new Avi.BITMAPINFO(); int size = Marshal.SizeOf(bih.bmiHeader); Avi.AVIStreamReadFormat(aviStream, 0, ref bih, ref size); if (bih.bmiHeader.biBitCount < 24) { size = Marshal.SizeOf(bih.bmiHeader) + Avi.PALETTE_SIZE; Avi.AVIStreamReadFormat(aviStream, 0, ref bih, ref size); CopyPalette(bih.bmiColors); } this.frameRate = (float)streamInfo.dwRate / (float)streamInfo.dwScale; this.width = (int)streamInfo.rcFrame.right; this.height = (int)streamInfo.rcFrame.bottom; this.frameSize = bih.bmiHeader.biSizeImage; this.countBitsPerPixel = bih.bmiHeader.biBitCount; this.firstFrame = Avi.AVIStreamStart(aviStream.ToInt32()); this.countFrames = Avi.AVIStreamLength(aviStream.ToInt32()); }
/// <summary>Read the stream's format information</summary> /// <returns>PCMWAVEFORMAT</returns> public Avi.PCMWAVEFORMAT GetFormat() { Avi.PCMWAVEFORMAT format = new Avi.PCMWAVEFORMAT(); int size = Marshal.SizeOf(format); int result = Avi.AVIStreamReadFormat(aviStream, 0, ref format, ref size); return(format); }
/// <summary>Initialize an AudioStream for an existing stream</summary> /// <param name="aviFile">The file that contains the stream</param> /// <param name="aviStream">An IAVISTREAM from [aviFile]</param> public AudioStream(int aviFile, IntPtr aviStream) { this.aviFile = aviFile; this.aviStream = aviStream; int size = Marshal.SizeOf(this.waveFormat); Avi.AVIStreamReadFormat(aviStream, 0, ref this.waveFormat, ref size); Avi.AVISTREAMINFO streamInfo = this.GetStreamInfo(aviStream); }
/// <summary>Initialize a VideoStream for an existing stream</summary> /// <param name="aviFile">The file that contains the stream</param> /// <param name="aviStream">An IAVISTREAM from [aviFile]</param> public VideoStream(int aviFile, IntPtr aviStream) { base.aviFile = aviFile; base.aviStream = aviStream; Avi.BITMAPINFOHEADER bih = new Avi.BITMAPINFOHEADER(); int size = Marshal.SizeOf(bih); Avi.AVIStreamReadFormat(aviStream, 0, ref bih, ref size); Avi.AVISTREAMINFO streamInfo = GetStreamInfo(aviStream); frameRate = streamInfo.dwRate / streamInfo.dwScale; width = (int)streamInfo.rcFrame.right; height = (int)streamInfo.rcFrame.bottom; frameSize = bih.biSizeImage; countBitsPerPixel = bih.biBitCount; int firstFrame = Avi.AVIStreamStart(aviStream.ToInt32()); countFrames = firstFrame + Avi.AVIStreamLength(aviStream.ToInt32()); }