Problems using VideoCapture

Hi,

I’m trying to record a video using VideoCapture. I use the code from documentation and I’m getting the following error when it calls StopRecordingAsync:
The VideoCapture is not in the correct state to stop recording video.
I’ve both the webcam and microphone capabilities active. I actually implemented PhotoCapture first, and it works as intended.

Checking VideoCaptureResult value and is returning false on the method OnStoppedRecordingVideo.

I’m running on the Editor (I don’t have with me the Hololens to test it on the device), using Unity 2020.3.33f1
I also tested in Unity 2021.3.0f1, Unity 2022.1.0b16 and I’m getting the same error.

I also tried in 2019.4.36f1 but in this version, it didn’t start the capture. I read something in the documentation that older versions of Unity VideoCapture didn’t work on Editor.

Do I need to activate anything more? I’m missing something?

Thanks

hi!
did you find a solution for that?! i am having the same problem. it starts and stops the video after the preferred time but gives the error like 200 times. doesnt save the video as well… You would be helping me so much if you had any idea!
best wishes

I have the same issue

You can resolve this issue by using a global bool variable. i.e isRecording.
use it like this

if (Time.time > m_stopRecordingTimer)
{
if (isRecording)
{
m_VideoCapture.StopRecordingAsync(OnStoppedRecordingVideo);
isRecording = false;
}

    }

you can make the isRecording variable again true while starting recording.

Hi, you can also learn how to record screen in this tutorial.