简体   繁体   English

如何在 Unity 上从网络摄像头捕获视频

[英]How to capture video from webcam on Unity

I need to capture a video from the webcam while my Unity application is running.我需要在 Unity 应用程序运行时从网络摄像头捕获视频。 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();
    }
}

Believe it or not, the Unity Video Capture documentation contains just such a function.信不信由你,Unity Video Capture 文档包含这样的 function。 Try this out!试试这个! https://docs.unity3d.com/560/Documentation/ScriptReference/VR.WSA.WebCam.VideoCapture.html https://docs.unity3d.com/560/Documentation/ScriptReference/VR.WSA.WebCam.VideoCapture.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM