保存ARCore视频以进行进一步处理?

时间:2017-09-15 13:48:32

标签: video video-encoding arcore

是否有能够保存ARCore输出以进行进一步处理的视频标准?就像在实际视频内容之外编码世界信息一样。

1 个答案:

答案 0 :(得分:0)

取决于您如何使用它。如果您正在使用Unity3D或Unreal,则可能。

Unity例如有RenderTexture。请查看以下教程以创建rendertexture:

https://www.youtube.com/watch?v=pA7ZC8owaeo

运行脚本并在其更新循环中使用以下代码:

int i = 0; // in Start()

int width = Screen.width;
int height = Screen.height;
Texture2D tex = new Texture2D(width, height, TextureFormat.RGB24, false);

// Read screen contents into the texture
tex.ReadPixels(new Rect(0, 0, width, height), 0, 0);
tex.Apply();

// Encode texture into PNG
byte[] bytes = tex.EncodeToPNG();
File.WriteAllBytes(Application.dataPath + "/../pic" + i + ".png", bytes);
i++;

以上代码来自here

现在您可以使用ffmpeg使用以下命令将这些PNG转换为MP4文件:

ffmpeg -r 60 -f image2 -s 1920x1080 -i pic%04d.png -vcodec libx264 -crf 25  -pix_fmt yuv420p test.mp4

希望有所帮助。