我需要在 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();
}
}
答案 0 :(得分:0)
信不信由你,Unity Video Capture 文档就包含这样一个功能。试试这个! https://docs.unity3d.com/560/Documentation/ScriptReference/VR.WSA.WebCam.VideoCapture.html