static public bool CheckDiskSpaceWithError(string path, string error = null) { if (error == null) { error = "Out of disk space!"; } if (!FileUtils.HasFreeSpace(path)) { OutputWindowScript.ReportFileSaved(error, null, OutputWindowScript.InfoCardSpawnPos.Brush); return(false); } return(true); }
static public bool StartVideoCapture(string filePath, VideoRecorder recorder, UsdPathSerializer usdPathSerializer, bool offlineRender = false) { // Only one video at a time. if (m_ActiveVideoRecording != null) { return(false); } // Don't start recording unless there is enough space left. if (!FileUtils.InitializeDirectoryWithUserError( Path.GetDirectoryName(filePath), "Failed to start video capture")) { return(false); } // Vertical video is disabled. recorder.IsPortrait = false; // Start the capture first, which may fail, so do this before toggling any state. // While the state below is important for the actual frame capture, starting the capture process // does not require it. int sampleRate = 0; if (AudioCaptureManager.m_Instance.IsCapturingAudio) { sampleRate = AudioCaptureManager.m_Instance.SampleRate; } if (!recorder.StartCapture(filePath, sampleRate, AudioCaptureManager.m_Instance.IsCapturingAudio, offlineRender, offlineRender ? App.UserConfig.Video.OfflineFPS : App.UserConfig.Video.FPS)) { OutputWindowScript.ReportFileSaved("Failed to start capture!", null, OutputWindowScript.InfoCardSpawnPos.Brush); return(false); } m_ActiveVideoRecording = recorder; // Perform any necessary VR camera rendering optimizations to reduce CPU & GPU workload // Debug reduce quality for capture. // XXX This should just be ADAPTIVE RENDERING if (m_DebugVideoCaptureQualityLevel != -1) { m_PreCaptureQualityLevel = QualityControls.m_Instance.QualityLevel; QualityControls.m_Instance.QualityLevel = m_DebugVideoCaptureQualityLevel; } App.VrSdk.SetHmdScalingFactor(m_VideoCaptureResolutionScale); // Setup SSAA RenderWrapper wrapper = recorder.gameObject.GetComponent <RenderWrapper>(); m_PreCaptureSuperSampling = wrapper.SuperSampling; wrapper.SuperSampling = m_SuperSampling; #if USD_SUPPORTED // Read from the Usd serializer if we're recording offline. Write to it otherwise. m_UsdPathSerializer = usdPathSerializer; if (!offlineRender) { m_UsdPath = SaveLoadScript.m_Instance.SceneFile.Valid ? Path.ChangeExtension(filePath, "usda") : null; m_RecordingStopwatch = new System.Diagnostics.Stopwatch(); m_RecordingStopwatch.Start(); if (!m_UsdPathSerializer.StartRecording(m_UsdPath)) { UnityEngine.Object.Destroy(m_UsdPathSerializer); m_UsdPathSerializer = null; } } else { recorder.SetCaptureFramerate(Mathf.RoundToInt(App.UserConfig.Video.OfflineFPS)); m_UsdPath = null; if (m_UsdPathSerializer.Load(App.Config.m_VideoPathToRender)) { m_UsdPathSerializer.StartPlayback(); } else { UnityEngine.Object.Destroy(m_UsdPathSerializer); m_UsdPathSerializer = null; } } #endif return(true); }