/// <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;
}