public override void Init(Stream dstStream, VideoStreamInfo videoStreamInfo, AudioStreamInfo audioStreamInfo) { if (dstStream == null || videoStreamInfo == null) { throw new ArgumentException("At least destination stream and video stream info is needed"); } base.Init(dstStream, videoStreamInfo, audioStreamInfo); usingMultipleRiffs = false; totalFramesOld = 0; totalFrames = 0; totalSamples = 0; writer = new RiffWriter(dstStream); writer.BeginRiff(AviDemux.ID_AVI_); writer.BeginList(AviDemux.ID_hdrl); // main header offsets.avih = WriteMainHeader(writer, videoStreamInfo, hasAudioStream); // video stream header writer.BeginList(AviDemux.ID_strl); offsets.videoStrh = WriteVideoStreamHeader(writer, videoStreamInfo); WriteVideoFormatHeader(writer, videoStreamInfo); offsets.videoIndx = WriteDummySuperIndex(writer, AviDemux.ID_00dc, maxSuperindexEntries); videoSuperIndexEntryCount = 0; writer.EndList(); // end of strl videoIndex = new AviStreamIndex(); videoIndex.streamId = AviDemux.ID_00dc; if (hasAudioStream) { // audio stream header writer.BeginList(AviDemux.ID_strl); offsets.audioStrh = WriteAudioStreamHeader(writer, audioStreamInfo); WriteAudioFormatHeader(writer, audioStreamInfo); offsets.audioIndx = WriteDummySuperIndex(writer, AviDemux.ID_01wb, maxSuperindexEntries); audioSuperIndexEntryCount = 0; writer.EndList(); // end of strl audioIndex = new AviStreamIndex(); audioIndex.streamId = AviDemux.ID_01wb; } // odml header writer.BeginList(AviDemux.ID_odml); offsets.dmlh = WriteDmlhHeader(writer, videoStreamInfo.frameCount); writer.EndList(); writer.EndList(); // end of hdrl writer.BeginList(AviDemux.ID_movi); offsets.indexBase = writer.binaryWriter.Seek(0, SeekOrigin.Current); }
public override void Init(Stream dstStream, VideoStreamInfo videoStreamInfo, AudioStreamInfo audioStreamInfo) { if (dstStream == null || videoStreamInfo == null) { throw new ArgumentException ("At least destination stream and video stream info is needed"); } base.Init (dstStream, videoStreamInfo, audioStreamInfo); usingMultipleRiffs = false; totalFramesOld = 0; totalFrames = 0; totalSamples = 0; writer = new RiffWriter (dstStream); writer.BeginRiff (AviDemux.ID_AVI_); writer.BeginList (AviDemux.ID_hdrl); // main header offsets.avih = WriteMainHeader (writer, videoStreamInfo, hasAudioStream); // video stream header writer.BeginList (AviDemux.ID_strl); offsets.videoStrh = WriteVideoStreamHeader (writer, videoStreamInfo); WriteVideoFormatHeader (writer, videoStreamInfo); offsets.videoIndx = WriteDummySuperIndex (writer, AviDemux.ID_00dc, maxSuperindexEntries); videoSuperIndexEntryCount = 0; writer.EndList (); // end of strl videoIndex = new AviStreamIndex (); videoIndex.streamId = AviDemux.ID_00dc; if (hasAudioStream) { // audio stream header writer.BeginList (AviDemux.ID_strl); offsets.audioStrh = WriteAudioStreamHeader (writer, audioStreamInfo); WriteAudioFormatHeader (writer, audioStreamInfo); offsets.audioIndx = WriteDummySuperIndex (writer, AviDemux.ID_01wb, maxSuperindexEntries); audioSuperIndexEntryCount = 0; writer.EndList (); // end of strl audioIndex = new AviStreamIndex (); audioIndex.streamId = AviDemux.ID_01wb; } // odml header writer.BeginList (AviDemux.ID_odml); offsets.dmlh = WriteDmlhHeader (writer, videoStreamInfo.frameCount); writer.EndList (); writer.EndList (); // end of hdrl writer.BeginList (AviDemux.ID_movi); offsets.indexBase = writer.binaryWriter.Seek (0, SeekOrigin.Current); }
private void StartNewRiff() { if (videoIndex.entries.Count > 0) { WriteChunkIndex(writer, videoIndex, offsets.videoIndx, ref videoSuperIndexEntryCount, offsets.indexBase, maxSuperindexEntries); } if (hasAudioStream && audioIndex.entries.Count > 0) { WriteChunkIndex(writer, audioIndex, offsets.audioIndx, ref audioSuperIndexEntryCount, offsets.indexBase, maxSuperindexEntries); } writer.EndList(); // end of movi writer.EndRiff(); writer.BeginRiff(AviDemux.ID_AVIX); writer.BeginList(AviDemux.ID_movi); offsets.indexBase = writer.binaryWriter.Seek(0, SeekOrigin.Current); usingMultipleRiffs = true; }