c# - 如何在 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();
}
}
解决方案
信不信由你,Unity Video Capture 文档就包含这样的功能。试试这个!https://docs.unity3d.com/560/Documentation/ScriptReference/VR.WSA.WebCam.VideoCapture.html
推荐阅读
- xcode - Xcode XCUITest XCUICoordinate 不适用于按下和/或拖动
- c# - C# 从另一个表单创建类的新实例
- c# - 如何获取xml文件的编码?
- javascript - 为什么渲染没有返回任何内容?
- mongodb - 谷歌云kubernetes引擎外部ip
- jasperserver - JasperServer 内容查看引发索引超出范围异常
- python - 如何在我的 python discord 音乐机器人中创建断开连接计时器?
- python - 使用不同的参数运行实验,有效地保存输出
- sql-server - 聚合函数中对分区的排序结果
- php - 在 php 中运行两个选择查询并将其编码为 json 格式