예제 #1
0
        /// <summary>
        /// Creates a new instance of <see cref="AviWriter"/>.
        /// </summary>
        /// <param name="FileName">Output file path.</param>
        /// <param name="Codec">The Avi Codec.</param>
        /// <param name="ImageProvider">The image source.</param>
        /// <param name="FrameRate">Video Frame Rate.</param>
        /// <param name="AudioProvider">The audio source. null = no audio.</param>
        public AviWriter(string FileName, AviCodec Codec, IImageProvider ImageProvider, int FrameRate, IAudioProvider AudioProvider = null)
        {
            _codec = Codec;

            _videoBuffer     = new byte[ImageProvider.Width * ImageProvider.Height * 4];
            _prevVideoBuffer = new byte[_videoBuffer.Length];
            _zeroBuffer      = new byte[_videoBuffer.Length];
            for (int i = 0; i < _zeroBuffer.Length; i++)
            {
                _zeroBuffer[i] = 0;
            }

            _writer = new AviInternalWriter(FileName)
            {
                FramesPerSecond = FrameRate,
                EmitIndex1      = true
            };

            CreateVideoStream(ImageProvider.Width, ImageProvider.Height);

            if (AudioProvider != null)
            {
                CreateAudioStream(AudioProvider);
            }
        }
예제 #2
0
        /// <summary>
        /// Frees all resources used by this object.
        /// </summary>
        public void Dispose()
        {
            lock (_syncLock)
            {
                _writer.Close();
                _writer = null;

                _videoStream = null;
                _audioStream = null;
            }

            _videoBuffer = null;
        }
예제 #3
0
        /// <summary>
        /// Creates a new instance of <see cref="AviWriter"/>.
        /// </summary>
        /// <param name="fileName">Output file path.</param>
        /// <param name="codec">The Avi Codec.</param>
        /// <param name="imageProvider">The image source.</param>
        /// <param name="frameRate">Video Frame Rate.</param>
        /// <param name="audioProvider">The audio source. null = no audio.</param>
        public AviWriter(string fileName, AviCodec codec, IImageProvider imageProvider, int frameRate, IAudioProvider audioProvider = null)
        {
            _codec = codec;

            _videoBuffer = new byte[imageProvider.Width * imageProvider.Height * 4];

            _writer = new AviInternalWriter(fileName)
            {
                FramesPerSecond = frameRate,
                EmitIndex1      = true
            };

            CreateVideoStream(imageProvider.Width, imageProvider.Height);

            if (audioProvider != null)
            {
                CreateAudioStream(audioProvider);
            }
        }
예제 #4
0
        /// <summary>
        /// Initialises the <see cref="IVideoFileWriter"/>. Usually called by an <see cref="IRecorder"/>.
        /// </summary>
        /// <param name="ImageProvider">The Image Provider.</param>
        /// <param name="FrameRate">Video Frame Rate.</param>
        /// <param name="AudioProvider">The Audio Provider.</param>
        public void Init(IImageProvider ImageProvider, int FrameRate, IAudioProvider AudioProvider)
        {
            this.FrameRate = FrameRate;
            _audioProvider = AudioProvider;
            _videoBuffer   = new byte[ImageProvider.Width * ImageProvider.Height * 4];

            _writer = new AviInternalWriter(_fileName)
            {
                FramesPerSecond = FrameRate,
                EmitIndex1      = true
            };

            CreateVideoStream(ImageProvider.Width, ImageProvider.Height);

            if (AudioProvider != null)
            {
                CreateAudioStream();
            }
        }