我正在尝试使用Unity的NatCorder资产获取视频帧。这可能吗?我可以使用NatCorder通过以下方式录制视频:
WebCamTexture webCam;
webCam.Play();
NatCorder.StartRecording(Configuration.Screen, OnVideo);
//Note: OnVideo is a separate function that natcorder calls after taking the video
,然后在我的更新功能中:
if (NatCorder.IsRecording && cameraTexture.didUpdateThisFrame) {
// Acquire an encoder frame from NatCorder
var frame = NatCorder.AcquireFrame();
// Blit the current camera preview frame to the encoder frame
Graphics.Blit(cameraTexture, frame);
// Commit the frame to NatCorder for encoding
NatCorder.CommitFrame(frame);
}
但我的目标是拍摄每帧并将其编码为png或jpg文件,而不是创建视频。这可能吗,还是有更好的方法来实现呢?