Unity:从设备摄像头录制视频 [英] Unity: Record video from device camera

查看:1668
本文介绍了Unity:从设备摄像头录制视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要一个插件或一个库,或者一种从设备摄像机统一(独立于Windows)录制视频(确保声音)的方法.

目前,我可以使用此相机拍摄屏幕截图.有人说我可以拍摄许多屏幕截图并将其转换为一个视频文件.

我在素材资源商店中找到了一个名为相机拍摄

除了Windows,我想要类似的东西.

现在,我正在使用一个库,用于从统一摄像机(统一内部的虚拟摄像机)捕获视频.我正在我的应用程序中未显示的画布上预览相机供稿,并使用该库来录制此视频.

这可能解决了我的问题,但是发现另一个问题,我需要录制麦克风语音才能将此音频添加到录制的视频中.

因此,现在我正在从库中录制视频(不录制声音),并使用另一个代码来录制来自麦克风的语音,录制完成后,我将这两个文件合并在一起以获得所需的文件.

再次出现新问题.合并过程(合并和压缩)需要很长时间(超过记录时间的10%),这会导致很多问题.

所以我需要另一种解决方案,并且更喜欢像上面的插件一样.

我在编辑器和构建中都尝试了Unity VideoCapture Example.在统一编辑器中,该应用程序运行时没有错误,但没有输入此函数"VideoCapture.CreateAsync()",因为他们说它无法与该编辑器一起使用.

当我尝试构建为Windows独立构建时,它给了我这个错误:资产/脚本/控制器/其他/VideoCaptureExample.cs(4,26):错误CS0234:类型或名称空间名称'WebCam'并不正确名称空间'UnityEngine.XR.WSA'中存在.您是否缺少程序集引用?"

解决方案

在搜索并处理此问题大约2个月后,我发现Camera Shoot

I want something like it but for windows.

Edit 1:

Now I am using a library that captures video from unity camera (virtual camera inside unity). I am previewing my camera feed on a canvas that is not shown in my application and I use this library to record this video.

This may solve my problem, but another problem was found that I need to record microphone voice to add this audio to the recorded video.

So now I am recording video (without sound) from the library, and record voice from microphone using another code, and after finish recording, I merge these 2 files together to get my desired file.

A new problem appears again. The merging process (muxing and compressing) takes a long time (more than 10% of the recorded time) which makes leads to many issues.

So I need another solution and prefered to be a plugin like the one above.

Edit 2:

I tried Unity VideoCapture Example in both editor and build. In unity editor, the application runs without errors but it didn't enter to this function "VideoCapture.CreateAsync()", as they said it didn't work with the editor.

When I tried to build to windows standalone build, it gives me this error : "Assets/Scripts/Controllers/Other/VideoCaptureExample.cs(4,26): error CS0234: The type or namespace name 'WebCam' does not exist in the namespace 'UnityEngine.XR.WSA'. Are you missing an assembly reference?"

解决方案

After searching and working on this issue for about 2 months, I found Capture Manager SDK.

It is for windows but the author has 2 demos for unity to record screenplay and not the camera feed. I asked him if it can capture video from the camera and he made a unity example that do what I want.

I have tested the unity demo and it works as expected.

这篇关于Unity:从设备摄像头录制视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆