keijiro / FFmpegOut

Video capture plugin for Unity with FFmpeg.
MIT License
931 stars 150 forks source link

Issues with VR? #53

Open NITechLabs opened 4 years ago

NITechLabs commented 4 years ago

Hi, For internal scientific research (so no direct issues with licenses) I want to use your runtime option of the recorder. In a default project it works fine, but using VR (legacy XR because of using OpenVR with HTC Vive Pro) in 2019.4.1 with HDRP 7.4.1 the camera stops reacting to the headset. So there is an image, no errors, just the tracking stops. There is also no video saved in the project's root folder. Is this recording solution compatible with the legacy XR in Unity? If so, are there any special settings?

Cheers!

Marco

keijiro commented 4 years ago

I don't have any experience on VR, so I'm not sure what's happening in it, but I think you can't grab the main camera (headset) without interrupting VR things. It might be better to add a second camera and capture it, I'm not sure how it can be done with VR though.

eusebiu commented 4 years ago

I think you can create a new GameObject with a Camera attached and put it under the main Camera.

        Transform camPar = Camera.main.transform;
        GameObject camGo = new GameObject("ScreenShotCamera");
        camGo.transform.parent = camPar;
        camGo.transform.localPosition = Vector3.zero;
        camGo.transform.localRotation = Quaternion.identity;

        screenshotCam = camGo.AddComponent<Camera>();
        screenshotCam.nearClipPlane = Camera.main.nearClipPlane;
        screenshotCam.farClipPlane = Camera.main.farClipPlane;
        screenshotCam.stereoTargetEye = StereoTargetEyeMask.None;
        screenshotCam.targetDisplay = 3;

        camGo.AddComponent<CameraCapture>();