首页 > 解决方案 > 如何在 Unity 上从网络摄像头捕获视频

问题描述

我需要在 Unity 应用程序运行时从网络摄像头捕获视频。现在我可以使用此代码获取网络摄像头并查看图像,但是如何捕获视频并将其保存到磁盘?

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();
    }
}

标签: c#unity3d

解决方案


信不信由你,Unity Video Capture 文档就包含这样的功能。试试这个!https://docs.unity3d.com/560/Documentation/ScriptReference/VR.WSA.WebCam.VideoCapture.html


推荐阅读