c# - 如何以 60fps 制作离线 png 序列记录器?
问题描述
我想以非实时(离线)的方式捕获 Unity 相机的 60fps、4k 图像序列。
到目前为止,我能够成功捕获每一帧,但我无法弄清楚如何使其离线并符合 60fps。
我正在捕捉这样的帧:
// get main camera and manually render scene into rt
Camera camera = this.GetComponent<Camera>(); // NOTE: added because there was no reference to camera in original script; must add this script to Camera
camera.targetTexture = renderTexture;
camera.Render();
this.lastRenderTime = Time.realtimeSinceStartup;
// read pixels will read from the currently active render texture so make our offscreen
// render texture active and then read the pixels
RenderTexture.active = renderTexture;
screenShot.ReadPixels(rect, 0, 0);
// reset active camera texture and render texture
camera.targetTexture = null;
RenderTexture.active = null;
// get our unique filename
string filename = uniqueFilename((int)rect.width, (int)rect.height);
// pull in our file header/data bytes for the specified image format (has to be done from main thread)
byte[] fileHeader = null;
byte[] fileData = null;
// create new thread to save the image to file (only operation that can be done in background)
new System.Threading.Thread(() =>
{
// create file and write optional header with image bytes
var f = System.IO.File.Create(filename);
if (fileHeader != null) f.Write(fileHeader, 0, fileHeader.Length);
f.Write(fileData, 0, fileData.Length);
f.Close();
Debug.Log(string.Format("Wrote screenshot {0} of size {1}", filename, fileData.Length));
}).Start();
有人可以指出我正确的方向吗?
解决方案
推荐阅读
- apache - Apache 将所有发布的数据发送到 Graylog
- android - 将数字与 RatingBar 对齐 - Android
- reactjs - 如何模拟 qraphQL/Apollo 查询响应以在 redux 中测试 action-creator?
- java - 是否有一种可能在没有警告的情况下传递可选参数?
- vhdl - VHDL 有符号值
- django - Django 应用程序在本地工作,但在 GCP 上部署说 500 服务器错误,“ImportError:无法导入设置”
- jquery - 更改具有类的下一个 div 的 css
- swift - 错误:无法使用类型为“(字符串)”RxSwift 的参数列表调用“onNext”
- c# - 字典中的响应没有“GetEnumerator”的定义
- javascript - csrf_token() 不会被令牌值替换在与 laravel 的反应中