public void SoftwareEncodingTest() { using (var outStream = new MemoryStream()) { RecorderOptions options = new RecorderOptions(); options.IsHardwareEncodingEnabled = false; using (var rec = Recorder.CreateRecorder(options)) { bool isError = false; bool isComplete = false; ManualResetEvent finalizeResetEvent = new ManualResetEvent(false); ManualResetEvent recordingResetEvent = new ManualResetEvent(false); rec.OnRecordingComplete += (s, args) => { isComplete = true; finalizeResetEvent.Set(); }; rec.OnRecordingFailed += (s, args) => { isError = true; finalizeResetEvent.Set(); recordingResetEvent.Set(); }; rec.Record(outStream); recordingResetEvent.WaitOne(3000); rec.Stop(); finalizeResetEvent.WaitOne(5000); Assert.IsFalse(isError); Assert.IsTrue(isComplete); Assert.AreNotEqual(outStream.Length, 0); } } }
private void TestRecord_Load(object sender, EventArgs e) { ScreenRecorderLib. RecorderOptions recorderOptions = new RecorderOptions() { RecorderMode = RecorderMode.Slideshow, VideoOptions = new VideoOptions() { SnapshotsInterval = 1, SnapshotFormat = ImageFormat.PNG, SnapshotsWithVideo = true, Framerate = 1 } }; stream = new MemoryStream(); recorder = Recorder.CreateRecorder(recorderOptions); recorder.OnRecordingComplete += Rec_OnRecordingComplete; recorder.OnRecordingFailed += Rec_OnRecordingFailed; recorder.OnStatusChanged += Rec_OnStatusChanged; recorder.OnSnapshotSaved += Rec_OnSnapShotSaved; recorder.Record("algo.mp4"); }
private static RecorderOptions GetRecorderOptions(Options cmd_opts) { //This is how you can select audio devices. If you want the system default device, //just leave the AudioInputDevice or AudioOutputDevice properties unset or pass null or empty string. var audioInputDevices = Recorder.GetSystemAudioDevices(AudioDeviceSource.InputDevices); var audioOutputDevices = Recorder.GetSystemAudioDevices(AudioDeviceSource.OutputDevices); string selectedAudioInputDevice = cmd_opts.Audio_input_device ?? (audioInputDevices.Count > 0 ? audioInputDevices.First().Key : null); string selectedAudioOutputDevice = audioOutputDevices.Count > 0 ? audioOutputDevices.First().Key : null; // Default to primary display, but allow overriding using CLI opt string defaultDisplayName = System.Windows.Forms.Screen.PrimaryScreen.DeviceName; string selectedDisplayName = string.IsNullOrEmpty(cmd_opts.Display_name) ? defaultDisplayName : cmd_opts.Display_name; var opts = new RecorderOptions { AudioOptions = new AudioOptions { AudioInputDevice = selectedAudioInputDevice, AudioOutputDevice = selectedAudioOutputDevice, IsAudioEnabled = cmd_opts.Audio_disabled == false, IsInputDeviceEnabled = true, IsOutputDeviceEnabled = true, }, DisplayOptions = new DisplayOptions { Top = cmd_opts.Top, Bottom = cmd_opts.Bottom, Left = cmd_opts.Left, Right = cmd_opts.Right, MonitorDeviceName = selectedDisplayName } }; return(opts); }
public void RecordingWithCropTest() { using (var outStream = new MemoryStream()) { RecorderOptions options = new RecorderOptions(); options.DisplayOptions = new DisplayOptions { Left = 100, Top = 100, Right = 500, Bottom = 500 }; using (var rec = Recorder.CreateRecorder(options)) { bool isError = false; bool isComplete = false; ManualResetEvent resetEvent = new ManualResetEvent(false); rec.OnRecordingComplete += (s, args) => { isComplete = true; resetEvent.Set(); }; rec.OnRecordingFailed += (s, args) => { isError = true; resetEvent.Set(); }; rec.Record(outStream); Thread.Sleep(3000); rec.Stop(); resetEvent.WaitOne(5000); Assert.IsFalse(isError); Assert.IsTrue(isComplete); Assert.AreNotEqual(outStream.Length, 0); } } }
public void RecordingWithAudioOutputTest() { using (var outStream = new MemoryStream()) { RecorderOptions options = new RecorderOptions(); options.AudioOptions = new AudioOptions { IsAudioEnabled = true }; using (var rec = Recorder.CreateRecorder(options)) { bool isError = false; bool isComplete = false; ManualResetEvent resetEvent = new ManualResetEvent(false); rec.OnRecordingComplete += (s, args) => { isComplete = true; resetEvent.Set(); }; rec.OnRecordingFailed += (s, args) => { isError = true; resetEvent.Set(); }; rec.Record(outStream); Thread.Sleep(3000); rec.Stop(); resetEvent.WaitOne(5000); Assert.IsFalse(isError); Assert.IsTrue(isComplete); Assert.AreNotEqual(outStream.Length, 0); } } }
public void RecordingToFileWithSnapshotsTest() { string filePath = Path.Combine(Path.GetTempPath(), Path.ChangeExtension(Path.GetRandomFileName(), ".mp4")); string snapshotsDir = Path.ChangeExtension(filePath, null); try { RecorderOptions options = new RecorderOptions(); options.VideoOptions = new VideoOptions { SnapshotsWithVideo = true, SnapshotsInterval = 2, SnapshotFormat = ImageFormat.JPEG }; using (var rec = Recorder.CreateRecorder(options)) { List <string> snapshotCallbackList = new List <string>(); bool isError = false; bool isComplete = false; ManualResetEvent finalizeResetEvent = new ManualResetEvent(false); ManualResetEvent recordingResetEvent = new ManualResetEvent(false); rec.OnRecordingComplete += (s, args) => { isComplete = true; finalizeResetEvent.Set(); }; rec.OnRecordingFailed += (s, args) => { isError = true; finalizeResetEvent.Set(); recordingResetEvent.Set(); }; rec.OnSnapshotSaved += (s, args) => { snapshotCallbackList.Add(args.SnapshotPath); }; rec.Record(filePath); recordingResetEvent.WaitOne(11900); // 10 < x < 12 sec rec.Stop(); finalizeResetEvent.WaitOne(5000); Assert.IsFalse(isError); Assert.IsTrue(isComplete); Assert.IsTrue(new FileInfo(filePath).Length > 0); var mediaInfo = new MediaInfoWrapper(filePath); Assert.IsTrue(mediaInfo.Format == "MPEG-4"); Assert.IsTrue(mediaInfo.VideoStreams.Count > 0); var snapshotsOnDisk = Directory.GetFiles(snapshotsDir); Assert.AreEqual(6, snapshotsOnDisk.Count()); // First snapshot taken at time 0. Assert.IsTrue(Enumerable.SequenceEqual(snapshotCallbackList, snapshotsOnDisk)); foreach (var snapshot in snapshotsOnDisk) { Assert.IsTrue(new MediaInfoWrapper(snapshot).Format == "JPEG"); } } } finally { File.Delete(filePath); Directory.Delete(snapshotsDir, recursive: true); } }
void TakeSnapshot() { if (!Directory.Exists(Path.Combine(Application.StartupPath, "Screenshots"))) { Directory.CreateDirectory(Path.Combine(Application.StartupPath, "Screenshots")); } string videoPath = Path.Combine(Application.StartupPath, "Screenshots", DateTime.Now.ToString("yyyy-MM-dd HH.mm.ss") + ".png"); RecorderOptions options = new RecorderOptions { RecorderMode = RecorderMode.Snapshot, }; _rec = Recorder.CreateRecorder(options); //_rec = Recorder.CreateRecorder(); _rec.OnRecordingComplete += Rec_OnRecordingComplete; _rec.OnRecordingFailed += Rec_OnRecordingFailed; _rec.OnStatusChanged += Rec_OnStatusChanged; //Record to a file //string videoPath = Path.Combine(Path.GetTempPath(), "test.mp4"); _rec.Record(videoPath); //..Or to a stream //_outStream = new MemoryStream(); //_rec.Record(_outStream); Debug.WriteLine("Started capturing"); }
public RecordService CreateRecorder(RecordProps props) { if (_recorder != null) { return(this); } var options = new RecorderOptions { RecorderApi = props.WndHandle.HasValue ? RecorderApi.WindowsGraphicsCapture : RecorderApi.DesktopDuplication, IsHardwareEncodingEnabled = _configService.Config.IsHardwareEncodingEnabled, IsLowLatencyEnabled = _configService.Config.IsLowLatencyEnabled, IsMp4FastStartEnabled = _configService.Config.IsMp4FastStartEnabled, DisplayOptions = new DisplayOptions { Top = props.Sides.Top, Bottom = props.Sides.Bottom, Left = props.Sides.Left, Right = props.Sides.Right, WindowHandle = props.WndHandle ?? IntPtr.Zero, MonitorDeviceName = props.MonitorName }, AudioOptions = new AudioOptions { IsAudioEnabled = _configService.Config.EnableSounds || _configService.Config.EnableMicrophone, IsOutputDeviceEnabled = _configService.Config.EnableSounds, IsInputDeviceEnabled = _configService.Config.EnableMicrophone, AudioOutputDevice = props.AudioOutputDevice, AudioInputDevice = props.AudioInputDevice, Bitrate = AudioBitrate.bitrate_128kbps, Channels = AudioChannels.Stereo }, VideoOptions = new VideoOptions { BitrateMode = BitrateControlMode.Quality, Quality = _configService.Config.Quality, Framerate = _configService.Config.Framerate, IsFixedFramerate = false, EncoderProfile = H264Profile.Main }, MouseOptions = new MouseOptions { IsMousePointerEnabled = _configService.Config.IsMousePointerEnabled, IsMouseClicksDetected = _configService.Config.IsMouseClicksDetected, MouseClickDetectionColor = "#FFFF00", MouseRightClickDetectionColor = "#FFFF00", MouseClickDetectionMode = MouseDetectionMode.Hook } }; _recorder = Recorder.CreateRecorder(options); _recorder.OnRecordingComplete += (sender, args) => Completed?.Invoke(args.FilePath); _recorder.OnRecordingFailed += (sender, args) => Failed?.Invoke(args.Error); _recorder.OnStatusChanged += (sender, args) => StatusChanged?.Invoke(args.Status); _recorder.OnSnapshotSaved += (sender, args) => SnapshotSaved?.Invoke(); return(this); }
static RecorderOptions OptionsFromArgs() { var args = GetCommandLineArgs(); var options = new RecorderOptions(); for (int i = 0; i < args.Length; i++) { var command = args[i].ToLower(); if (command == "--outdir") { options.OutputDirectory = args[++i]; } else if (command == "--triggerduration") { options.TriggerDuration = TimeSpan.FromMilliseconds(double.Parse(args[++i])); } else if (command == "--triggervolume") { options.TriggerVolume = double.Parse(args[++i]); } else if (command == "--endtriggerduration") { options.EndTriggerDuration = TimeSpan.FromMilliseconds(double.Parse(args[++i])); } else if (command == "--endtriggervolume") { options.EndTriggerVolume = double.Parse(args[++i]); } else if (command == "--minclipseparation") { options.MinClipSeparation = TimeSpan.FromMilliseconds(double.Parse(args[++i])); } else if (command == "--url") { options.Url = args[++i]; } else if (command == "--debug") { options.Debug = true; } else { if (!string.IsNullOrEmpty(command)) { Console.WriteLine($"Unrecognized command: {command}"); } } } return(options); }
public void SlideshowTest() { string directoryPath = Path.Combine(Path.GetTempPath(), Path.GetFileNameWithoutExtension(Path.GetRandomFileName())); try { RecorderOptions options = new RecorderOptions(); options.RecorderMode = RecorderMode.Slideshow; options.VideoOptions = new VideoOptions { Framerate = 5 }; Directory.CreateDirectory(directoryPath); Assert.IsTrue(Directory.Exists(directoryPath)); using (var rec = Recorder.CreateRecorder(options)) { bool isError = false; bool isComplete = false; ManualResetEvent finalizeResetEvent = new ManualResetEvent(false); ManualResetEvent recordingResetEvent = new ManualResetEvent(false); rec.OnRecordingComplete += (s, args) => { isComplete = true; finalizeResetEvent.Set(); }; rec.OnRecordingFailed += (s, args) => { isError = true; finalizeResetEvent.Set(); recordingResetEvent.Set(); }; rec.Record(directoryPath); recordingResetEvent.WaitOne(1000); rec.Stop(); finalizeResetEvent.WaitOne(5000); Assert.IsFalse(isError); Assert.IsTrue(isComplete); foreach (string filePath in Directory.GetFiles(directoryPath)) { FileInfo fi = new FileInfo(filePath); var mediaInfo = new MediaInfoWrapper(filePath); Assert.IsTrue(mediaInfo.Format == "PNG"); } } } finally { Directory.Delete(directoryPath, true); } }
/// <summary> /// Method automatically used on the start of each test for starting the video recording /// </summary> /// <param name="filename">File name for the record to be temporarily created before converting to Base64</param> public static void CreateRecording(string filename) { _fileName = filename; System.IO.Directory.CreateDirectory(path); string videoPath = Path.Combine(fullPath); RecorderOptions options = new RecorderOptions { RecorderMode = RecorderMode.Video, //If throttling is disabled, out of memory exceptions may eventually crash the program, //depending on encoder settings and system specifications. IsThrottlingDisabled = false, //Hardware encoding is enabled by default. IsHardwareEncodingEnabled = true, //Low latency mode provides faster encoding, but can reduce quality. IsLowLatencyEnabled = false, //Fast start writes the mp4 header at the beginning of the file, to facilitate streaming. IsMp4FastStartEnabled = false, AudioOptions = new AudioOptions { IsAudioEnabled = false }, VideoOptions = new VideoOptions { Bitrate = 1000 * 1000, Framerate = 30, IsMousePointerEnabled = true, IsFixedFramerate = true, EncoderProfile = H264Profile.Main } }; _rec = Recorder.CreateRecorder(options); _rec.OnRecordingComplete += Rec_OnRecordingComplete; _rec.OnRecordingFailed += Rec_OnRecordingFailed; _rec.OnStatusChanged += Rec_OnStatusChanged; try { _rec.Record(videoPath); Thread.Sleep(500); } catch (Exception) { throw; } }
public void Run50RecordingsTestWithOneInstance() { string error = ""; bool isError = false; bool isComplete = false; AutoResetEvent finalizeResetEvent = new AutoResetEvent(false); ManualResetEvent recordingResetEvent = new ManualResetEvent(false); RecorderOptions options = new RecorderOptions(); options.VideoOptions = new VideoOptions { Framerate = 60, IsFixedFramerate = false }; options.AudioOptions = new AudioOptions { IsAudioEnabled = true, IsInputDeviceEnabled = true, IsOutputDeviceEnabled = true }; using (var rec = Recorder.CreateRecorder(options)) { rec.OnRecordingComplete += (s, args) => { isComplete = true; finalizeResetEvent.Set(); }; rec.OnRecordingFailed += (s, args) => { isError = true; error = args.Error; finalizeResetEvent.Set(); recordingResetEvent.Set(); }; for (int i = 0; i < 50; i++) { using (var outStream = new MemoryStream()) { isError = false; isComplete = false; rec.Record(outStream); recordingResetEvent.WaitOne(2000); rec.Stop(); Assert.IsTrue(finalizeResetEvent.WaitOne(5000), $"[{i}] Recording finalize timed out"); Assert.IsNotNull(outStream, $"[{i}] Outstream is null"); Assert.IsFalse(isError, $"[{i}] Recording error: " + error); Assert.IsTrue(isComplete, $"[{i}] Recording not complete"); Assert.AreNotEqual(outStream.Length, 0, $"[{i}] Outstream length is 0"); } } } }
public void RecordScreen(RecorderParams recorderParams) { string videoPath = recorderParams.FileName; var recorderOptions = new RecorderOptions(); recorderOptions.VideoOptions = new VideoOptions(); recorderOptions.VideoOptions.BitrateMode = BitrateControlMode.Quality; recorderOptions.VideoOptions.Quality = recorderParams.Quality; _rec = Recorder.CreateRecorder(recorderOptions); //_rec.OnRecordingComplete += Rec_OnRecordingComplete; //_rec.OnRecordingFailed += Rec_OnRecordingFailed; // _rec.OnStatusChanged += Rec_OnStatusChanged; //Record to a file _rec.Record(videoPath); }
public void ScreenshotTestWithCropping() { RecorderOptions options = new RecorderOptions(); options.RecorderMode = RecorderMode.Snapshot; options.DisplayOptions = new DisplayOptions { Left = 100, Top = 100, Right = 200, Bottom = 200 }; string filePath = Path.Combine(Path.GetTempPath(), Path.ChangeExtension(Path.GetRandomFileName(), ".png")); try { using (var rec = Recorder.CreateRecorder(options)) { bool isError = false; bool isComplete = false; ManualResetEvent finalizeResetEvent = new ManualResetEvent(false); ManualResetEvent recordingResetEvent = new ManualResetEvent(false); rec.OnRecordingComplete += (s, args) => { isComplete = true; finalizeResetEvent.Set(); }; rec.OnRecordingFailed += (s, args) => { isError = true; finalizeResetEvent.Set(); recordingResetEvent.Set(); }; rec.Record(filePath); recordingResetEvent.WaitOne(3000); rec.Stop(); finalizeResetEvent.WaitOne(5000); Assert.IsFalse(isError); Assert.IsTrue(isComplete); Assert.IsTrue(new FileInfo(filePath).Length > 0); var mediaInfo = new MediaInfoWrapper(filePath); Assert.IsTrue(mediaInfo.Format == "PNG"); } } finally { File.Delete(filePath); } }
public void CreateRecording() { RecorderOptions options = new RecorderOptions { RecorderMode = RecorderMode.Video, //If throttling is disabled, out of memory exceptions may eventually crash the program, //depending on encoder settings and system specifications. IsThrottlingDisabled = false, //Hardware encoding is enabled by default. IsHardwareEncodingEnabled = true, //Low latency mode provides faster encoding, but can reduce quality. IsLowLatencyEnabled = false, //Fast start writes the mp4 header at the beginning of the file, to facilitate streaming. IsMp4FastStartEnabled = false, AudioOptions = new AudioOptions { Bitrate = AudioBitrate.bitrate_128kbps, Channels = AudioChannels.Stereo, IsAudioEnabled = true }, VideoOptions = new VideoOptions { //BitrateMode = BitrateControlMode.UnconstrainedVBR, Bitrate = 8000 * 1000, Framerate = 60, IsMousePointerEnabled = true, IsFixedFramerate = true, EncoderProfile = H264Profile.Main } }; string videoPath = Path.Combine(Path.GetTempPath(), "test.mp4"); _rec = Recorder.CreateRecorder(options); _rec.OnRecordingComplete += Rec_OnRecordingComplete; _rec.OnRecordingFailed += Rec_OnRecordingFailed; _rec.OnStatusChanged += Rec_OnStatusChanged; //Record to a file //string videoPath = Path.Combine(Path.GetTempPath(), "test.mp4"); _rec.Record(videoPath); //..Or to a stream //_outStream = new MemoryStream(); //_rec.Record(_outStream); }
public void Run50RecordingsTestWithOneInstance() { string error = ""; bool isError = false; bool isComplete = false; AutoResetEvent resetEvent = new AutoResetEvent(false); RecorderOptions options = new RecorderOptions(); options.VideoOptions = new VideoOptions { Framerate = 60, IsFixedFramerate = false }; var rec = ScreenRecorderLib.Recorder.CreateRecorder(options); rec.OnRecordingComplete += (s, args) => { isComplete = true; resetEvent.Set(); }; rec.OnRecordingFailed += (s, args) => { isError = true; error = args.Error; resetEvent.Set(); }; for (int i = 0; i < 50; i++) { Stream outStream = new MemoryStream(); isError = false; isComplete = false; rec.Record(outStream); Thread.Sleep(2000); rec.Stop(); Assert.IsTrue(resetEvent.WaitOne(5000), "Recording finalize timed out"); Assert.IsNotNull(outStream, "Outstream is null"); Assert.IsFalse(isError, "Recording error: " + error); Assert.IsTrue(isComplete, "Recording not complete"); Assert.AreNotEqual(outStream.Length, 0, "Outstream length is 0"); outStream.Dispose(); } rec.Dispose(); rec = null; }
private async void Window_Initialized(object sender, EventArgs e) { Options = RecorderOptions.Load(ConfigFile, out var exists); if (!exists) { bool amd = await Utils.IsAcceleratorAvailable(RecorderOptions.HardwareAccel.AMD); if (amd) { Options.HardwareAcceleration = RecorderOptions.HardwareAccel.AMD; } else { bool nvidia = await Utils.IsAcceleratorAvailable(RecorderOptions.HardwareAccel.NVIDIA); if (nvidia) { Options.HardwareAcceleration = RecorderOptions.HardwareAccel.NVIDIA; } } Options.Save(ConfigFile); } AudioDevices = (await Utils.GetAudioDevices()); foreach (var device in AudioDevices) { device.Enabled = Options.AudioDevices.Contains(device.AltName); } SaveHotkey.Hotkey = Options.SaveReplayHotkey; SaveOptions(); Recorder = new FFmpegRecorder(Options); Recorder.Stopped += this.Recorder_Stopped; Recorder.Started += this.Recorder_Started; await Recorder.StartAsync(); }
public void Run50RecordingsTestWithDifferentInstances() { for (int i = 0; i < 50; i++) { using (Stream outStream = new MemoryStream()) { RecorderOptions options = new RecorderOptions(); options.VideoOptions = new VideoOptions { Framerate = 60, IsFixedFramerate = false }; using (var rec = Recorder.CreateRecorder(options)) { string error = ""; bool isError = false; bool isComplete = false; ManualResetEvent resetEvent = new ManualResetEvent(false); rec.OnRecordingComplete += (s, args) => { isComplete = true; resetEvent.Set(); }; rec.OnRecordingFailed += (s, args) => { isError = true; error = args.Error; resetEvent.Set(); }; rec.Record(outStream); Thread.Sleep(2000); rec.Stop(); Assert.IsTrue(resetEvent.WaitOne(5000), $"[{i}] Recording finalize timed out"); Assert.IsNotNull(outStream, $"[{i}] Outstream is null"); Assert.IsFalse(isError, $"[{i}] Recording error: " + error); Assert.IsTrue(isComplete, $"[{i}] Recording not complete"); Assert.AreNotEqual(outStream.Length, 0, $"[{i}] Outstream length is 0"); } } } }
public static async void Start() { Directory.CreateDirectory(Environment.GetEnvironmentVariable("APPDATA") + "\\Alan\\screenshare"); RecorderOptions options = new RecorderOptions { VideoOptions = new VideoOptions() }; options.VideoOptions.BitrateMode = BitrateControlMode.Quality; recorder = Recorder.CreateRecorder(options); recorder2 = Recorder.CreateRecorder(options); recorder.OnRecordingComplete += Recorder_OnRecordingComplete; recorder2.OnRecordingComplete += Recorder_OnRecordingComplete; while (true) { try { options.VideoOptions.Bitrate = STREAM_BITRATE; options.VideoOptions.Framerate = STREAM_FRAMES; recorder.SetOptions(options); recorder2.SetOptions(options); if (RecordersReset) { if (s.Count > 0) recorder2.Record(Path.Combine(Environment.GetEnvironmentVariable("APPDATA") + "\\Alan\\screenshare\\" + DateTimeOffset.Now.ToUnixTimeMilliseconds() + ".mp4")); recorder.Stop(); } else { recorder2.Stop(); if (s.Count > 0) recorder.Record(Path.Combine(Environment.GetEnvironmentVariable("APPDATA") + "\\Alan\\screenshare\\" + DateTimeOffset.Now.ToUnixTimeMilliseconds() + ".mp4")); } RecordersReset = !RecordersReset; } catch { } await Task.Delay(STREAM_SECONDS * 1000); } }
public void CustomFixedBitrateTest() { using (var outStream = new MemoryStream()) { RecorderOptions options = new RecorderOptions(); options.VideoOptions = new VideoOptions { BitrateMode = BitrateControlMode.CBR, Bitrate = 4000 }; using (var rec = Recorder.CreateRecorder(options)) { bool isError = false; bool isComplete = false; ManualResetEvent finalizeResetEvent = new ManualResetEvent(false); ManualResetEvent recordingResetEvent = new ManualResetEvent(false); rec.OnRecordingComplete += (s, args) => { isComplete = true; finalizeResetEvent.Set(); }; rec.OnRecordingFailed += (s, args) => { isError = true; finalizeResetEvent.Set(); recordingResetEvent.Set(); }; rec.Record(outStream); recordingResetEvent.WaitOne(3000); rec.Stop(); finalizeResetEvent.WaitOne(5000); Assert.IsFalse(isError); Assert.IsTrue(isComplete); Assert.AreNotEqual(outStream.Length, 0); } } }
public void CreateRecording(String recordingType) { RecorderOptions recOpt = getRecordingOptions(recordingType); _rec = Recorder.CreateRecorder(recOpt); _rec.OnRecordingComplete += Rec_OnRecordingComplete; _rec.OnRecordingFailed += Rec_OnRecordingFailed; _rec.OnStatusChanged += Rec_OnStatusChanged; //Record to a file string videoPath = Path.Combine(outPath, fileName); Console.WriteLine($"Full path is {videoPath}"); if (File.Exists(videoPath)) { Console.WriteLine($"Deleting file {videoPath}"); File.Delete(videoPath); } _rec.Record(videoPath); //..Or to a stream //_outStream = new MemoryStream(); //_rec.Record(_outStream); }
static void Main(string[] args) { var inputDevices = Recorder.GetSystemAudioDevices(AudioDeviceSource.InputDevices); var opts = new RecorderOptions { AudioOptions = new AudioOptions { AudioInputDevice = inputDevices.First(), IsAudioEnabled = true, IsInputDeviceEnabled = true, IsOutputDeviceEnabled = true, }, }; Recorder rec = Recorder.CreateRecorder(opts); rec.OnRecordingFailed += Rec_OnRecordingFailed; rec.OnRecordingComplete += Rec_OnRecordingComplete; rec.OnStatusChanged += Rec_OnStatusChanged; Console.WriteLine("Press ENTER to start recording or ESC to exit"); while (true) { ConsoleKeyInfo info = Console.ReadKey(true); if (info.Key == ConsoleKey.Enter) { break; } else if (info.Key == ConsoleKey.Escape) { return; } } rec.Record(Path.ChangeExtension(Path.GetTempFileName(), ".mp4")); CancellationTokenSource cts = new CancellationTokenSource(); var token = cts.Token; Task.Run(async() => { while (true) { if (token.IsCancellationRequested) { return; } if (_isRecording) { Dispatcher.CurrentDispatcher.Invoke(() => { Console.Write(String.Format("\rElapsed: {0}s:{1}ms", _stopWatch.Elapsed.Seconds, _stopWatch.Elapsed.Milliseconds)); }); } await Task.Delay(10); } }, token); while (true) { ConsoleKeyInfo info = Console.ReadKey(true); if (info.Key == ConsoleKey.Escape) { break; } } cts.Cancel(); rec.Stop(); Console.WriteLine(); Console.ReadKey(); }
private async void RecordButton_Click(object sender, RoutedEventArgs e) { if (IsRecording) { _rec.Stop(); _progressTimer?.Stop(); _progressTimer = null; _secondsElapsed = 0; RecordButton.IsEnabled = false; return; } OutputResultTextBlock.Text = ""; UpdateProgress(); string videoPath = ""; if (CurrentRecordingMode == RecorderMode.Video) { string timestamp = DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss"); videoPath = Path.Combine(Path.GetTempPath(), "ScreenRecorder", timestamp, timestamp + ".mp4"); } else if (CurrentRecordingMode == RecorderMode.Slideshow) { //For slideshow just give a folder path as input. string timestamp = DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss"); videoPath = Path.Combine(Path.GetTempPath(), "ScreenRecorder", timestamp) + "\\"; } else if (CurrentRecordingMode == RecorderMode.Snapshot) { string timestamp = DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss-ff"); videoPath = Path.Combine(Path.GetTempPath(), "ScreenRecorder", timestamp, timestamp + GetImageExtension()); } _progressTimer = new DispatcherTimer(); _progressTimer.Tick += _progressTimer_Tick; _progressTimer.Interval = TimeSpan.FromSeconds(1); _progressTimer.Start(); int right = 0; Int32.TryParse(this.RecordingAreaRightTextBox.Text, out right); int bottom = 0; Int32.TryParse(this.RecordingAreaBottomTextBox.Text, out bottom); int left = 0; Int32.TryParse(this.RecordingAreaLeftTextBox.Text, out left); int top = 0; Int32.TryParse(this.RecordingAreaTopTextBox.Text, out top); Display selectedDisplay = (Display)this.ScreenComboBox.SelectedItem; string audioOutputDevice = AudioOutputsComboBox.SelectedValue as string; string audioInputDevice = AudioInputsComboBox.SelectedValue as string; RecorderOptions options = new RecorderOptions { RecorderMode = CurrentRecordingMode, IsThrottlingDisabled = this.IsThrottlingDisabled, IsHardwareEncodingEnabled = this.IsHardwareEncodingEnabled, IsLowLatencyEnabled = this.IsLowLatencyEnabled, IsMp4FastStartEnabled = this.IsMp4FastStartEnabled, IsFragmentedMp4Enabled = this.IsFragmentedMp4Enabled, AudioOptions = new AudioOptions { Bitrate = AudioBitrate.bitrate_96kbps, Channels = AudioChannels.Stereo, IsAudioEnabled = this.IsAudioEnabled, IsOutputDeviceEnabled = IsAudioOutEnabled, IsInputDeviceEnabled = IsAudioInEnabled, AudioOutputDevice = audioOutputDevice, AudioInputDevice = audioInputDevice }, VideoOptions = new VideoOptions { BitrateMode = this.CurrentVideoBitrateMode, Bitrate = VideoBitrate * 1000, Framerate = this.VideoFramerate, Quality = this.VideoQuality, IsFixedFramerate = this.IsFixedFramerate, EncoderProfile = this.CurrentH264Profile, SnapshotFormat = CurrentImageFormat }, DisplayOptions = new DisplayOptions(selectedDisplay.DisplayName, left, top, right, bottom), MouseOptions = new MouseOptions { IsMouseClicksDetected = this.IsMouseClicksDetected, IsMousePointerEnabled = this.IsMousePointerEnabled, MouseClickDetectionColor = this.MouseLeftClickColor, MouseRightClickDetectionColor = this.MouseRightClickColor, MouseClickDetectionRadius = this.MouseClickRadius, MouseClickDetectionDuration = this.MouseClickDuration, MouseClickDetectionMode = this.CurrentMouseDetectionMode } }; if (_rec == null) { _rec = Recorder.CreateRecorder(options); _rec.OnRecordingComplete += Rec_OnRecordingComplete; _rec.OnRecordingFailed += Rec_OnRecordingFailed; _rec.OnStatusChanged += _rec_OnStatusChanged; } else { _rec.SetOptions(options); } if (RecordToStream) { Directory.CreateDirectory(Path.GetDirectoryName(videoPath)); _outputStream = new FileStream(videoPath, FileMode.Create); _rec.Record(_outputStream); } else { _rec.Record(videoPath); } _secondsElapsed = 0; IsRecording = true; }
static void Main(string[] args) { //This is how you can select audio devices. If you want the system default device, //just leave the AudioInputDevice or AudioOutputDevice properties unset or pass null or empty string. var audioInputDevices = Recorder.GetSystemAudioDevices(AudioDeviceSource.InputDevices); var audioOutputDevices = Recorder.GetSystemAudioDevices(AudioDeviceSource.OutputDevices); string selectedAudioInputDevice = audioInputDevices.Count > 0 ? audioInputDevices.First().Key : null; string selectedAudioOutputDevice = audioOutputDevices.Count > 0 ? audioOutputDevices.First().Key : null; var opts = new RecorderOptions { AudioOptions = new AudioOptions { AudioInputDevice = selectedAudioInputDevice, AudioOutputDevice = selectedAudioOutputDevice, IsAudioEnabled = true, IsInputDeviceEnabled = true, IsOutputDeviceEnabled = true, } }; Recorder rec = Recorder.CreateRecorder(opts); rec.OnRecordingFailed += Rec_OnRecordingFailed; rec.OnRecordingComplete += Rec_OnRecordingComplete; rec.OnStatusChanged += Rec_OnStatusChanged; Console.WriteLine("Press ENTER to start recording or ESC to exit"); while (true) { ConsoleKeyInfo info = Console.ReadKey(true); if (info.Key == ConsoleKey.Enter) { break; } else if (info.Key == ConsoleKey.Escape) { return; } } rec.Record(Path.ChangeExtension(Path.GetTempFileName(), ".mp4")); CancellationTokenSource cts = new CancellationTokenSource(); var token = cts.Token; Task.Run(async() => { while (true) { if (token.IsCancellationRequested) { return; } if (_isRecording) { Console.Write(String.Format("\rElapsed: {0}s:{1}ms", _stopWatch.Elapsed.Seconds, _stopWatch.Elapsed.Milliseconds)); } await Task.Delay(10); } }, token); while (true) { ConsoleKeyInfo info = Console.ReadKey(true); if (info.Key == ConsoleKey.Escape) { break; } } cts.Cancel(); rec.Stop(); Console.WriteLine(); Console.ReadKey(); }
private void RecordButton_Click(object sender, RoutedEventArgs e) { if (IsRecording) { _rec.Stop(); _progressTimer?.Stop(); _progressTimer = null; _secondsElapsed = 0; IsRecording = false; return; } OutputResultTextBlock.Text = ""; string videoPath = ""; if (CurrentRecordingMode == RecorderMode.Video) { string timestamp = DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss"); videoPath = Path.Combine(Path.GetTempPath(), "ScreenRecorder", timestamp, timestamp + ".mp4"); } else if (CurrentRecordingMode == RecorderMode.Slideshow) { //For slideshow just give a folder path as input. string timestamp = DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss"); videoPath = Path.Combine(Path.GetTempPath(), "ScreenRecorder", timestamp) + "\\"; } else if (CurrentRecordingMode == RecorderMode.Snapshot) { string timestamp = DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss-ff"); videoPath = Path.Combine(Path.GetTempPath(), "ScreenRecorder", timestamp, timestamp + ".png"); } _progressTimer = new DispatcherTimer(); _progressTimer.Tick += _progressTimer_Tick; _progressTimer.Interval = TimeSpan.FromSeconds(1); _progressTimer.Start(); int right = 0; Int32.TryParse(this.RecordingAreaRightTextBox.Text, out right); int bottom = 0; Int32.TryParse(this.RecordingAreaBottomTextBox.Text, out bottom); int left = 0; Int32.TryParse(this.RecordingAreaLeftTextBox.Text, out left); int top = 0; Int32.TryParse(this.RecordingAreaTopTextBox.Text, out top); RecorderOptions options = new RecorderOptions { RecorderMode = CurrentRecordingMode, IsThrottlingDisabled = this.IsThrottlingDisabled, IsHardwareEncodingEnabled = this.IsHardwareEncodingEnabled, IsLowLatencyEnabled = this.IsLowLatencyEnabled, IsMp4FastStartEnabled = this.IsMp4FastStartEnabled, AudioOptions = new AudioOptions { Bitrate = AudioBitrate.bitrate_96kbps, Channels = AudioChannels.Stereo, IsAudioEnabled = this.IsAudioEnabled }, VideoOptions = new VideoOptions { Bitrate = VideoBitrate * 1000, Framerate = this.VideoFramerate, IsMousePointerEnabled = this.IsMousePointerEnabled, IsFixedFramerate = this.IsFixedFramerate, EncoderProfile = this.CurrentH264Profile }, DisplayOptions = new DisplayOptions(this.ScreenComboBox.SelectedIndex, left, top, right, bottom) }; _rec = Recorder.CreateRecorder(options); _rec.OnRecordingComplete += Rec_OnRecordingComplete; _rec.OnRecordingFailed += Rec_OnRecordingFailed; _rec.OnStatusChanged += _rec_OnStatusChanged; if (RecordToStream) { Directory.CreateDirectory(Path.GetDirectoryName(videoPath)); _outputStream = new FileStream(videoPath, FileMode.Create); _rec.Record(_outputStream); } else { _rec.Record(videoPath); } _secondsElapsed = 0; IsRecording = true; }
static void Main(string[] args) { Console.Title = "Console Screen Recorder"; bool restart = false; do { Console.Clear(); _stopWatch = new Stopwatch(); var inputDevices = Recorder.GetSystemAudioDevices(AudioDeviceSource.InputDevices); var opts = new RecorderOptions { VideoOptions = new VideoOptions { Framerate = 60, BitrateMode = BitrateControlMode.Quality, Quality = 100, }, AudioOptions = new AudioOptions { AudioInputDevice = inputDevices.First().Key, IsAudioEnabled = true, IsInputDeviceEnabled = true, IsOutputDeviceEnabled = true, } }; Recorder rec = Recorder.CreateRecorder(opts); rec.OnRecordingFailed += Rec_OnRecordingFailed; rec.OnRecordingComplete += Rec_OnRecordingComplete; rec.OnStatusChanged += Rec_OnStatusChanged; AskOutputDirectory(); rec.Record(_outputFolder + _outputFilename); ModifiedConsoleWrite(true, new string[] { "Press ", "[P]", " to pause\n", " ", "[R]", " to resume\n", " ", "[F]", " to finish" }, new ConsoleColor[] { ConsoleColor.Cyan, ConsoleColor.Cyan, ConsoleColor.Cyan }, new int[] { 1, 4, 7 }); CancellationTokenSource cts = new CancellationTokenSource(); var token = cts.Token; Task.Run(async() => { while (true) { if (token.IsCancellationRequested) { return; } if (_stopWatch.IsRunning) { Dispatcher.CurrentDispatcher.Invoke(() => { DisplayLength(ConsoleColor.Red); }); } await Task.Delay(10); } }, token); while (true) { ConsoleKeyInfo info = Console.ReadKey(true); switch (info.Key) { case ConsoleKey.F: cts.Cancel(); rec.Stop(); DisplayLength(ConsoleColor.Green); goto Stop; case ConsoleKey.P: if (rec.Status == RecorderStatus.Recording) { rec.Pause(); DisplayLength(ConsoleColor.Green); } break; case ConsoleKey.R: rec.Resume(); break; default: break; } } Stop :; while (true) { ConsoleKey consoleKey = Console.ReadKey(true).Key; if (consoleKey == ConsoleKey.O) { Process.Start("explorer", "/select,\"" + _outputFolder + _outputFilename + "\""); } if (consoleKey == ConsoleKey.Enter) { restart = true; break; } if (consoleKey == ConsoleKey.Escape) { restart = false; break; } } rec?.Dispose(); rec = null; } while (restart); }
RecorderOptions getRecordingOptions(String recType) { RecorderOptions options; if (recType == windowType) { options = new RecorderOptions { RecorderMode = RecorderMode.Video, //If throttling is disabled, out of memory exceptions may eventually crash the program, //depending on encoder settings and system specifications. IsThrottlingDisabled = false, //Hardware encoding is enabled by default. IsHardwareEncodingEnabled = true, //Low latency mode provides faster encoding, but can reduce quality. IsLowLatencyEnabled = false, //Fast start writes the mp4 header at the beginning of the file, to facilitate streaming. IsMp4FastStartEnabled = false, AudioOptions = new AudioOptions { Bitrate = AudioBitrate.bitrate_128kbps, Channels = AudioChannels.Stereo, IsAudioEnabled = true, //IsOutputDeviceEnabled = true, IsInputDeviceEnabled = true, //AudioOutputDevice = selectedOutputDevice, AudioInputDevice = inpDev, InputVolume = 1 }, VideoOptions = new VideoOptions { BitrateMode = BitrateControlMode.UnconstrainedVBR, Bitrate = 8000 * 1000, Framerate = 60, IsFixedFramerate = true, EncoderProfile = H264Profile.Main }, MouseOptions = new MouseOptions { //Displays a colored dot under the mouse cursor when the left mouse button is pressed. IsMouseClicksDetected = true, MouseClickDetectionColor = "#FFFF00", MouseRightClickDetectionColor = "#FFFF00", MouseClickDetectionRadius = 30, MouseClickDetectionDuration = 100, IsMousePointerEnabled = true, /* Polling checks every millisecond if a mouse button is pressed. * Hook works better with programmatically generated mouse clicks, but may affect * mouse performance and interferes with debugging.*/ MouseClickDetectionMode = MouseDetectionMode.Hook }, // Display Options for recording a portion of the screen DisplayOptions = new DisplayOptions { WindowHandle = window.Handle, MonitorDeviceName = monitorDeviceName }, RecorderApi = RecorderApi.WindowsGraphicsCapture }; } else if (recType == portionType) { options = new RecorderOptions { RecorderMode = RecorderMode.Video, //If throttling is disabled, out of memory exceptions may eventually crash the program, //depending on encoder settings and system specifications. IsThrottlingDisabled = false, //Hardware encoding is enabled by default. IsHardwareEncodingEnabled = true, //Low latency mode provides faster encoding, but can reduce quality. IsLowLatencyEnabled = false, //Fast start writes the mp4 header at the beginning of the file, to facilitate streaming. IsMp4FastStartEnabled = false, AudioOptions = new AudioOptions { Bitrate = AudioBitrate.bitrate_128kbps, Channels = AudioChannels.Stereo, IsAudioEnabled = true, //IsOutputDeviceEnabled = true, IsInputDeviceEnabled = true, //AudioOutputDevice = selectedOutputDevice, AudioInputDevice = inpDev, InputVolume = 1 }, VideoOptions = new VideoOptions { BitrateMode = BitrateControlMode.UnconstrainedVBR, Bitrate = 8000 * 1000, Framerate = 60, IsFixedFramerate = true, EncoderProfile = H264Profile.Main }, MouseOptions = new MouseOptions { //Displays a colored dot under the mouse cursor when the left mouse button is pressed. IsMouseClicksDetected = true, MouseClickDetectionColor = "#FFFF00", MouseRightClickDetectionColor = "#FFFF00", MouseClickDetectionRadius = 30, MouseClickDetectionDuration = 100, IsMousePointerEnabled = true, /* Polling checks every millisecond if a mouse button is pressed. * Hook works better with programmatically generated mouse clicks, but may affect * mouse performance and interferes with debugging.*/ MouseClickDetectionMode = MouseDetectionMode.Hook }, // Display Options for recording a portion of the screen DisplayOptions = new DisplayOptions { Left = left, Top = top, Right = right, Bottom = bottom, MonitorDeviceName = monitorDeviceName }, RecorderApi = RecorderApi.DesktopDuplication }; } else // This is default { // if (recType == fullScreenType) options = new RecorderOptions { RecorderMode = RecorderMode.Video, //If throttling is disabled, out of memory exceptions may eventually crash the program, //depending on encoder settings and system specifications. IsThrottlingDisabled = false, //Hardware encoding is enabled by default. IsHardwareEncodingEnabled = true, //Low latency mode provides faster encoding, but can reduce quality. IsLowLatencyEnabled = false, //Fast start writes the mp4 header at the beginning of the file, to facilitate streaming. IsMp4FastStartEnabled = false, AudioOptions = new AudioOptions { Bitrate = AudioBitrate.bitrate_128kbps, Channels = AudioChannels.Stereo, IsAudioEnabled = true, //IsOutputDeviceEnabled = true, IsInputDeviceEnabled = true, //AudioOutputDevice = selectedOutputDevice, AudioInputDevice = inpDev, InputVolume = 1 }, VideoOptions = new VideoOptions { BitrateMode = BitrateControlMode.UnconstrainedVBR, Bitrate = 8000 * 1000, Framerate = 60, IsFixedFramerate = true, EncoderProfile = H264Profile.Main }, MouseOptions = new MouseOptions { //Displays a colored dot under the mouse cursor when the left mouse button is pressed. IsMouseClicksDetected = true, MouseClickDetectionColor = "#FFFF00", MouseRightClickDetectionColor = "#FFFF00", MouseClickDetectionRadius = 30, MouseClickDetectionDuration = 100, IsMousePointerEnabled = true, /* Polling checks every millisecond if a mouse button is pressed. * Hook works better with programmatically generated mouse clicks, but may affect * mouse performance and interferes with debugging.*/ MouseClickDetectionMode = MouseDetectionMode.Hook }, DisplayOptions = new DisplayOptions { MonitorDeviceName = monitorDeviceName }, }; } return(options); }
public Form_EventFileReader(string Game_Name, string Game_Path) { this.Game_Path = Game_Path; InitializeComponent(); //load presets checkBox_ShowWarnings.Checked = Properties.Settings.Default.Show_warnings; checkBox_ShowErrors.Checked = Properties.Settings.Default.Show_errors; checkBox_ShowNotifications.Checked = Properties.Settings.Default.Show_notifications; checkBox_ShowDebug.Checked = Properties.Settings.Default.Show_debug_info; vibrationEvents = new VibrationEvents(Game_Path); memory_scanner = new Memory_Scanner(Game_Name); eventFileScanner = new EventFileScanner(Game_Path, memory_scanner, vibrationEvents); RecorderOptions options = new RecorderOptions { RecorderMode = RecorderMode.Video, RecorderApi = RecorderApi.WindowsGraphicsCapture, IsThrottlingDisabled = false, IsHardwareEncodingEnabled = true, IsLowLatencyEnabled = false, IsMp4FastStartEnabled = false, IsFragmentedMp4Enabled = false, IsLogEnabled = true, LogSeverityLevel = LogLevel.Debug, LogFilePath = @"C:\Users\jpriv\Desktop\Nieuwe map\", AudioOptions = new AudioOptions { IsAudioEnabled = false, }, VideoOptions = new VideoOptions { BitrateMode = BitrateControlMode.Quality, Bitrate = 7000 * 1000, Framerate = 60, Quality = 70, IsFixedFramerate = true, EncoderProfile = H264Profile.Main } }; _rec1 = Recorder.CreateRecorder(options); _rec2 = Recorder.CreateRecorder(options); m_GlobalHook = Hook.GlobalEvents(); m_GlobalHook.OnCombination(new Dictionary <Combination, Action> { { Combination.TriggeredBy(Keys.PageUp), WaitForRecording }, }); m_GlobalHook.OnCombination(new Dictionary <Combination, Action> { { Combination.TriggeredBy(Keys.Home), WaitForContinuesRecording }, }); m_GlobalHook.OnCombination(new Dictionary <Combination, Action> { { Combination.TriggeredBy(Keys.End), StopRecording }, }); }
private static void Watcher(string filePath) { // Borrowed from the great coder(s) at https://github.com/sskodje/ScreenRecorderLib/blob/master/TestConsoleApp/Program.cs RecorderOptions options = new RecorderOptions { RecorderMode = RecorderMode.Video, //If throttling is disabled, out of memory exceptions may eventually crash the program, //depending on encoder settings and system specifications. IsThrottlingDisabled = false, //Hardware encoding is enabled by default. IsHardwareEncodingEnabled = true, //Low latency mode provides faster encoding, but can reduce quality. IsLowLatencyEnabled = true, //Fast start writes the mp4 header at the beginning of the file, to facilitate streaming. IsMp4FastStartEnabled = false, VideoOptions = new VideoOptions { BitrateMode = BitrateControlMode.UnconstrainedVBR, Bitrate = 8000 * 1000, Framerate = 24, IsFixedFramerate = false, EncoderProfile = H264Profile.Main }, }; rec = Recorder.CreateRecorder(options); rec.OnRecordingFailed += Rec_OnRecordingFailed; rec.OnRecordingComplete += Rec_OnRecordingComplete; rec.OnStatusChanged += Rec_OnStatusChanged; System.Timers.Timer aTimer = new System.Timers.Timer(); aTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent); aTimer.Interval = timeToRecord * 1000; aTimer.Start(); rec.Record(filePath); CancellationTokenSource cts = new CancellationTokenSource(); var token = cts.Token; Task.Run(async() => { while (true) { if (token.IsCancellationRequested) { return; } if (_isRecording) { Dispatcher.CurrentDispatcher.Invoke(() => { //Console.Write(String.Format("\rElapsed: {0}s:{1}ms", _stopWatch.Elapsed.Seconds, _stopWatch.Elapsed.Milliseconds)); }); } await Task.Delay(10); } }, token); while (true) { if (exitFlag == true) { break; } } cts.Cancel(); rec.Stop(); while (!isDone) { Thread.Sleep(1000); } //Console.ReadKey(); }
private void Record(string path) { if (Settings.AudioBitrate == 96) { A_bitrate = AudioBitrate.bitrate_96kbps; } else if (Settings.AudioBitrate == 128) { A_bitrate = AudioBitrate.bitrate_128kbps; } else if (Settings.AudioBitrate == 160) { A_bitrate = AudioBitrate.bitrate_160kbps; } else { A_bitrate = AudioBitrate.bitrate_192kbps; } if (Settings.AudioChannels == "5.1") { A_Channels = AudioChannels.FivePointOne; } else if (Settings.AudioChannels == "Mono") { A_Channels = AudioChannels.Mono; } else { A_Channels = AudioChannels.Stereo; } UpdateLogFile("Creating recording options."); RecorderOptions options = new RecorderOptions { RecorderMode = RecorderMode.Video, //If throttling is disabled, out of memory exceptions may eventually crash the program, //depending on encoder settings and system specifications. IsThrottlingDisabled = false, //Hardware encoding is enabled by default. IsHardwareEncodingEnabled = Settings.HardwareEncoding, //Low latency mode provides faster encoding, but can reduce quality. IsLowLatencyEnabled = Settings.LowLatency, //Fast start writes the mp4 header at the beginning of the file, to facilitate streaming. IsMp4FastStartEnabled = false, AudioOptions = new AudioOptions { Bitrate = A_bitrate, Channels = A_Channels, IsAudioEnabled = Settings.EnableAudio }, VideoOptions = new VideoOptions { BitrateMode = BitrateControlMode.UnconstrainedVBR, Bitrate = Settings.VideoBitrate * 1000000, Framerate = Settings.FrameRate, IsMousePointerEnabled = Settings.RecordMouse, IsFixedFramerate = true, EncoderProfile = H264Profile.Main } }; UpdateLogFile("Creating Recorder object."); Rec = Recorder.CreateRecorder(options); Rec.OnRecordingFailed += Rec_OnRecordingFailed; Rec.OnStatusChanged += Rec_OnStatusChanged; UpdateLogFile("Recording started."); Rec.Record(path); }