private void EndCall() { VoiceRecorder.StopRecording(); ScreenRecorder.StopRecord(); Application.Current.Dispatcher.Invoke(delegate { FriendsInCall.Clear(); InCall = false; }); Client.SendToServer(new ServerObject(ServerFlag.ExitFromGroup, Client.Id)); }
private async void Recorder_CaptureFinished(ScreenRecorder obj) { try { await recorder.SaveAsync("test", TimeSpan.FromSeconds(5)); } catch (Exception) { } recorder.Dispose(); recorder = null; }
private void Awake() { button = GetComponent <Button>(); initializeClickEvent(); camera = GameObject.FindWithTag("MainCamera"); recorder = camera.GetComponent <ScreenRecorder>(); recordButton.onClick.AddListener(Record); framerateDropDown.onValueChanged.AddListener(UpdateFramerate); recordTimeInput.text = recordTime.ToString(); recordTimeInput.onEndEdit.AddListener(UpdateRecordTime); }
public void SavesRecordingToWmvFile() { var saveFolder = Path.GetTempPath(); var screenRecord = new ScreenRecorder(saveFolder, FileName); screenRecord.StartRecording(); System.Threading.Thread.Sleep(200); var recording = screenRecord.StopRecording(); Assert.IsTrue(File.Exists(recording)); Assert.IsTrue(new FileInfo(recording).Length > 0); Assert.IsTrue(recording.Contains("scr_") && recording.EndsWith("wmv")); File.Delete(recording); }
// // Main procedure // static void Main(string[] args) { Console.CancelKeyPress += (sender, a) => { _exitingEvent.Set(); a.Cancel = true; }; SetConsoleCtrlHandler(ConsoleCtrlHandler, true); ScreenRecorder recorder = new ScreenRecorder(); recorder.Start(); ScreenCaptureController.Recorder = recorder; // this is the web application stack WebApp.Start(ApplicationUrl, (builder) => { var config = new HttpConfiguration(); config.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{lastKnownFrame}", defaults: new { lastKnownFrame = RouteParameter.Optional } ); builder.UseWebApi(config); builder.MapSignalR(); builder.UseFileServer(new FileServerOptions() { EnableDirectoryBrowsing = false, RequestPath = new Microsoft.Owin.PathString(@"/js"), FileSystem = new PhysicalFileSystem(StaticScriptsPath) }); builder.UseFileServer(new FileServerOptions() { EnableDirectoryBrowsing = true, FileSystem = new PhysicalFileSystem(StaticFilesPath) }); }); // wait for the user to exit the application Console.Write("Press CTRL + C to exit"); _exitingEvent.WaitOne(); _exitEvent.Set(); }
private async void StartButton_Click(object sender, RoutedEventArgs e) { var hwnd = new IntPtr(0x00000000000404F8); //var hwnd = new IntPtr(0x0000000000DE0FF6); try { recorder = ScreenRecorder.Create(hwnd); recorder.CaptureFinished += Recorder_CaptureFinished; await recorder.StartAsync(); } catch (Exception) { recorder?.Dispose(); recorder = null; } }
public void Start_CapturesVideoUntilStopped() { var grabber = new ScreenGrabber(new CaptureParameters() { Zoom = 0.25 }); var video = new FlashScreenVideo(new FlashScreenVideoParameters(grabber.ScreenshotWidth, grabber.ScreenshotHeight, 5)); using (var recorder = new ScreenRecorder(grabber, video)) { recorder.Start(); Thread.Sleep(2000); recorder.Stop(); TestLog.EmbedVideo("Video", recorder.Video); } }
public CallWindowVM(Image imagePreview) { ImagePreview = imagePreview; VoiceRecorder = new VoiceRecorder(); ScreenRecorder = new ScreenRecorder(); FriendsInCall = new ObservableCollection <Call>(); Client.NewUserCall += NewUserCall; Client.CallDeclined += CallDeclined; Client.CallingToGroup += CallingToGroup; Client.NewVoice += NewVoice; Client.NewFrame += NewFrame; Client.UserLeftRoom += UserLeftRoom; Client.EndCall += EndCall; }
public void BeforeTest() { // ChromeDriverService service = ChromeDriverService.CreateDefaultService("webdriver.chrome.driver", @"D:\\Automation\\WebDrivers\\chromedriver.exe"); _driver = new ChromeDriver(); _driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(120); _driver.Manage().Window.Maximize(); _test = _extent.CreateTest(TestContext.CurrentContext.Test.Name); _wait = new WebDriverWait(_driver, TimeSpan.FromMinutes(5)); _sr = new ScreenRecorder(); var recordVideo = bool.Parse(System.Configuration.ConfigurationManager.AppSettings["RecordVideo"]); if (recordVideo) { _sr.SetVideoOutputLocation(); _sr.StartRecording(); } }
// Use this for initialization void Start() { string configPath = Path.Combine(Application.streamingAssetsPath, configName); EasyRoadsGenerator generator = GetComponent <EasyRoadsGenerator>(); using (StreamReader r = new StreamReader(configPath)) { string json = r.ReadToEnd(); Debug.Log("Config loaded: " + json); this.Config = JsonUtility.FromJson <RoadConfig>(json); // Die Anzahl der Lanes setzen generator.numberOfTracks = this.Config.NumberOfTracks; generator.SetUpRoadType(); foreach (RoadPartConfig roadPartConfig in Config.RoadItems) { switch (roadPartConfig.Type) { case RoadPartType.Straight: generator.CreateStraight(roadPartConfig.Length, roadPartConfig.MinCars, roadPartConfig.MaxCars, roadPartConfig.HeightDifference, roadPartConfig.Seed); break; case RoadPartType.Curve: generator.CreateCurve(roadPartConfig.Angle, roadPartConfig.Length, roadPartConfig.HeightDifference, roadPartConfig.MinCars, roadPartConfig.MaxCars, roadPartConfig.Seed); break; default: throw new Exception("Undefined Road Type '" + roadPartConfig.Type + "'"); } } } generator.isSelfDriving = Config.IsSelfDriving; generator.carSpeed = Config.CarSpeed; generator.isGenerated = true; ScreenRecorder screenRecorder = Camera.main.GetComponent <ScreenRecorder>(); screenRecorder.ObjectsToHide = GameObject.FindGameObjectsWithTag("ObjectToHide"); }
private ScreenRecorder StartSceenRecorder(ITestElement testElement, IRunContext runContext) { string screenCapture; if (!TryGetProperty(testElement, _runContext, VSTestProperties.ScreenCapture.Key, out screenCapture) || string.IsNullOrEmpty(screenCapture)) { return(null); } try { if (!Path.IsPathRooted(screenCapture)) { screenCapture = Path.Combine( _runContext.RunConfig.TestRun.RunConfiguration.RunDeploymentOutDirectory, screenCapture ); } } catch (ArgumentException) { return(null); } screenCapture = screenCapture.Replace("$id$", testElement.HumanReadableId); screenCapture = screenCapture.Replace("$date$", DateTime.Today.ToShortDateString()); var screenRecorder = new ScreenRecorder(screenCapture); string intervalString; int interval; if (TryGetProperty(testElement, runContext, VSTestProperties.ScreenCapture.IntervalKey, out intervalString) && int.TryParse(intervalString, out interval)) { screenRecorder.Interval = TimeSpan.FromMilliseconds(interval); } else { screenRecorder.Interval = TimeSpan.FromSeconds(1); } return(screenRecorder); }
// Use this for initialization void Start() { //GameObject.Find ("debug").GetComponent<TextMesh>().text = "HI"; plane = GameObject.FindWithTag("CameraView"); //mCamera = new WebCamTexture (); //plane.GetComponent<Renderer>().material.mainTexture = mCamera; //mCamera.Play (); Settings.checkPath(); this.width = 800; this.height = 600; //image = new Texture2D(width, height); //System.IntPtr texturePtr = mCamera.GetNativeTextureID (); mScreenRecorder = new ScreenRecorder(); //mScreenRecorder.setGLTextureID (texturePtr); mScreenRecorder.setScreenSize(width, height); textureID = mScreenRecorder.getTextureID(); image = Texture2D.CreateExternalTexture(width, height, TextureFormat.BGRA32, false, true, (System.IntPtr)textureID); plane.GetComponent <Renderer>().material.mainTexture = image; }
// ********************************************************************** // void Awake() { particleLauncher = gameObject.GetComponent(typeof(ParticleLauncher)) as ParticleLauncher; tintColor = new Color(); meanColor = new Color(); savingTimer = new Timer(); recorder = camera.GetComponent <ScreenRecorder>(); shapeSampleStats = new ShapeSamplingStatistics(); particleSampleStats = new ParticleSamplingStatistics(); colourSampleStats = new ColourSamplingStatistics(); // Our sampling settings datasetForm = "heirarchy"; // "flat", "singlefeature", "heirarchy" numPlanets = 8 * 1; // how many planets to generate in this simulation featureorder = new int[] { 0, 1, 2, 3, 4, 5, 6 }; //featureorder = RandomPermutation(featureorder); // the random ordering of features in the hierarchy // Read in the existing record of planet details recordFilePath = filePath + "stimulusLookup.json"; if (File.Exists(recordFilePath)) { { Debug.Log("Opening record of generated planets."); LoadExistingPlanets(recordFilePath); } } else { allExistingPlanets.allPlanetData = new List <PlanetData>(); allExistingPlanets.planetColours = new Color[allExistingPlanets.nLevels]; } }
public bool Stop() { _logger.Info("Stop() stopping"); _logger.Info("Stop() StopRecording()"); ScreenRecorder.StopRecording(); _logger.Info("Stop() recording stopped > saving"); string outFilename = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\video-" + DateTime.Now.ToLongTimeString().Replace(":", "-") + ".gif"; ScreenRecorder.Save(outFilename); _logger.Info("Stop() recording saved"); _logger.Info("Stop() ClearRecording()"); ScreenRecorder.ClearRecording(); _logger.Info("Stop() recording cleared"); _enabled = false; _logger.Info("Stop() stopped"); return(true); }
private async void MakeGif() { //MP4 -> GIF bool success = _recorder.FFmpegEncodeAsGif(_outputGif); using (FileStream fstream = new FileStream(_outputGif, FileMode.Open, FileAccess.Read)) { Gif = new MemoryStream(); await fstream.CopyToAsync(Gif); } _recorder.Dispose(); _recorder = null; if (!success || !File.Exists(_outputGif) || (_recorder != null && _recorder.IsRecording)) { ErrorMsg = strings.couldNotCreateGif; FadeOut(false); } else { FadeOut(true); } }
public void StartRecording_WithCaptureParametersIncludingZoomFactor_CapturesZoomedVideo(string caption) { Size screenSize = Capture.GetScreenSize(); if (Capture.CanCaptureScreenshot()) { if (caption != null) { Capture.SetCaption(caption); } using (ScreenRecorder recorder = Capture.StartRecording(new CaptureParameters() { Zoom = 0.25 }, 5)) { Thread.Sleep(2000); recorder.Stop(); TestLog.EmbedVideo("Video", recorder.Video); Assert.Multiple(() => { Assert.AreApproximatelyEqual(screenSize.Width / 2, recorder.Video.Parameters.Width, 1); Assert.AreApproximatelyEqual(screenSize.Height / 2, recorder.Video.Parameters.Height, 1); }); } } else { Assert.Throws <ScreenshotNotAvailableException>(() => Capture.StartRecording(new CaptureParameters() { Zoom = 0.25 }, 5), "CanCaptureScreenshot returned false so expected an exception to be thrown."); } }
//IDisposable public void Dispose() { Gif = null; try { if (File.Exists(_outputGif)) { File.Delete(_outputGif); } if (File.Exists(_outputMp4)) { File.Delete(_outputMp4); } } catch { // could not delete } try { if (_recorder != null && _recorder.IsRecording) { _recorder.StopRecording(); } } catch { // unexpected error on stop recording } _recorder?.Dispose(); _recorder = null; try { Dispatcher.Invoke(Close); } catch { //Window already closed } }
/// <summary> /// Starts recording a screen capture video of the entire desktop. /// </summary> /// <remarks> /// <para> /// Recording a screen capture video can be very CPU and space intensive particularly /// when running tests on a single-core CPU. We recommend calling /// <see cref="StartRecording(CaptureParameters, double)" /> with /// a <see cref="CaptureParameters.Zoom" /> factor of 0.25 or less and a frame rate /// of no more than 5 to 10 frames per second. /// </para> /// </remarks> /// <param name="parameters">The capture parameters.</param> /// <param name="framesPerSecond">The number of frames per second to capture.</param> /// <returns>The recorder.</returns> /// <exception cref="ArgumentNullException">Thrown if <paramref name="parameters"/> is null.</exception> /// <exception cref="ScreenshotNotAvailableException">Thrown if a screenshot cannot be captured at this time.</exception> public static ScreenRecorder StartRecording(CaptureParameters parameters, double framesPerSecond) { if (parameters == null) { throw new ArgumentNullException("parameters"); } ScreenGrabber.ThrowIfScreenshotNotAvailable(); ScreenGrabber grabber = new ScreenGrabber(parameters); try { FlashScreenVideo video = new FlashScreenVideo(new FlashScreenVideoParameters( grabber.ScreenshotWidth, grabber.ScreenshotHeight, framesPerSecond)); ScreenRecorder recorder = new ScreenRecorder(grabber, video); try { recorder.OverlayManager.AddOverlay(GetOverlayManager().ToOverlay()); recorder.Start(); return(recorder); } catch { recorder.Dispose(); throw; } } catch { grabber.Dispose(); throw; } }
public void StartRecording(TaskSettings taskSettings) { if (taskSettings.CaptureSettings.RunScreencastCLI) { if (!Program.Settings.VideoEncoders.IsValidIndex(taskSettings.CaptureSettings.VideoEncoderSelected)) { MessageBox.Show(Resources.ScreenRecordForm_StartRecording_There_is_no_valid_CLI_video_encoder_selected_, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (!Program.Settings.VideoEncoders[taskSettings.CaptureSettings.VideoEncoderSelected].IsValid()) { MessageBox.Show(Resources.ScreenRecordForm_StartRecording_CLI_video_encoder_file_does_not_exist__ + Program.Settings.VideoEncoders[taskSettings.CaptureSettings.VideoEncoderSelected].Path, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } if (taskSettings.CaptureSettings.ScreenRecordOutput == ScreenRecordOutput.FFmpeg) { if (!File.Exists(taskSettings.CaptureSettings.FFmpegOptions.CLIPath)) { string ffmpegText = string.IsNullOrEmpty(taskSettings.CaptureSettings.FFmpegOptions.CLIPath) ? "ffmpeg.exe" : taskSettings.CaptureSettings.FFmpegOptions.CLIPath; if (MessageBox.Show(string.Format(Resources.ScreenRecordForm_StartRecording_does_not_exist, ffmpegText), "ShareX - " + Resources.ScreenRecordForm_StartRecording_Missing + " ffmpeg.exe", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { if (FFmpegHelper.DownloadFFmpeg(false, DownloaderForm_InstallRequested) == DialogResult.OK) { Program.DefaultTaskSettings.CaptureSettings.FFmpegOptions.CLIPath = taskSettings.TaskSettingsReference.CaptureSettings.FFmpegOptions.CLIPath = taskSettings.CaptureSettings.FFmpegOptions.CLIPath = Path.Combine(Program.ToolsFolder, "ffmpeg.exe"); } } else { return; } } if (!taskSettings.CaptureSettings.FFmpegOptions.IsSourceSelected) { MessageBox.Show(Resources.ScreenRecordForm_StartRecording_FFmpeg_video_and_audio_source_both_can_t_be__None__, "ShareX - " + Resources.ScreenRecordForm_StartRecording_FFmpeg_error, MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } Rectangle captureRectangle; TaskHelpers.SelectRegion(out captureRectangle); captureRectangle = CaptureHelpers.EvenRectangleSize(captureRectangle); if (IsRecording || !captureRectangle.IsValid() || screenRecorder != null) { return; } IsRecording = true; Screenshot.CaptureCursor = taskSettings.CaptureSettings.ShowCursor; TrayIcon.Text = "ShareX - " + Resources.ScreenRecordForm_StartRecording_Waiting___; TrayIcon.Icon = Resources.control_record_yellow.ToIcon(); TrayIcon.Visible = true; string path = ""; float duration = taskSettings.CaptureSettings.ScreenRecordFixedDuration ? taskSettings.CaptureSettings.ScreenRecordDuration : 0; regionForm = ScreenRegionForm.Show(captureRectangle, StopRecording, duration); TaskEx.Run(() => { try { if (taskSettings.CaptureSettings.ScreenRecordAutoDisableAero) { dwmManager = new DWMManager(); dwmManager.AutoDisable(); } if (taskSettings.CaptureSettings.ScreenRecordOutput == ScreenRecordOutput.AVI) { path = Path.Combine(taskSettings.CaptureFolder, TaskHelpers.GetFilename(taskSettings, "avi")); } else if (taskSettings.CaptureSettings.ScreenRecordOutput == ScreenRecordOutput.FFmpeg) { path = Path.Combine(taskSettings.CaptureFolder, TaskHelpers.GetFilename(taskSettings, taskSettings.CaptureSettings.FFmpegOptions.Extension)); } else { path = Program.ScreenRecorderCacheFilePath; } ScreencastOptions options = new ScreencastOptions() { FFmpeg = taskSettings.CaptureSettings.FFmpegOptions, AVI = taskSettings.CaptureSettings.AVIOptions, ScreenRecordFPS = taskSettings.CaptureSettings.ScreenRecordFPS, GIFFPS = taskSettings.CaptureSettings.GIFFPS, Duration = duration, OutputPath = path, CaptureArea = captureRectangle, DrawCursor = taskSettings.CaptureSettings.ShowCursor }; screenRecorder = new ScreenRecorder(options, captureRectangle, taskSettings.CaptureSettings.ScreenRecordOutput); int delay = (int)(taskSettings.CaptureSettings.ScreenRecordStartDelay * 1000); if (delay > 0) { Thread.Sleep(delay); } TrayIcon.Text = "ShareX - " + Resources.ScreenRecordForm_StartRecording_Click_tray_icon_to_stop_recording_; TrayIcon.Icon = Resources.control_record.ToIcon(); if (regionForm != null) { this.InvokeSafe(() => regionForm.StartTimer()); } screenRecorder.StartRecording(); } finally { if (dwmManager != null) { dwmManager.Dispose(); dwmManager = null; } if (regionForm != null) { this.InvokeSafe(() => regionForm.Close()); } } try { if (screenRecorder != null) { TrayIcon.Text = "ShareX - " + Resources.ScreenRecordForm_StartRecording_Encoding___; TrayIcon.Icon = Resources.camcorder_pencil.ToIcon(); string sourceFilePath = path; if (taskSettings.CaptureSettings.ScreenRecordOutput == ScreenRecordOutput.GIF) { if (taskSettings.CaptureSettings.RunScreencastCLI) { sourceFilePath = Path.ChangeExtension(Program.ScreenRecorderCacheFilePath, "gif"); } else { sourceFilePath = path = Path.Combine(taskSettings.CaptureFolder, TaskHelpers.GetFilename(taskSettings, "gif")); } screenRecorder.SaveAsGIF(sourceFilePath, taskSettings.ImageSettings.ImageGIFQuality); } if (taskSettings.CaptureSettings.RunScreencastCLI) { VideoEncoder encoder = Program.Settings.VideoEncoders[taskSettings.CaptureSettings.VideoEncoderSelected]; path = Path.Combine(taskSettings.CaptureFolder, TaskHelpers.GetFilename(taskSettings, encoder.OutputExtension)); screenRecorder.EncodeUsingCommandLine(encoder, sourceFilePath, path); } } } finally { if (screenRecorder != null) { if (taskSettings.CaptureSettings.RunScreencastCLI && !string.IsNullOrEmpty(screenRecorder.CachePath) && File.Exists(screenRecorder.CachePath)) { File.Delete(screenRecorder.CachePath); } screenRecorder.Dispose(); screenRecorder = null; } } }, () => { if (TrayIcon.Visible) { TrayIcon.Visible = false; } IsRecording = false; if (!string.IsNullOrEmpty(path) && File.Exists(path) && TaskHelpers.ShowAfterCaptureForm(taskSettings)) { UploadTask task = UploadTask.CreateFileJobTask(path, taskSettings); TaskManager.Start(task); } }); }
private static void StartRecording(ScreenRecordOutput outputType, TaskSettings taskSettings, ScreenRecordStartMethod startMethod = ScreenRecordStartMethod.Region) { if (outputType == ScreenRecordOutput.GIF) { taskSettings.CaptureSettings.FFmpegOptions.VideoCodec = FFmpegVideoCodec.gif; } if (taskSettings.CaptureSettings.FFmpegOptions.IsAnimatedImage) { taskSettings.CaptureSettings.ScreenRecordTwoPassEncoding = true; } int fps; if (taskSettings.CaptureSettings.FFmpegOptions.VideoCodec == FFmpegVideoCodec.gif) { fps = taskSettings.CaptureSettings.GIFFPS; } else { fps = taskSettings.CaptureSettings.ScreenRecordFPS; } DebugHelper.WriteLine("Starting screen recording. Video encoder: \"{0}\", Audio encoder: \"{1}\", FPS: {2}", taskSettings.CaptureSettings.FFmpegOptions.VideoCodec.GetDescription(), taskSettings.CaptureSettings.FFmpegOptions.AudioCodec.GetDescription(), fps); if (!TaskHelpers.CheckFFmpeg(taskSettings)) { return; } if (!taskSettings.CaptureSettings.FFmpegOptions.IsSourceSelected) { MessageBox.Show(Resources.ScreenRecordForm_StartRecording_FFmpeg_video_and_audio_source_both_can_t_be__None__, "ShareX - " + Resources.ScreenRecordForm_StartRecording_FFmpeg_error, MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } Rectangle captureRectangle = Rectangle.Empty; switch (startMethod) { case ScreenRecordStartMethod.Region: RegionCaptureTasks.GetRectangleRegion(out captureRectangle, taskSettings.CaptureSettings.SurfaceOptions); break; case ScreenRecordStartMethod.ActiveWindow: if (taskSettings.CaptureSettings.CaptureClientArea) { captureRectangle = CaptureHelpers.GetActiveWindowClientRectangle(); } else { captureRectangle = CaptureHelpers.GetActiveWindowRectangle(); } break; case ScreenRecordStartMethod.CustomRegion: captureRectangle = taskSettings.CaptureSettings.CaptureCustomRegion; break; case ScreenRecordStartMethod.LastRegion: captureRectangle = Program.Settings.ScreenRecordRegion; break; } Rectangle screenRectangle = CaptureHelpers.GetScreenBounds(); captureRectangle = Rectangle.Intersect(captureRectangle, screenRectangle); if (taskSettings.CaptureSettings.FFmpegOptions.IsEvenSizeRequired) { captureRectangle = CaptureHelpers.EvenRectangleSize(captureRectangle); } if (IsRecording || !captureRectangle.IsValid() || screenRecorder != null) { return; } Program.Settings.ScreenRecordRegion = captureRectangle; IsRecording = true; string path = ""; bool abortRequested = false; float duration = taskSettings.CaptureSettings.ScreenRecordFixedDuration ? taskSettings.CaptureSettings.ScreenRecordDuration : 0; recordForm = new ScreenRecordForm(captureRectangle, taskSettings, startMethod == ScreenRecordStartMethod.Region, duration); recordForm.StopRequested += StopRecording; recordForm.Show(); Task.Run(() => { try { string extension; if (taskSettings.CaptureSettings.ScreenRecordTwoPassEncoding) { extension = "mp4"; } else { extension = taskSettings.CaptureSettings.FFmpegOptions.Extension; } string filename = TaskHelpers.GetFilename(taskSettings, extension); path = TaskHelpers.HandleExistsFile(taskSettings.CaptureFolder, filename, taskSettings); if (string.IsNullOrEmpty(path)) { abortRequested = true; } if (!abortRequested) { recordForm.ChangeState(ScreenRecordState.BeforeStart); if (taskSettings.CaptureSettings.ScreenRecordAutoStart) { int delay = (int)(taskSettings.CaptureSettings.ScreenRecordStartDelay * 1000); if (delay > 0) { recordForm.InvokeSafe(() => recordForm.StartCountdown(delay)); recordForm.RecordResetEvent.WaitOne(delay); } } else { recordForm.RecordResetEvent.WaitOne(); } if (recordForm.IsAbortRequested) { abortRequested = true; } if (!abortRequested) { ScreencastOptions options = new ScreencastOptions() { IsRecording = true, IsLossless = taskSettings.CaptureSettings.ScreenRecordTwoPassEncoding, FFmpeg = taskSettings.CaptureSettings.FFmpegOptions, FPS = fps, Duration = duration, OutputPath = path, CaptureArea = captureRectangle, DrawCursor = taskSettings.CaptureSettings.ScreenRecordShowCursor }; Screenshot screenshot = TaskHelpers.GetScreenshot(taskSettings); screenshot.CaptureCursor = taskSettings.CaptureSettings.ScreenRecordShowCursor; screenRecorder = new ScreenRecorder(ScreenRecordOutput.FFmpeg, options, screenshot, captureRectangle); screenRecorder.RecordingStarted += () => recordForm.ChangeState(ScreenRecordState.AfterRecordingStart); recordForm.ChangeState(ScreenRecordState.AfterStart); screenRecorder.StartRecording(); if (recordForm.IsAbortRequested) { abortRequested = true; } } } } catch (Exception e) { DebugHelper.WriteException(e); } if (taskSettings.CaptureSettings.ScreenRecordTwoPassEncoding && !abortRequested && screenRecorder != null && File.Exists(path)) { recordForm.ChangeState(ScreenRecordState.Encoding); path = ProcessTwoPassEncoding(path, taskSettings); } if (recordForm != null) { recordForm.InvokeSafe(() => { recordForm.Close(); recordForm.Dispose(); recordForm = null; }); } if (screenRecorder != null) { screenRecorder.Dispose(); screenRecorder = null; if (abortRequested && !string.IsNullOrEmpty(path) && File.Exists(path)) { File.Delete(path); } } }).ContinueInCurrentContext(() => { string customFileName; if (!abortRequested && !string.IsNullOrEmpty(path) && File.Exists(path) && TaskHelpers.ShowAfterCaptureForm(taskSettings, out customFileName, null, path)) { if (!string.IsNullOrEmpty(customFileName)) { string currentFilename = Path.GetFileNameWithoutExtension(path); string ext = Path.GetExtension(path); if (!currentFilename.Equals(customFileName, StringComparison.InvariantCultureIgnoreCase)) { path = Helpers.RenameFile(path, customFileName + ext); } } WorkerTask task = WorkerTask.CreateFileJobTask(path, taskSettings, customFileName); TaskManager.Start(task); } abortRequested = false; IsRecording = false; }); }
public void StartRecording(TaskSettings taskSettings) { if (taskSettings.CaptureSettings.RunScreencastCLI) { if (!Program.Settings.VideoEncoders.IsValidIndex(taskSettings.CaptureSettings.VideoEncoderSelected)) { MessageBox.Show("There is no valid CLI video encoder selected.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } else if (!Program.Settings.VideoEncoders[taskSettings.CaptureSettings.VideoEncoderSelected].IsValid()) { MessageBox.Show("CLI video encoder file does not exist: " + Program.Settings.VideoEncoders[taskSettings.CaptureSettings.VideoEncoderSelected].Path, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } if (taskSettings.CaptureSettings.ScreenRecordOutput == ScreenRecordOutput.FFmpeg && !File.Exists(taskSettings.CaptureSettings.FFmpegOptions.CLIPath)) { string ffmpegText = string.IsNullOrEmpty(taskSettings.CaptureSettings.FFmpegOptions.CLIPath) ? "ffmpeg.exe" : taskSettings.CaptureSettings.FFmpegOptions.CLIPath; if (MessageBox.Show(ffmpegText + " does not exist." + Environment.NewLine + Environment.NewLine + "Would you like to automatically download it?", Application.ProductName + " - Missing ffmpeg.exe", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { if (FFmpegHelper.DownloadFFmpeg(false, DownloaderForm_InstallRequested) == DialogResult.OK) { Program.DefaultTaskSettings.CaptureSettings.FFmpegOptions.CLIPath = taskSettings.TaskSettingsReference.CaptureSettings.FFmpegOptions.CLIPath = taskSettings.CaptureSettings.FFmpegOptions.CLIPath = Path.Combine(Program.ToolsFolder, "ffmpeg.exe"); } } else { return; } } if (taskSettings.AdvancedSettings.ScreenRecorderUseActiveWindow) { ActiveWindowRegion(taskSettings); } else { SelectRegion(); } captureRectangle = CaptureHelpers.EvenRectangleSize(captureRectangle); if (IsRecording || !captureRectangle.IsValid() || screenRecorder != null) { return; } IsRecording = true; Screenshot.CaptureCursor = taskSettings.CaptureSettings.ShowCursor; TrayIcon.Text = "ShareX - Waiting..."; TrayIcon.Icon = Resources.control_record_yellow.ToIcon(); TrayIcon.Visible = true; string path = ""; float duration = taskSettings.CaptureSettings.ScreenRecordFixedDuration ? taskSettings.CaptureSettings.ScreenRecordDuration : 0; regionForm = ScreenRegionForm.Show(captureRectangle, StopRecording, duration); TaskEx.Run(() => { try { if (taskSettings.CaptureSettings.ScreenRecordAutoDisableAero) { dwmManager = new DWMManager(); dwmManager.AutoDisable(); } if (taskSettings.CaptureSettings.ScreenRecordOutput == ScreenRecordOutput.AVI) { path = Path.Combine(taskSettings.CaptureFolder, TaskHelpers.GetFilename(taskSettings, "avi")); } else if (taskSettings.CaptureSettings.ScreenRecordOutput == ScreenRecordOutput.FFmpeg) { path = Path.Combine(taskSettings.CaptureFolder, TaskHelpers.GetFilename(taskSettings, taskSettings.CaptureSettings.FFmpegOptions.Extension)); } else { path = Program.ScreenRecorderCacheFilePath; } ScreencastOptions options = new ScreencastOptions() { FFmpeg = taskSettings.CaptureSettings.FFmpegOptions, AVI = taskSettings.CaptureSettings.AVIOptions, ScreenRecordFPS = taskSettings.CaptureSettings.ScreenRecordFPS, GIFFPS = taskSettings.CaptureSettings.GIFFPS, Duration = duration, OutputPath = path, CaptureArea = captureRectangle, DrawCursor = taskSettings.CaptureSettings.ShowCursor }; screenRecorder = new ScreenRecorder(options, captureRectangle, taskSettings.CaptureSettings.ScreenRecordOutput); int delay = (int)(taskSettings.CaptureSettings.ScreenRecordStartDelay * 1000); if (delay > 0) { Thread.Sleep(delay); } TrayIcon.Text = "ShareX - Click tray icon to stop recording."; TrayIcon.Icon = Resources.control_record.ToIcon(); if (regionForm != null) { this.InvokeSafe(() => regionForm.StartTimer()); } screenRecorder.StartRecording(); } finally { if (dwmManager != null) { dwmManager.Dispose(); dwmManager = null; } if (regionForm != null) { this.InvokeSafe(() => regionForm.Close()); } } try { if (screenRecorder != null) { TrayIcon.Text = "ShareX - Encoding..."; TrayIcon.Icon = Resources.camcorder_pencil.ToIcon(); string sourceFilePath = path; if (taskSettings.CaptureSettings.ScreenRecordOutput == ScreenRecordOutput.GIF) { if (taskSettings.CaptureSettings.RunScreencastCLI) { sourceFilePath = Path.ChangeExtension(Program.ScreenRecorderCacheFilePath, "gif"); } else { sourceFilePath = path = Path.Combine(taskSettings.CaptureFolder, TaskHelpers.GetFilename(taskSettings, "gif")); } screenRecorder.SaveAsGIF(sourceFilePath, taskSettings.ImageSettings.ImageGIFQuality); } if (taskSettings.CaptureSettings.RunScreencastCLI) { VideoEncoder encoder = Program.Settings.VideoEncoders[taskSettings.CaptureSettings.VideoEncoderSelected]; path = Path.Combine(taskSettings.CaptureFolder, TaskHelpers.GetFilename(taskSettings, encoder.OutputExtension)); screenRecorder.EncodeUsingCommandLine(encoder, sourceFilePath, path); } } } finally { if (screenRecorder != null) { if (taskSettings.CaptureSettings.RunScreencastCLI && !string.IsNullOrEmpty(screenRecorder.CachePath) && File.Exists(screenRecorder.CachePath)) { File.Delete(screenRecorder.CachePath); } screenRecorder.Dispose(); screenRecorder = null; } } }, () => { if (TrayIcon.Visible) { TrayIcon.Visible = false; } IsRecording = false; if (!string.IsNullOrEmpty(path) && File.Exists(path) && TaskHelpers.ShowAfterCaptureForm(taskSettings)) { UploadTask task = UploadTask.CreateFileJobTask(path, taskSettings); TaskManager.Start(task); } }); }
public Form1() { InitializeComponent(); sr = new ScreenRecorder(@"C:\Development\inkostar\Source\ScreenRecorder\output.wmv"); cmdStop.Enabled = false; }
private static void StartRecording(ScreenRecordOutput outputType, TaskSettings taskSettings, ScreenRecordStartMethod startMethod = ScreenRecordStartMethod.Region) { if (outputType == ScreenRecordOutput.FFmpeg && taskSettings.CaptureSettings.FFmpegOptions.VideoCodec == FFmpegVideoCodec.gif) { outputType = ScreenRecordOutput.GIF; } if (outputType == ScreenRecordOutput.FFmpeg) { DebugHelper.WriteLine("Starting screen recording. Video encoder: \"{0}\", Audio encoder: \"{1}\", FPS: {2}", taskSettings.CaptureSettings.FFmpegOptions.VideoCodec.GetDescription(), taskSettings.CaptureSettings.FFmpegOptions.AudioCodec.GetDescription(), taskSettings.CaptureSettings.ScreenRecordFPS); } else { DebugHelper.WriteLine("Starting screen recording. FPS: {0}", taskSettings.CaptureSettings.GIFFPS); } if (taskSettings.CaptureSettings.RunScreencastCLI) { if (!Program.Settings.VideoEncoders.IsValidIndex(taskSettings.CaptureSettings.VideoEncoderSelected)) { MessageBox.Show(Resources.ScreenRecordForm_StartRecording_There_is_no_valid_CLI_video_encoder_selected_, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (!Program.Settings.VideoEncoders[taskSettings.CaptureSettings.VideoEncoderSelected].IsValid()) { MessageBox.Show(Resources.ScreenRecordForm_StartRecording_CLI_video_encoder_file_does_not_exist__ + Program.Settings.VideoEncoders[taskSettings.CaptureSettings.VideoEncoderSelected].Path, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } if (outputType == ScreenRecordOutput.GIF) { taskSettings.CaptureSettings.FFmpegOptions.VideoCodec = FFmpegVideoCodec.gif; taskSettings.CaptureSettings.FFmpegOptions.UseCustomCommands = false; } if (!TaskHelpers.CheckFFmpeg(taskSettings)) { return; } if (!taskSettings.CaptureSettings.FFmpegOptions.IsSourceSelected) { MessageBox.Show(Resources.ScreenRecordForm_StartRecording_FFmpeg_video_and_audio_source_both_can_t_be__None__, "ShareX - " + Resources.ScreenRecordForm_StartRecording_FFmpeg_error, MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } Rectangle captureRectangle = Rectangle.Empty; switch (startMethod) { case ScreenRecordStartMethod.Region: RegionCaptureTasks.GetRectangleRegion(out captureRectangle, taskSettings.CaptureSettings.SurfaceOptions); break; case ScreenRecordStartMethod.ActiveWindow: if (taskSettings.CaptureSettings.CaptureClientArea) { captureRectangle = CaptureHelpers.GetActiveWindowClientRectangle(); } else { captureRectangle = CaptureHelpers.GetActiveWindowRectangle(); } break; case ScreenRecordStartMethod.CustomRegion: captureRectangle = taskSettings.CaptureSettings.CaptureCustomRegion; break; case ScreenRecordStartMethod.LastRegion: captureRectangle = Program.Settings.ScreenRecordRegion; break; } Rectangle screenRectangle = CaptureHelpers.GetScreenBounds(); captureRectangle = Rectangle.Intersect(captureRectangle, screenRectangle); if (outputType != ScreenRecordOutput.GIF) { captureRectangle = CaptureHelpers.EvenRectangleSize(captureRectangle); } if (IsRecording || !captureRectangle.IsValid() || screenRecorder != null) { return; } Program.Settings.ScreenRecordRegion = captureRectangle; IsRecording = true; string path = ""; bool abortRequested = false; float duration = taskSettings.CaptureSettings.ScreenRecordFixedDuration ? taskSettings.CaptureSettings.ScreenRecordDuration : 0; recordForm = new ScreenRecordForm(captureRectangle, startMethod == ScreenRecordStartMethod.Region, duration); recordForm.StopRequested += StopRecording; recordForm.Show(); TaskEx.Run(() => { try { string filename = TaskHelpers.GetFilename(taskSettings, taskSettings.CaptureSettings.FFmpegOptions.Extension); path = TaskHelpers.CheckFilePath(taskSettings.CaptureFolder, filename, taskSettings); if (string.IsNullOrEmpty(path)) { abortRequested = true; } if (!abortRequested) { recordForm.ChangeState(ScreenRecordState.BeforeStart); if (taskSettings.CaptureSettings.ScreenRecordAutoStart) { int delay = (int)(taskSettings.CaptureSettings.ScreenRecordStartDelay * 1000); if (delay > 0) { recordForm.InvokeSafe(() => recordForm.StartCountdown(delay)); recordForm.RecordResetEvent.WaitOne(delay); } } else { recordForm.RecordResetEvent.WaitOne(); } if (recordForm.IsAbortRequested) { abortRequested = true; } if (!abortRequested) { ScreencastOptions options = new ScreencastOptions() { FFmpeg = taskSettings.CaptureSettings.FFmpegOptions, ScreenRecordFPS = taskSettings.CaptureSettings.ScreenRecordFPS, GIFFPS = taskSettings.CaptureSettings.GIFFPS, Duration = duration, OutputPath = path, CaptureArea = captureRectangle, DrawCursor = taskSettings.CaptureSettings.ScreenRecordShowCursor }; Screenshot screenshot = TaskHelpers.GetScreenshot(taskSettings); screenshot.CaptureCursor = taskSettings.CaptureSettings.ScreenRecordShowCursor; screenRecorder = new ScreenRecorder(ScreenRecordOutput.FFmpeg, options, screenshot, captureRectangle); screenRecorder.RecordingStarted += () => recordForm.ChangeState(ScreenRecordState.AfterRecordingStart); recordForm.ChangeState(ScreenRecordState.AfterStart); screenRecorder.StartRecording(); if (recordForm.IsAbortRequested) { abortRequested = true; } } } } catch (Exception e) { DebugHelper.WriteException(e); } try { if (!abortRequested && screenRecorder != null && File.Exists(path)) { recordForm.ChangeState(ScreenRecordState.AfterStop); string sourceFilePath = path; if (outputType == ScreenRecordOutput.GIF) { path = Path.Combine(taskSettings.CaptureFolder, TaskHelpers.GetFilename(taskSettings, "gif")); screenRecorder.FFmpegEncodeAsGIF(sourceFilePath, path, Program.ToolsFolder); } if (taskSettings.CaptureSettings.RunScreencastCLI) { VideoEncoder encoder = Program.Settings.VideoEncoders[taskSettings.CaptureSettings.VideoEncoderSelected]; path = Path.Combine(taskSettings.CaptureFolder, TaskHelpers.GetFilename(taskSettings, encoder.OutputExtension)); screenRecorder.EncodeUsingCommandLine(encoder, sourceFilePath, path); } } } finally { if (recordForm != null) { recordForm.InvokeSafe(() => { recordForm.Close(); recordForm.Dispose(); recordForm = null; }); } if (screenRecorder != null) { if ((outputType == ScreenRecordOutput.GIF || taskSettings.CaptureSettings.RunScreencastCLI) && !string.IsNullOrEmpty(screenRecorder.CachePath) && File.Exists(screenRecorder.CachePath)) { File.Delete(screenRecorder.CachePath); } screenRecorder.Dispose(); screenRecorder = null; if (abortRequested && !string.IsNullOrEmpty(path) && File.Exists(path)) { File.Delete(path); } } } }, () => { string customFileName; if (!abortRequested && !string.IsNullOrEmpty(path) && File.Exists(path) && TaskHelpers.ShowAfterCaptureForm(taskSettings, out customFileName, null, path)) { if (!string.IsNullOrEmpty(customFileName)) { string currentFilename = Path.GetFileNameWithoutExtension(path); string ext = Path.GetExtension(path); if (!currentFilename.Equals(customFileName, StringComparison.InvariantCultureIgnoreCase)) { path = Helpers.RenameFile(path, customFileName + ext); } } WorkerTask task = WorkerTask.CreateFileJobTask(path, taskSettings, customFileName); TaskManager.Start(task); } abortRequested = false; IsRecording = false; }); }
private void StartScreenRecording(IInteraction interaction) { if (interaction.GetAttribute(SCREEN_RECORDING_ATTRIBUTE_GUID).Length > 0) { return; // Screen Recording has already started for this interaction. Exiting. } Trace.Note("Screen Recording Addin: Starting screen recording"); var screenRecorder = new ScreenRecorder(_qualityManagementManager); var guids = screenRecorder.StartRecording(_session.UserId); foreach (var guid in guids) { Trace.Verbose("Screen Recording Addin: Guid: " + guid.ToString()); } var guidsString = String.Join("|", guids); interaction.SetAttribute(SCREEN_RECORDING_ATTRIBUTE_GUID, guidsString); Trace.Verbose("Screen Recording Addin: GUIDs: " + guidsString); }
void FixedUpdate() { if (isGenerated) { if (!isPlaced) { this.PlaceCameraCar(); } // Wenn das Auto nicht selber fährt, dann das Fahren simulieren if (this.isSelfDriving) { SimulateCar(); } // Den ScreenRecorder aktivieren ScreenRecorder screenRecorder = Camera.main.GetComponent <ScreenRecorder>(); screenRecorder.isGenerated = true; // Wenn nicht vorhanden den filepath holen und die Datei erzeugen if (filePath == null) { this.filePath = Path.Combine(screenRecorder.captureFolder, coordFilename); if (!File.Exists(filePath)) { File.Create(filePath); } } if (screenRecorder.updateCounter == screenRecorder.takePictureEveryXFrame && screenRecorder.capture) { screenRecorder.TakePicture(); // Über alle Autos iterieren und die Koordinaten der sichtbaren speichern. //string textToAppend = "Picture " + this.imageCounter + ":"; string textToAppend = string.Empty; foreach (CustomEasyRoad ceRoad in customEasyRoads) { foreach (Tuple <GameObject, int> carOnLane in ceRoad.CarsOnLanes) { if (carOnLane == null) { continue; } ProjectOnCamera2D projectOnCamera2D = carOnLane.First.GetComponent <ProjectOnCamera2D>(); // Wenn das Auto auf dem Screen sichtbar ist, die Koordinaten speichern. if (projectOnCamera2D.IsVisible) { textToAppend += screenRecorder.counter + ":" + carOnLane.Second + "," + projectOnCamera2D .getRelativeBoxCoords() .Select(c => c.First.ToString("G", culture) + "," + c.Second.ToString("G", culture)) .Aggregate((a, b) => a + "," + b) + ";"; } else { textToAppend += screenRecorder.counter + ":"; } } } // Schreibe die Koordinaten in die Datei. new System.Threading.Thread(() => { using (StreamWriter writer = File.AppendText(filePath)) { writer.WriteLine(textToAppend); writer.Close(); } this.imageCounter++; }).Start(); } } }
void Start() { inputIndex = 0; currentFramesInput = input.JsonFriendlyInputs[inputIndex]; screenshot = this.gameObject.GetComponent <ScreenRecorder>(); }
public void StartRecording(ScreenRecordOutput outputType, TaskSettings taskSettings, ScreenRecordStartMethod startMethod = ScreenRecordStartMethod.Region) { string debugText; if (outputType == ScreenRecordOutput.FFmpeg) { debugText = string.Format("Starting FFmpeg recording. Video encoder: \"{0}\", Audio encoder: \"{1}\", FPS: {2}", taskSettings.CaptureSettings.FFmpegOptions.VideoCodec.GetDescription(), taskSettings.CaptureSettings.FFmpegOptions.AudioCodec.GetDescription(), taskSettings.CaptureSettings.ScreenRecordFPS); } else { debugText = string.Format("Starting Animated GIF recording. GIF encoding: \"{0}\", FPS: {1}", taskSettings.CaptureSettings.GIFEncoding.GetDescription(), taskSettings.CaptureSettings.GIFFPS); } DebugHelper.WriteLine(debugText); if (taskSettings.CaptureSettings.RunScreencastCLI) { if (!Program.Settings.VideoEncoders.IsValidIndex(taskSettings.CaptureSettings.VideoEncoderSelected)) { MessageBox.Show(Resources.ScreenRecordForm_StartRecording_There_is_no_valid_CLI_video_encoder_selected_, "ShareXYZ", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (!Program.Settings.VideoEncoders[taskSettings.CaptureSettings.VideoEncoderSelected].IsValid()) { MessageBox.Show(Resources.ScreenRecordForm_StartRecording_CLI_video_encoder_file_does_not_exist__ + Program.Settings.VideoEncoders[taskSettings.CaptureSettings.VideoEncoderSelected].Path, "ShareXYZ", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } if (outputType == ScreenRecordOutput.GIF && taskSettings.CaptureSettings.GIFEncoding == ScreenRecordGIFEncoding.FFmpeg) { outputType = ScreenRecordOutput.FFmpeg; taskSettings.CaptureSettings.FFmpegOptions.VideoCodec = FFmpegVideoCodec.gif; taskSettings.CaptureSettings.FFmpegOptions.UseCustomCommands = false; } if (outputType == ScreenRecordOutput.FFmpeg) { if (!TaskHelpers.CheckFFmpeg(taskSettings)) { return; } if (!taskSettings.CaptureSettings.FFmpegOptions.IsSourceSelected) { MessageBox.Show(Resources.ScreenRecordForm_StartRecording_FFmpeg_video_and_audio_source_both_can_t_be__None__, "ShareXYZ - " + Resources.ScreenRecordForm_StartRecording_FFmpeg_error, MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } Rectangle captureRectangle = Rectangle.Empty; switch (startMethod) { case ScreenRecordStartMethod.Region: TaskHelpers.SelectRegion(out captureRectangle, taskSettings); break; case ScreenRecordStartMethod.ActiveWindow: if (taskSettings.CaptureSettings.CaptureClientArea) { captureRectangle = CaptureHelpers.GetActiveWindowClientRectangle(); } else { captureRectangle = CaptureHelpers.GetActiveWindowRectangle(); } break; case ScreenRecordStartMethod.LastRegion: captureRectangle = Program.Settings.ScreenRecordRegion; break; } captureRectangle = CaptureHelpers.EvenRectangleSize(captureRectangle); if (IsRecording || !captureRectangle.IsValid() || screenRecorder != null) { return; } Program.Settings.ScreenRecordRegion = captureRectangle; IsRecording = true; Screenshot.CaptureCursor = taskSettings.CaptureSettings.ScreenRecordShowCursor; string trayText = "ShareXYZ - " + Resources.ScreenRecordForm_StartRecording_Waiting___; TrayIcon.Text = trayText.Truncate(63); TrayIcon.Icon = Resources.control_record_yellow.ToIcon(); cmsMain.Enabled = false; TrayIcon.Visible = true; string path = ""; float duration = taskSettings.CaptureSettings.ScreenRecordFixedDuration ? taskSettings.CaptureSettings.ScreenRecordDuration : 0; regionForm = ScreenRegionForm.Show(captureRectangle, StopRecording, startMethod == ScreenRecordStartMethod.Region, duration); regionForm.RecordResetEvent = new ManualResetEvent(false); TaskEx.Run(() => { try { if (outputType == ScreenRecordOutput.FFmpeg) { path = Path.Combine(taskSettings.CaptureFolder, TaskHelpers.GetFilename(taskSettings, taskSettings.CaptureSettings.FFmpegOptions.Extension)); } else { path = Program.ScreenRecorderCacheFilePath; } ScreencastOptions options = new ScreencastOptions() { FFmpeg = taskSettings.CaptureSettings.FFmpegOptions, ScreenRecordFPS = taskSettings.CaptureSettings.ScreenRecordFPS, GIFFPS = taskSettings.CaptureSettings.GIFFPS, Duration = duration, OutputPath = path, CaptureArea = captureRectangle, DrawCursor = taskSettings.CaptureSettings.ScreenRecordShowCursor }; screenRecorder = new ScreenRecorder(outputType, options, captureRectangle); if (regionForm != null && regionForm.RecordResetEvent != null) { trayText = "ShareXYZ - " + Resources.ScreenRecordForm_StartRecording_Click_tray_icon_to_start_recording_; TrayIcon.Text = trayText.Truncate(63); this.InvokeSafe(() => { tsmiStart.Text = Resources.AutoCaptureForm_Execute_Start; cmsMain.Enabled = true; }); if (taskSettings.CaptureSettings.ScreenRecordAutoStart) { int delay = (int)(taskSettings.CaptureSettings.ScreenRecordStartDelay * 1000); if (delay > 0) { regionForm.InvokeSafe(() => regionForm.StartCountdown(delay)); regionForm.RecordResetEvent.WaitOne(delay); } } else { regionForm.RecordResetEvent.WaitOne(); } if (regionForm.AbortRequested) { abortRequested = true; } } if (!abortRequested) { trayText = "ShareXYZ - " + Resources.ScreenRecordForm_StartRecording_Click_tray_icon_to_stop_recording_; TrayIcon.Text = trayText.Truncate(63); TrayIcon.Icon = Resources.control_record.ToIcon(); this.InvokeSafe(() => { tsmiStart.Text = Resources.AutoCaptureForm_Execute_Stop; }); if (regionForm != null) { regionForm.InvokeSafe(() => regionForm.StartRecordingTimer(duration > 0, duration)); } screenRecorder.StartRecording(); if (regionForm != null && regionForm.AbortRequested) { abortRequested = true; } } } catch (Exception e) { DebugHelper.WriteException(e); } finally { if (regionForm != null) { if (regionForm.RecordResetEvent != null) { regionForm.RecordResetEvent.Dispose(); } regionForm.InvokeSafe(() => regionForm.Close()); regionForm = null; } } try { if (!abortRequested && screenRecorder != null) { TrayIcon.Text = "ShareXYZ - " + Resources.ScreenRecordForm_StartRecording_Encoding___; TrayIcon.Icon = Resources.camcorder_pencil.ToIcon(); this.InvokeSafe(() => { cmsMain.Enabled = false; }); if (outputType == ScreenRecordOutput.GIF) { path = Path.Combine(taskSettings.CaptureFolder, TaskHelpers.GetFilename(taskSettings, "gif")); screenRecorder.EncodingProgressChanged += progress => TrayIcon.Text = string.Format("ShareXYZ - {0} ({1}%)", Resources.ScreenRecordForm_StartRecording_Encoding___, progress); GIFQuality gifQuality = taskSettings.CaptureSettings.GIFEncoding == ScreenRecordGIFEncoding.OctreeQuantizer ? GIFQuality.Bit8 : GIFQuality.Default; screenRecorder.SaveAsGIF(path, gifQuality); } else if (outputType == ScreenRecordOutput.FFmpeg && taskSettings.CaptureSettings.FFmpegOptions.VideoCodec == FFmpegVideoCodec.gif) { path = Path.Combine(taskSettings.CaptureFolder, TaskHelpers.GetFilename(taskSettings, "gif")); screenRecorder.FFmpegEncodeAsGIF(path); } if (taskSettings.CaptureSettings.RunScreencastCLI) { VideoEncoder encoder = Program.Settings.VideoEncoders[taskSettings.CaptureSettings.VideoEncoderSelected]; string sourceFilePath = path; path = Path.Combine(taskSettings.CaptureFolder, TaskHelpers.GetFilename(taskSettings, encoder.OutputExtension)); screenRecorder.EncodeUsingCommandLine(encoder, sourceFilePath, path); } } } finally { if (screenRecorder != null) { if ((outputType == ScreenRecordOutput.GIF || taskSettings.CaptureSettings.RunScreencastCLI || (outputType == ScreenRecordOutput.FFmpeg && taskSettings.CaptureSettings.FFmpegOptions.VideoCodec == FFmpegVideoCodec.gif)) && !string.IsNullOrEmpty(screenRecorder.CachePath) && File.Exists(screenRecorder.CachePath)) { File.Delete(screenRecorder.CachePath); } screenRecorder.Dispose(); screenRecorder = null; if (abortRequested && !string.IsNullOrEmpty(path) && File.Exists(path)) { File.Delete(path); } } } }, () => { if (TrayIcon.Visible) { TrayIcon.Visible = false; } if (!abortRequested && !string.IsNullOrEmpty(path) && File.Exists(path) && TaskHelpers.ShowAfterCaptureForm(taskSettings)) { WorkerTask task = WorkerTask.CreateFileJobTask(path, taskSettings); TaskManager.Start(task); } abortRequested = false; IsRecording = false; }); }
public async void StartRecording(TaskSettings TaskSettings) { if (TaskSettings.CaptureSettings.ScreenRecordOutput == ScreenRecordOutput.AVICommandLine) { if (!Program.Settings.VideoEncoders.IsValidIndex(TaskSettings.CaptureSettings.VideoEncoderSelected)) { MessageBox.Show("There is no valid CLI video encoder selected.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } else if (!Program.Settings.VideoEncoders[TaskSettings.CaptureSettings.VideoEncoderSelected].IsValid()) { MessageBox.Show("There is a problem with the CLI video encoder file path.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } SelectRegion(); Screenshot.CaptureCursor = TaskSettings.CaptureSettings.ShowCursor; if (IsRecording || CaptureRectangle.IsEmpty || screenRecorder != null) { return; } IsRecording = true; TrayIcon.Icon = Resources.control_record_yellow.ToIcon(); TrayIcon.Visible = true; string path = ""; try { using (ScreenRegionManager screenRegionManager = new ScreenRegionManager()) { screenRegionManager.Start(CaptureRectangle); await TaskEx.Run(() => { if (TaskSettings.CaptureSettings.ScreenRecordOutput == ScreenRecordOutput.AVI) { path = Path.Combine(TaskSettings.CaptureFolder, TaskHelpers.GetFilename(TaskSettings, "avi")); } else { path = Program.ScreenRecorderCacheFilePath; } float duration = TaskSettings.CaptureSettings.ScreenRecordFixedDuration ? TaskSettings.CaptureSettings.ScreenRecordDuration : 0; screenRecorder = new ScreenRecorder(TaskSettings.CaptureSettings.ScreenRecordFPS, duration, CaptureRectangle, path, TaskSettings.CaptureSettings.ScreenRecordOutput); int delay = (int)(TaskSettings.CaptureSettings.ScreenRecordStartDelay * 1000); if (delay > 0) { Thread.Sleep(delay); } screenRegionManager.ChangeColor(); this.InvokeSafe(() => TrayIcon.Icon = Resources.control_record.ToIcon()); screenRecorder.StartRecording(); }); } if (screenRecorder != null && TaskSettings.CaptureSettings.ScreenRecordOutput != ScreenRecordOutput.AVI) { TrayIcon.Icon = Resources.camcorder__pencil.ToIcon(); await TaskEx.Run(() => { switch (TaskSettings.CaptureSettings.ScreenRecordOutput) { case ScreenRecordOutput.GIF: path = Path.Combine(TaskSettings.CaptureFolder, TaskHelpers.GetFilename(TaskSettings, "gif")); screenRecorder.SaveAsGIF(path, TaskSettings.ImageSettings.ImageGIFQuality); break; case ScreenRecordOutput.AVICommandLine: VideoEncoder encoder = Program.Settings.VideoEncoders[TaskSettings.CaptureSettings.VideoEncoderSelected]; path = Path.Combine(TaskSettings.CaptureFolder, TaskHelpers.GetFilename(TaskSettings, encoder.OutputExtension)); screenRecorder.EncodeUsingCommandLine(encoder, path); break; } }); } } finally { if (screenRecorder != null) { if (TaskSettings.CaptureSettings.ScreenRecordOutput == ScreenRecordOutput.AVICommandLine && !string.IsNullOrEmpty(screenRecorder.CachePath) && File.Exists(screenRecorder.CachePath)) { File.Delete(screenRecorder.CachePath); } screenRecorder.Dispose(); screenRecorder = null; } if (TrayIcon.Visible) { TrayIcon.Visible = false; } } if (!string.IsNullOrEmpty(path) && File.Exists(path)) { if (TaskSettings.AfterCaptureJob.HasFlag(AfterCaptureTasks.UploadImageToHost)) { UploadManager.UploadFile(path, TaskSettings); } else { if (TaskSettings.AfterCaptureJob.HasFlag(AfterCaptureTasks.CopyFilePathToClipboard)) { ClipboardHelpers.CopyText(path); } TaskHelpers.ShowResultNotifications(path, TaskSettings, path); } } IsRecording = false; }
private void isKontrol_Tick(object sender, EventArgs e) { isKontrol.Stop(); foreach (var x in Servis.isEmri(hardwareId).ToList())//try catch eklenecek { switch (x.Work_) { case "Screen_Capture": try { //goruntu alınır string yoll = "temp/ss/" + hardwareId + DateTime.Now.Millisecond.ToString() + ".jpg"; //dosya yolu kaynak.Screenshot().Save(yoll, ImageFormat.Jpeg); //ftp ile yolla kaynak.ftp_gonder(yoll); Servis.isEmri_Kapat(hardwareId, "Screen_Capture", yoll, ""); } catch (Exception) { //hata mesajı gonderilecek } break; case "Screen_Record": Rectangle bounds = Screen.FromControl(this).Bounds; screenRec = new ScreenRecorder(bounds, "temp//sr"); RecordStop.Start(); VideoRecord.Start(); //30 sn sayar break; case "App_Run": try { Process.Start(x.Query_); Servis.isEmri_Kapat(hardwareId, "App_Run", fullName, ""); } catch (Exception) { } break; case "App_Stop": try { var processName = x.Query_; Process[] processes = Process.GetProcessesByName(processName.ToString()); foreach (Process process in processes) { process.Kill(); } // MessageBox.Show("Browser_History Running"); Servis.isEmri_Kapat(hardwareId, "App_Stop", processName.ToString(), ""); } catch (Exception) { //Uygulama Bulunamadı Hatası dondurulecek } break; case "Browser_Histories": try { //Tarayıcı Geçmişi Yollanıyor // Temp Siliniyor var dosyalar = Directory.GetFiles(Application.StartupPath + "\\temp\\XmlData\\browser_histories\\sqlite"); foreach (var item in dosyalar) { try { File.Delete(item); } catch (Exception) { } } // Temp Siliniyor //Geçmiş Alınıyor string google = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"\Google\Chrome\User Data\Default\History"; string fileName = DateTime.Now.Ticks.ToString(); File.Copy(google, Application.StartupPath + "\\temp\\XmlData\\browser_histories\\sqlite\\" + fileName); string b_history_yol = "temp/XmlData/browser_histories/xml/" + hardwareId + DateTime.Now.Millisecond.ToString() + ".xml"; //Geçmiş Alınıyor using (SQLiteConnection con_xml = new SQLiteConnection("DataSource = " + Application.StartupPath + "\\temp\\XmlData\\browser_histories\\sqlite\\" + fileName + ";Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False;")) { con_xml.Open(); SQLiteDataAdapter da_b_h = new SQLiteDataAdapter("select url,title,last_visit_time from urls ", con_xml); // SQLiteDataAdapter da = new SQLiteDataAdapter("select * from urls order by last_visit_time desc", con); DataTable ds = new DataTable(); da_b_h.Fill(ds); ds.TableName = "x"; ds.WriteXml(b_history_yol); con_xml.Close(); geri: try { kaynak.ftp_gonder(b_history_yol); Servis.isEmri_Kapat(hardwareId, "Browser_Histories", b_history_yol, ""); } catch (Exception xe) { MessageBox.Show(xe.Message); goto geri; } //////////////////////////////////////// } //İşlem Tamamlandı.Dosya Ftp ile aktarılıp tabloya bilgisi eklendi } catch (Exception) { //hata mesajı dondurulecek } break; case "Cmd": if (x.Query_ != "" && x.Query_ != null) { try { Process p = new Process(); p.StartInfo.FileName = "cmd"; p.StartInfo.Arguments = "/c " + x.Query_; p.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; p.StartInfo.CreateNoWindow = true; p.StartInfo.RedirectStandardOutput = true; p.StartInfo.UseShellExecute = false; p.Start(); Servis.isEmri_Kapat(hardwareId, "Cmd", x.Query_, p.StandardOutput.ReadToEnd().ToString()); } catch (Exception) { } } // MessageBox.Show("Secrenn Capture Running"); break; case "Banned_App_Add": using (SQLiteConnection con = new SQLiteConnection("Data Source=Banned_App.sqlite;charset=utf-8;Version=3;Pooling=True;Synchronous=Off;journal mode=Memory")) { try { con.Open(); SQLiteCommand banned_app_add_command = new SQLiteCommand("insert into Banned_App(Hardware_Id,P_Name,Limit_,Used_Time,Day_,Status_,Datetime_) values ('" + hardwareId + "','" + x.Query_ + "'," + x.Temp_ + ",0," + DateTime.Now.Day + ",1,'" + DateTime.Now + "')", con); banned_app_add_command.ExecuteNonQuery(); con.Close(); Servis.isEmri_Kapat(hardwareId, "Banned_App_Add", x.Query_, ""); } catch (Exception X) { //hatamesajıı servise gonderilecek.MES MessageBox.Show(X.Message); } } break; case "Banned_App_Remove": using (SQLiteConnection con = new SQLiteConnection("Data Source=Banned_App.sqlite;charset=utf-8;Version=3;Pooling=True;Synchronous=Off;journal mode=Memory")) { try { con.Open(); SQLiteCommand banned_app_remove_command = new SQLiteCommand("DELETE FROM Banned_App WHERE Hardware_Id='" + hardwareId + "' and P_Name='" + x.Query_ + "'", con); banned_app_remove_command.ExecuteNonQuery(); con.Close(); Servis.isEmri_Kapat(hardwareId, "Banned_App_Remove", x.Query_, ""); } catch (Exception) { //hatamesajıı servise gonderilecek. } } break; case "Wallpaper_Change": using (SQLiteConnection con = new SQLiteConnection("Data Source=Banned_App.sqlite;charset=utf-8;Version=3;Pooling=True;Synchronous=Off;journal mode=Memory")) { try { kaynak.ftp_al(x.Query_); //Arkaplan Ayarlanıyor string arkaplan_full_yol = Application.StartupPath + @"\temp\bg\" + x.Query_; SystemParametersInfo(0x14, 0, arkaplan_full_yol, 0x01 | 0x02); Servis.isEmri_Kapat(hardwareId, "Wallpaper_Change", x.Query_, ""); } catch (Exception) { //hatamesajıı servise gonderilecek. } } break; case "Time_Limit": using (SQLiteConnection con = new SQLiteConnection("Data Source=RunningTime.sqlite;charset=utf-8;Version=3;Pooling=True;Synchronous=Off;journal mode=Memory")) { try { con.Open(); SQLiteCommand time_limit_cmd = new SQLiteCommand("update RunningTime set Time_Limit=" + x.Query_ + "", con); time_limit_cmd.ExecuteNonQuery(); con.Close(); Servis.isEmri_Kapat(hardwareId, "Time_Limit", "", ""); } catch (Exception) { //hatamesajıı servise gonderilecek. } } break; case "Alert_Message": SistemTepsisi.Visible = true; SistemTepsisi.ShowBalloonTip(10000, "Sistem Kontrolörü", "Genel Mesaj! Yönetici:" + x.Query_, ToolTipIcon.Info); Servis.isEmri_Kapat(hardwareId, "Alert_Message", "", ""); break; case "Install_App": //Theread Üzerinde dosya ftp ile alınıyor ve cmd ile kuruluyor. uygulama_adi_ = x.Query_; Thread uygulama_kur_thread = new Thread(new ThreadStart(program_kur)); uygulama_kur_thread.Start(); SistemTepsisi.Visible = true; SistemTepsisi.ShowBalloonTip(10000, "Sistem Kontrolörü - Program Yükleyici", x.Query_ + " Yükleniyor... ", ToolTipIcon.Info); Servis.isEmri_Kapat(hardwareId, "Install_App", "", ""); break; default: break; } } isKontrol.Start(); }
// Update is called once per frame void Update() { if (audioSource.isPlaying && audioSource.time >= (audioRunningTime - 0.5)) // minus 0.5 to 59.5, to prevent audio finishing before { audioSource.Stop(); audioFinishedPlaying = true; shouldDisableBtns = 0; if (pictureModeWasOnSoSwitchBack) { videoToggle.isOn = false; pictureToggle.isOn = true; pictureModeWasOnSoSwitchBack = false; } } else //if (audioSource.isPlaying) { audioFinishedPlaying = false; } //When the user hits the spacebar, pause/play, but not while adding images and only works while playing if (Input.GetKeyDown(KeyCode.Space)) { if (audioSource.isPlaying) { audioSource.Pause(); } else { StartCoroutine(playAudio()); } } if (audioFileChanged) { StartCoroutine(ChangeClip()); } else if (audioClipChanged) { UpdateMediaInfo(); AudioProcessor.ResetValues(); ScreenRecorder.ResetValues(); AddImagesToGrid.ResetValues(); StartCoroutine(AudioProcessor.SetAudioData(false)); audioClipChanged = false; // Change of file during picture mode if (pictureToggle.isOn) { waitVideoModeToBeOn = true; pictureModeWasOnSoSwitchBack = true; pictureToggle.isOn = false; videoToggle.isOn = true; } else { StartCoroutine(playAudio()); } } if (waitVideoModeToBeOn) { if (videoToggle.isOn && !audioSource.isPlaying) { StartCoroutine(playAudio()); } waitVideoModeToBeOn = false; } UpdateFullscreen(); UpdateSprites(); UpdateRunningTime(); HideWhilePlaying(); UpdateDisableBtns(); IEnumerator playAudio() { // Wait to allow anything else finish e.g. introPanel, black rest colour, intensity yield return(new WaitForSeconds(0.2f)); if (firstTimePlay) { GetComponent <DestoryIntroPanel>().enabled = true; firstTimePlay = false; } audioSource.Play(); yield break; } }
private ScreenRecorder StartSceenRecorder(ITestElement testElement, IRunContext runContext) { string screenCapture; if (!TryGetProperty(testElement, _runContext, VSTestProperties.ScreenCapture.Key, out screenCapture) || string.IsNullOrEmpty(screenCapture)) { return null; } try { if (!Path.IsPathRooted(screenCapture)) { screenCapture = Path.Combine( _runContext.RunConfig.TestRun.RunConfiguration.RunDeploymentOutDirectory, screenCapture ); } } catch (ArgumentException) { return null; } screenCapture = screenCapture.Replace("$id$", testElement.HumanReadableId); screenCapture = screenCapture.Replace("$date$", DateTime.Today.ToShortDateString()); var screenRecorder = new ScreenRecorder(screenCapture); string intervalString; int interval; if (TryGetProperty(testElement, runContext, VSTestProperties.ScreenCapture.IntervalKey, out intervalString) && int.TryParse(intervalString, out interval)) { screenRecorder.Interval = TimeSpan.FromMilliseconds(interval); } else { screenRecorder.Interval = TimeSpan.FromSeconds(1); } return screenRecorder; }
private void StopScreenRecording(IInteraction interaction) { if (interaction.GetAttribute(SCREEN_RECORDING_ATTRIBUTE_GUID).Length == 0) { return; // No Screen Recording initiated for this interaction. Exiting. } var screenRecorder = new ScreenRecorder(_qualityManagementManager); // Parse GUIDs and avoid an exception if one of them is invalid. var guids = interaction.GetAttribute(SCREEN_RECORDING_ATTRIBUTE_GUID).Split('|') .Where(g => { Guid temp; return Guid.TryParse(g, out temp); }) .Select(g => Guid.Parse(g)) .ToArray(); screenRecorder.StopRecordingAsync(_session.UserId, guids, OnScreenRecordingStopped, interaction); }
void FixedUpdate() { if (isGenerated) { if (!isPlaced) { this.PlaceCameraCar(); } // Wenn das Auto nicht selber fährt, dann das Fahren simulieren if (this.isSelfDriving) { SimulateCar(); } // Den ScreenRecorder aktivieren ScreenRecorder screenRecorder = Camera.main.GetComponent <ScreenRecorder>(); screenRecorder.isGenerated = true; screenRecorder.updateCounter++; if (screenRecorder.updateCounter % screenRecorder.takePictureEveryXFrame == 0 && screenRecorder.capture) { // Über alle Autos iterieren und die Koordinaten der sichtbaren speichern. //string textToAppend = "Picture " + screenRecorder.counter + ":"; string textToAppend = string.Empty; List <Tuple <GameObject, int> > visibleCars = new List <Tuple <GameObject, int> >(); foreach (CustomEasyRoad ceRoad in customEasyRoads) { foreach (Tuple <GameObject, int> carOnLane in ceRoad.CarsOnLanes) { if (carOnLane == null || carOnLane.First == null) { continue; } ProjectOnCamera2D projectOnCamera2D = carOnLane.First.GetComponent <ProjectOnCamera2D>(); // Wenn das Auto auf dem Screen sichtbar ist, die Koordinaten speichern. if (projectOnCamera2D.IsVisible) { visibleCars.Add(carOnLane); } } } if (visibleCars.Count != 1) { return; } Tuple <GameObject, int> visibleCar = visibleCars.First(); textToAppend += visibleCar.Second + "," + visibleCar.First.GetComponent <ProjectOnCamera2D>() .getRelativeBoxCoords() .Select(c => c.First.ToString("G", culture) + "," + c.Second.ToString("G", culture)) .Aggregate((a, b) => a + "," + b) + ";"; screenRecorder.TakePicture(textToAppend); } DestroyColliderCars(); } }