public void Preview() { BITMAPINFOHEADER vidHdr = _aviReader.GetVideoStreamFormat(_aviReader.VideoStreamID); _frameModifier.SetVideoInfo(vidHdr.biWidth, Math.Abs(vidHdr.biHeight), AVIHelper.FourCC(vidHdr.biCompression)); Run(false); _ranPreview = true; }
private long StartList(string chunkID, string listType) { long offset = _fileOffset; byte[] hdr = new byte[12]; _openLists.Push(offset); BitConverterLE.WriteBytes(AVIHelper.FourCC(chunkID), hdr, 0); BitConverterLE.WriteBytes((uint)0, hdr, 4); BitConverterLE.WriteBytes(AVIHelper.FourCC(listType), hdr, 8); _fs.Write(hdr, 0, 12); _fileOffset += 12; return(offset); }
public static uint StreamFourCC(int streamID, string twoCC, bool twoCCFirst) { if ((streamID < 0) || (streamID > 255)) { throw new Exception("Invalid stream ID."); } string sID, sFCC; sID = streamID.ToString("X"); if (sID.Length == 1) { sID = "0" + sID; } sFCC = twoCCFirst ? twoCC + sID : sID + twoCC; return(AVIHelper.FourCC(sFCC)); }
private long WriteChunk(string chunkID, uint length) { return(WriteChunk(AVIHelper.FourCC(chunkID), new byte[length])); }
private long WriteChunk(string chunkID, byte[] data) { return(WriteChunk(AVIHelper.FourCC(chunkID), data)); }
private void ReadHeaders() { uint chunkID, dataSize, listType; long chunkOffset, firstRIFFEnd, moviEnd; byte[] data; bool inMOVI; moviEnd = -1; chunkOffset = ReadChunkHeader(out chunkID, out dataSize, out listType); if ((chunkOffset == -1) || (chunkID != AVIHelper.FourCC("RIFF")) || (listType != AVIHelper.FourCC("AVI "))) { throw new Exception("File isn't an AVI."); } firstRIFFEnd = _fileOffset + dataSize; while (_fileOffset < firstRIFFEnd) { chunkOffset = ReadChunkHeader(out chunkID, out dataSize, out listType); if (chunkOffset == -1) { break; } if (chunkID == ckIDLIST) { if (listType == AVIHelper.FourCC("movi")) { if (_videoStreamID == -1) { throw new Exception("Video stream not found."); } _moviOffset = chunkOffset; moviEnd = _fileOffset + dataSize; } continue; } inMOVI = (_moviOffset != -1) && (chunkOffset >= _moviOffset) && (chunkOffset < moviEnd); if (!inMOVI) { data = ReadChunkData(dataSize); if (data.Length < dataSize) { break; } } else { SkipChunkData(dataSize); data = null; } if (chunkID == AVIHelper.FourCC("strh")) { AVISTREAMHEADER strH = StructHelper <AVISTREAMHEADER> .FromBytes(data, 0, false); AVIStream s; if (strH.fccType == AVIHelper.FourCC("vids")) { s = new AVIStream(AVIStreamType.Video); if (_videoStreamID == -1) { _videoStreamID = _streamList.Count; } } else if (strH.fccType == AVIHelper.FourCC("auds")) { s = new AVIStream(AVIStreamType.Audio); } else { s = new AVIStream(AVIStreamType.Other); } s.Header = strH; _streamList.Add(s); } if (chunkID == AVIHelper.FourCC("strf")) { AVIStream stream = _streamList[_streamList.Count - 1]; int fmtSize = 0; int fmtExtraSize; if (stream.Type == AVIStreamType.Video) { stream.VideoFormat = StructHelper <BITMAPINFOHEADER> .FromBytes(data, 0, false); fmtSize = StructHelper <BITMAPINFOHEADER> .SizeOf; } else if (stream.Type == AVIStreamType.Audio) { stream.AudioFormat = StructHelper <WAVEFORMATEX> .FromBytes(data, 0, false); fmtSize = StructHelper <WAVEFORMATEX> .SizeOf; } else { fmtSize = 0; } fmtExtraSize = data.Length - fmtSize; if (fmtExtraSize > 0) { stream.FormatExtra = new byte[fmtExtraSize]; Buffer.BlockCopy(data, fmtSize, stream.FormatExtra, 0, fmtExtraSize); } } if (chunkID == AVIHelper.FourCC("strn")) { _streamList[_streamList.Count - 1].STRNData = data; } if (inMOVI && (AVIHelper.StreamID(chunkID, false) == _videoStreamID)) { _firstVideoChunkOffset = chunkOffset; Seek(moviEnd); } if (chunkID == AVIHelper.FourCC("indx")) { _isOpenDML = true; _foundIndex = ParseOpenDMLIndex(data); } if (chunkID == AVIHelper.FourCC("idx1")) { if (!_isOpenDML) { ParseOldIndex(data); _foundIndex = true; } } } if (_moviOffset == -1) { throw new Exception("\"movi\" list not found."); } SeekToStart(); }