在视频中捕获 openGL 图形
我已经编写了一个 openGL 应用程序,并希望生成 Glut 窗口上显示的图形的视频。你知道该怎么做吗?
从上一个问题来看,我知道一种可能的解决方案是使用 glReadPixels 获取由 openGL 渲染的帧,然后使用 FFmpeg 库制作视频。我真的不知道如何使用 FFmpeg,所以我不确定如何编写一个获取帧并输出视频的程序。尽管原始问题中的链接已损坏,但我发现这个示例< /a> 视频编码,这可能对任何试图提供帮助的人有用。
两个问题:
- 如何使用 FFmpeg 编写一个获取帧并输出视频的程序?
- 我的应用程序是用 OCaml 编写的,因此我使用
lablgl
和lablglut
。关于在这种情况下如何实施 FFmpeg 的想法有什么想法吗?
I have written an openGL application and would like to produce a video of the graphics shown on the Glut window. Do you know how to do it?
From a previous question at SO, I know that one possible solution is to use glReadPixels to get the frames that were rendered by openGL and then use the FFmpeg library to produce the video. I don't really know how to use FFmpeg, so I'm not sure how I could write a program which takes the frames and outputs the video. Although the link is broken in the original question, I've found this example of video encoding, that may be useful for anyone trying to help.
Two questions:
- How can I use FFmpeg to write a program which takes frames and outputs a video?
- My application is written in OCaml, so I'm using
lablgl
andlablglut
. Any ideas on how the FFmpeg ideas could be implemented in that case?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以使用 libpng 将框架写入单个 PNG 文件,然后使用以下命令-line
ffmpeg
工具将其编码为视频。You can use libpng to write your frames to individual PNG files, then use the command-line
ffmpeg
tool to encode this into a video.png 答案的变体:输出为 bmp。在Paint中创建一个相同大小的白色图像(或Mac上可用的任何图像),用记事本打开它,隔离文件头(对于800 * 600,它是42 4D 36 F9 15 00 00 00 00 00 36 00 00 00 28 00 -00 00 20 03 00 00 58 02 00 00 01 00 18 00 00 00-00 00 00 F9 15 00 00 00-00 00 00 00 00 00 00 00 00 00 00 00 00 00 27 ), 附加 gl 的结果读取像素,刷新, 关闭。
是的,文件很多,但通常不是问题,因为大多数 openGL 应用程序不会过多使用硬盘。
(我知道,这很脏,但这是最简单的实现方法 - 我在火车上做过一次,没有任何文档)
A variation on the png answser : output to bmp. Create a white image of the same size in Paint (or whatever is available on mac), open it with notepad, isolate the file header (for 800*600 it's 42 4D 36 F9 15 00 00 00 00 00 36 00 00 00 28 00-00 00 20 03 00 00 58 02 00 00 01 00 18 00 00 00-00 00 00 F9 15 00 00 00-00 00 00 00 00 00 00 00 00 00 00 00 00 00 27 ), append results of glReadPixels, flush, close.
So yeah, lots of files, but usually not a problem since most openGL apps don't use the hard drive too much.
( I know, it's quite dirty, but it's the simplest method to implement - I did it on the train once, without any documentation )
要捕获演示视频,最好的方法可能是 fraps
To capture video for a demo the best way is probably fraps