'How to capture video from webcam on Unity
I need to capture a video from the webcam while my Unity application is running. Right now I can get the webcam and see the image with this code, but how I capture the video and save it to the disk?
public class captureVideo : MonoBehaviour
{
[SerializeField]
private UnityEngine.UI.RawImage _rawImage;
void Start()
{
WebCamDevice[] devices = WebCamTexture.devices;
// for debugging purposes, prints available devices to the console
for (int i = 0; i < devices.Length; i++)
{
print("Webcam available: " + devices[i].name);
}
WebCamTexture tex = new WebCamTexture(devices[0].name);
this._rawImage.texture = tex;
tex.Play();
}
}
Solution 1:[1]
Believe it or not, the Unity Video Capture documentation contains just such a function. Try this out! https://docs.unity3d.com/560/Documentation/ScriptReference/VR.WSA.WebCam.VideoCapture.html
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Roger |
