static public void StopVideoCapture(bool saveCapture) { // Debug reset changes to quality settings. if (m_DebugVideoCaptureQualityLevel != -1) { QualityControls.m_Instance.QualityLevel = m_PreCaptureQualityLevel; } App.VrSdk.SetHmdScalingFactor(1.0f); // Stop capturing, reset colors m_ActiveVideoRecording.gameObject.GetComponent <RenderWrapper>().SuperSampling = m_PreCaptureSuperSampling; m_ActiveVideoRecording.StopCapture(save: saveCapture); #if USD_SUPPORTED if (m_UsdPathSerializer != null) { bool wasRecording = m_UsdPathSerializer.IsRecording; m_UsdPathSerializer.Stop(); if (wasRecording) { m_RecordingStopwatch.Stop(); if (!string.IsNullOrEmpty(m_UsdPath)) { if (App.UserConfig.Video.SaveCameraPath && saveCapture) { m_UsdPathSerializer.Save(); CreateOfflineRenderBatchFile(SaveLoadScript.m_Instance.SceneFile.FullPath, m_UsdPath); } } } } m_UsdPathSerializer = null; m_RecordingStopwatch = null; #endif m_ActiveVideoRecording = null; App.Switchboard.TriggerVideoRecordingStopped(); }
void Update() { if (m_odsCamera.FrameCount >= m_framesToCapture) { if (m_framesToCapture > 0) { // We rendered everything. if ((Application.platform == RuntimePlatform.WindowsPlayer) || (Application.platform == RuntimePlatform.WindowsEditor)) { System.Diagnostics.Process.Start("explorer.exe", "/open," + m_outputFolder); } System.Diagnostics.Process proc = new System.Diagnostics.Process(); proc.StartInfo.FileName = Path.GetFullPath(TiltBrush.FfmpegPipe.GetFfmpegExe()); proc.StartInfo.Arguments = System.String.Format( @"-y -framerate {0} -f image2 -i ""{1}_%06d.png"" " + @"-c:v " + FfmpegPipe.GetVideoEncoder() + @" -r {0} -pix_fmt yuv420p ""{2}""", m_fps, m_imagesPath, m_videoPath); Debug.LogFormat("{0} {1}", proc.StartInfo.FileName, proc.StartInfo.Arguments); proc.StartInfo.CreateNoWindow = false; proc.StartInfo.ErrorDialog = true; proc.StartInfo.UseShellExecute = false; proc.StartInfo.RedirectStandardError = true; proc.Start(); UnityEngine.Debug.Log(proc.StandardError.ReadToEnd()); #if USD_SUPPORTED if (m_PathSerializer != null) { m_PathSerializer.Stop(); } #endif proc.Close(); Application.Quit(); Debug.Break(); } return; } if (m_odsCamera.IsRendering) { return; } if (m_frameTick) { if (m_frameTimer.ElapsedMilliseconds < 1000.0f / m_fps) { return; } m_frameTimer.Stop(); } if (m_renderTimer.IsRunning) { m_renderTimer.Stop(); Debug.LogFormat("ODS Frame Time: {0}", m_renderTimer.ElapsedMilliseconds / 1000.0f); } m_frameTick = !m_frameTick; if (m_frameTick) { Time.timeScale = 1.0f; m_frameTimer.Reset(); m_frameTimer.Start(); return; } Time.timeScale = 0.0f; if (!HaveCameraPath) { float progress = m_odsCamera.FrameCount / (float)m_framesToCapture; App.Scene.Pose = GetScenePose(progress); if (m_turnTableRotation > 0) { TiltBrush.TrTransform sc = App.Scene.Pose; sc.rotation = Quaternion.AngleAxis(progress * m_turnTableRotation, Vector3.up); App.Scene.Pose = sc; } } else { #if USD_SUPPORTED m_PathSerializer.Time = m_odsCamera.FrameCount / m_fps; m_PathSerializer.Deserialize(); #endif } Camera cam = OdsCamera.GetComponent <Camera>(); Camera parentCam = TiltBrush.App.VrSdk.GetVrCamera(); cam.clearFlags = parentCam.clearFlags; cam.backgroundColor = parentCam.backgroundColor; // Copy back the culling mask so the preview window looks like the final render. parentCam.cullingMask = cam.cullingMask; if (m_odsCamera.FrameCount == 0 && m_framesToCapture > 0) { if (QualitySettings.GetQualityLevel() != 3) { QualitySettings.SetQualityLevel(3); } } App.Instance.FrameCountDisplay.SetCurrentFrame(m_odsCamera.FrameCount); // Move the viewer camera, so the user can see what's going on. Transform viewerXform = App.VrSdk.GetVrCamera().transform; viewerXform.position = transform.position; viewerXform.rotation = transform.rotation; viewerXform.localScale = transform.localScale; m_renderTimer.Reset(); m_renderTimer.Start(); StartCoroutine(m_odsCamera.Render(transform)); }