Start() public method

Start audio source.
Starts audio source and return execution to caller. audio source object creates background thread and notifies about new frames with the help of NewFrame event.
public Start ( ) : void
return void
コード例 #1
0
        /// <summary>
        ///   Starts recording. Only works if the player has
        ///   already been started and is grabbing frames.
        /// </summary>
        /// 
        public void StartRecording()
        {
            if (IsRecording || !IsPlaying) return;

            Rectangle area = CaptureRegion;
            string fileName = newFileName();

            int height = area.Height;
            int width = area.Width;
            int framerate = 1000 / screenStream.FrameInterval;
            int videoBitRate = 10 * 1000 * 1000;
            int audioBitRate = 320 * 1000;

            OutputPath = Path.Combine(main.CurrentDirectory, fileName);
            RecordingStartTime = DateTime.MinValue;
            videoWriter = new VideoFileWriter();

            if (CaptureAudioDevice != null)
            {
                audioDevice = new AudioCaptureDevice(CaptureAudioDevice.Guid);
                audioDevice.Format = SampleFormat.Format16Bit;
                audioDevice.SampleRate = Settings.Default.SampleRate;
                audioDevice.DesiredFrameSize = 4096;
                audioDevice.NewFrame += audioDevice_NewFrame;
                audioDevice.Start();

                videoWriter.Open(OutputPath, width, height, framerate, VideoCodec.H264, videoBitRate,
                    AudioCodec.MP3, audioBitRate, audioDevice.SampleRate, 1);
            }
            else
            {
                videoWriter.Open(OutputPath, width, height, framerate, VideoCodec.H264, videoBitRate);
            }

            HasRecorded = false;
            IsRecording = true;
        }
コード例 #2
0
        /// <summary>
        ///   Starts recording. Only works if the player has
        ///   already been started and is grabbing frames.
        /// </summary>
        /// 
        public void StartRecording()
        {
            if (IsRecording || !IsPlaying) 
                return;

            Rectangle area = CaptureRegion;
            string fileName = newFileName();

            int height = area.Height;
            int width = area.Width;
            int framerate = 1000 / screenStream.FrameInterval;
            int videoBitRate = 1200 * 1000;
            int audioBitRate = 320 * 1000;

            OutputPath = Path.Combine(main.CurrentDirectory, fileName);
            RecordingStartTime = DateTime.MinValue;
            videoWriter = new VideoFileWriter();

            // Create audio devices which have been checked
            var audioDevices = new List<AudioCaptureDevice>();
            foreach (var audioViewModel in AudioCaptureDevices)
            {
                if (!audioViewModel.Checked) 
                    continue;

                var device = new AudioCaptureDevice(audioViewModel.DeviceInfo);
                device.AudioSourceError += device_AudioSourceError;
                device.Format = SampleFormat.Format16Bit;
                device.SampleRate = Settings.Default.SampleRate;
                device.DesiredFrameSize = 2 * 4098;
                device.Start();

                audioDevices.Add(device);
            }

            if (audioDevices.Count > 0) // Check if we need to record audio
            {
                audioDevice = new AudioSourceMixer(audioDevices);
                audioDevice.AudioSourceError += device_AudioSourceError;
                audioDevice.NewFrame += audioDevice_NewFrame;
                audioDevice.Start();

                videoWriter.Open(OutputPath, width, height, framerate, VideoCodec.H264, videoBitRate,
                    AudioCodec.MP3, audioBitRate, audioDevice.SampleRate, audioDevice.Channels);
            }
            else
            {
                videoWriter.Open(OutputPath, width, height, framerate, VideoCodec.H264, videoBitRate);
            }

            HasRecorded = false;
            IsRecording = true;
        }