/// <summary> /// What is being recorded /// </summary> /// <returns>CaptureContent of the area being recorded</returns> public CaptureContent GetCapturedContent() { if (_capturedContent == CaptureContent.Invalid) { string setting = GlobalConfig.Settings.Media.VideoCodec_Content.ToUpper(); if (setting.Contains("PREVIEW")) { _capturedContent = CaptureContent.GraphAndPreviews; } else if (setting.Contains("GRAPH")) { _capturedContent = CaptureContent.Graph; } else { _capturedContent = CaptureContent.Window; } } return(_capturedContent); }
/// <summary> /// A task for recording a video /// </summary> /// <param name="graph">Optional graph to record</param> async public void Go(PlottedGraph?graph) { if (!File.Exists(GlobalConfig.GetSettingPath(CONSTANTS.PathKey.FFmpegPath))) { StopRecording(processQueue: false, error: $"Unable to start recording: Path to ffmpeg.exe not configured"); Loaded = false; Initialised = false; return; } try { string?dirname = Path.GetDirectoryName(GlobalConfig.GetSettingPath(CONSTANTS.PathKey.FFmpegPath)); if (dirname is not null) { GlobalFFOptions.Configure(new FFOptions { BinaryFolder = dirname }); } else { StopRecording(processQueue: false, error: $"Unable to start recording: FFMpeg not found"); Loaded = false; return; } } catch (Exception e) { StopRecording(processQueue: false, error: $"Unable to start recording: Exception '{e.Message}' configuring recorder"); Loaded = false; return; } Initialised = true; CurrentRecordingFile = GenerateVideoFilepath(graph); _recordedFrameCount = 0; Logging.RecordLogEvent("Recording video to " + CurrentRecordingFile); var videoFramesSource = new RawVideoPipeSource(GetNextFrame()); try { //https://trac.ffmpeg.org/wiki/Encode/H.264 await FFMpegArguments .FromPipeInput(videoFramesSource) .OutputToFile(CurrentRecordingFile, false, opt => opt .WithFramerate(GlobalConfig.Settings.Media.VideoCodec_FPS) .WithConstantRateFactor(28 - GlobalConfig.Settings.Media.VideoCodec_Quality) .WithSpeedPreset(GetVideoSpeed()) .WithVideoCodec(VideoCodec.LibX264) ) .ProcessAsynchronously(); } catch (Exception e) { Logging.RecordException("FFMpeg Record Error: " + e.Message, e); } Initialised = false; StopRecording(); CapturePaused = false; _bmpQueue.Clear(); Logging.RecordLogEvent($"Recorded {_recordedFrameCount} x {CurrentVideoWidth}*{CurrentVideoHeight} frames of video to " + CurrentRecordingFile); CurrentRecordingFile = ""; _capturedContent = CaptureContent.Invalid; }