private static void DownloadFFmpeg64ForWindows() { FFmpegConfig.CheckFolder(); if (downloadFFmpegThread != null) { if (downloadFFmpegThread.IsAlive) { downloadFFmpegThread.Abort(); } downloadFFmpegThread = null; } string windowsFFmpegPath = FFmpegConfig.windows64Path; downloadFFmpegThread = new Thread( () => DownloadFFmpegThreadFunction(WINDOWS_FFMPEG_64_DOWNLOAD_URL, windowsFFmpegPath)); downloadFFmpegThread.Priority = System.Threading.ThreadPriority.Lowest; downloadFFmpegThread.IsBackground = true; downloadFFmpegThread.Start(); }
private static void DownloadFFmpegForOSX() { FFmpegConfig.CheckFolder(); if (downloadFFmpegThread != null) { if (downloadFFmpegThread.IsAlive) { downloadFFmpegThread.Abort(); } downloadFFmpegThread = null; } string macOSFFmpegPath = FFmpegConfig.macOSPath; downloadFFmpegThread = new Thread( () => DownloadFFmpegThreadFunction(OSX_FFMPEG_DOWNLOAD_URL, macOSFFmpegPath)); downloadFFmpegThread.Priority = System.Threading.ThreadPriority.Lowest; downloadFFmpegThread.IsBackground = true; downloadFFmpegThread.Start(); }
public bool StartCapture() { if (captureStarted) { Debug.LogWarningFormat(LOG_FORMAT, "Previous video capture manager session not finish yet!"); return(false); } // check all video capture is ready bool allReady = true; foreach (VideoCapture videoCapture in videoCaptures) { if (videoCapture.status != CaptureStatus.READY) { allReady = false; break; } } if (!allReady) { Debug.LogWarningFormat(LOG_FORMAT, "There is one or more video capture session still in progress!"); return(false); } if (!FFmpegConfig.IsExist()) { Debug.LogErrorFormat(LOG_FORMAT, "FFmpeg not found, please follow document and add ffmpeg executable before start capture!"); return(false); } saveFolder = Utils.CreateFolder(saveFolder); if (captureMode == CaptureMode._360) { if (projectionType == ProjectionType.NONE) { Debug.LogFormat(LOG_FORMAT, "Projection type should be set for 360 capture, set type to equirect for generating texture properly"); projectionType = ProjectionType.EQUIRECT; } if (projectionType == ProjectionType.CUBEMAP) { if (stereoMode != StereoMode.NONE) { Debug.LogFormat(LOG_FORMAT, "Stereo settings not support for cubemap capture, reset to mono video capture."); stereoMode = StereoMode.NONE; } } } else if (captureMode == CaptureMode.REGULAR) { // Non 360 capture doesn't have projection type projectionType = ProjectionType.NONE; } // start capture for all video capture foreach (VideoCapture videoCapture in videoCaptures) { // video capture settings videoCapture.startOnAwake = startOnAwake; videoCapture.captureTime = captureTime; videoCapture.quitAfterCapture = quitAfterCapture; videoCapture.captureMode = captureMode; videoCapture.projectionType = projectionType; // only VOD supported in multi capture videoCapture.captureType = CaptureType.VOD; videoCapture.saveFolder = saveFolder; videoCapture.resolutionPreset = resolutionPreset; videoCapture.frameWidth = frameWidth; videoCapture.frameHeight = frameHeight; videoCapture.frameRate = frameRate; videoCapture.bitrate = bitrate; videoCapture.stereoMode = stereoMode; videoCapture.interpupillaryDistance = interpupillaryDistance; videoCapture.cubemapFaceSize = cubemapFaceSize; videoCapture.offlineRender = offlineRender; videoCapture.captureAudio = captureAudio; videoCapture.captureMicrophone = captureMicrophone; videoCapture.deviceIndex = deviceIndex; videoCapture.antiAliasing = antiAliasing; videoCapture.gpuEncoding = gpuEncoding; videoCapture.encoderPreset = encoderPreset; videoCapture.StartCapture(); } captureStarted = true; return(true); }
/// <summary> /// Prepare capture settings. /// </summary> protected bool PrepareCapture() { if (status != CaptureStatus.READY) { Debug.LogWarningFormat(LOG_FORMAT, "Previous capture session not finish yet!"); OnCaptureError(new CaptureErrorEventArgs(CaptureErrorCode.CAPTURE_ALREADY_IN_PROGRESS)); return(false); } if (!FFmpegConfig.IsExist()) { Debug.LogErrorFormat(LOG_FORMAT, "FFmpeg not found, please follow document and add ffmpeg executable before start capture!"); OnCaptureError(new CaptureErrorEventArgs(CaptureErrorCode.FFMPEG_NOT_FOUND)); return(false); } if (captureSource == CaptureSource.RENDERTEXTURE) { if (inputTexture == null) { Debug.LogErrorFormat(LOG_FORMAT, "Input render texture not found, please attach input render texture!"); OnCaptureError(new CaptureErrorEventArgs(CaptureErrorCode.INPUT_TEXTURE_NOT_FOUND)); return(false); } if (captureMode != CaptureMode.REGULAR) { Debug.LogFormat(LOG_FORMAT, "Capture from render texture only support REGULAR CaptureMode"); captureMode = CaptureMode.REGULAR; projectionType = ProjectionType.NONE; } if (stereoMode != StereoMode.NONE) { Debug.LogFormat(LOG_FORMAT, "Capture from render texture only support NONE StereoMode"); stereoMode = StereoMode.NONE; } frameWidth = inputTexture.width; frameHeight = inputTexture.height; } else if (captureSource == CaptureSource.SCREEN) { if (captureMode != CaptureMode.REGULAR) { Debug.LogFormat(LOG_FORMAT, "Capture from screen only support REGULAR CaptureMode"); captureMode = CaptureMode.REGULAR; projectionType = ProjectionType.NONE; } if (stereoMode != StereoMode.NONE) { Debug.LogFormat(LOG_FORMAT, "Capture from screen only support NONE StereoMode"); stereoMode = StereoMode.NONE; } if (captureCursor) { Cursor.SetCursor(cursorImage, Vector2.zero, CursorMode.ForceSoftware); } frameWidth = Screen.width; frameHeight = Screen.height; } else { ResolutionPresetSettings(); } // Some codec cannot handle odd video size frameWidth = Utils.GetClosestEvenNumber(frameWidth); frameHeight = Utils.GetClosestEvenNumber(frameHeight); if (captureType == CaptureType.LIVE) { if (string.IsNullOrEmpty(liveStreamUrl)) { Debug.LogWarningFormat(LOG_FORMAT, "Please input a valid live streaming url."); OnCaptureError(new CaptureErrorEventArgs(CaptureErrorCode.INVALID_STREAM_URI)); return(false); } } if (captureMode == CaptureMode._360) { if (projectionType == ProjectionType.NONE) { Debug.LogFormat(LOG_FORMAT, "Projection type should be set for 360 capture, set type to equirect for generating texture properly"); projectionType = ProjectionType.EQUIRECT; } if (projectionType == ProjectionType.CUBEMAP) { if (stereoMode != StereoMode.NONE) { Debug.LogFormat(LOG_FORMAT, "Stereo settings not support for cubemap capture, reset to mono video capture."); stereoMode = StereoMode.NONE; } } CubemapSizeSettings(); } else if (captureMode == CaptureMode.REGULAR) { // Non 360 capture doesn't have projection type projectionType = ProjectionType.NONE; } if (frameRate < 18) { frameRate = 18; Debug.LogFormat(LOG_FORMAT, "Minimum frame rate is 18, set frame rate to 18."); } if (frameRate > 120) { frameRate = 120; Debug.LogFormat(LOG_FORMAT, "Maximum frame rate is 120, set frame rate to 120."); } AntiAliasingSettings(); if (captureAudio && offlineRender) { Debug.LogFormat(LOG_FORMAT, "Audio capture not supported in offline render mode, disable audio capture!"); captureAudio = false; } // Save camera settings SaveCameraSettings(); if (transparent) { TransparentCameraSettings(); } ffmpegFullPath = FFmpegConfig.path; saveFolderFullPath = Utils.CreateFolder(saveFolder); lastVideoFile = ""; return(true); }