从 OpenGL C 程序生成视频
我有一个 C 程序,可以运行科学模拟并在 OpenGL 窗口中显示可视化结果。我想把这个可视化做成一个视频,最终会在 YouTube 上发布。
问题:从 C/OpenGL 程序制作视频的最佳方法是什么?
我过去的做法是使用屏幕捕获程序,但这非常耗费人力(必须启动/停止屏幕捕获程序,保存视频文件等......)。似乎应该有一种方法可以自动化从 C 程序中制作视频的过程。然后我可以让它运行一整夜,并在早上浏览 20 个视频,然后选择最好的一个放在 YouTube 上。
YouTube 推荐“640x480 分辨率的 MPEG4(Divx、Xvid)格式”。
我正在使用 GLUT 3.7.6_3,如果这有什么不同的话。如果有充分的理由,我可以更改窗口系统。
我运行的是 Windows (XP),因此更喜欢适用于 Windows 的答案,但 Linux 答案也可以。如果无法在 Windows 上轻松完成视频工作,我可以使用 Linux。我有一个朋友为视频的每一帧制作一个 .png 图像,然后在 Linux 上使用“mencoder”将它们拼接在一起。
I have a C program that runs a scientific simulation and displays a visualisation in an OpenGL window. I want to make this visualisation into a video, which will eventually go on YouTube.
Question: What's the best way to make a video from a C / OpenGL program?
The way I've done it in the past is to use a screen capture program, but this is very labour-intensive (have to start/stop the screen capture program, save the video file, etc...). It seems like there should be a way to automate the process of making a video from within the C program. Then I can leave it running overnight and have 20 videos to look through in the morning, and choose the best one to put on YouTube.
YouTube recommend "MPEG4 (Divx, Xvid) format at 640x480 resolution".
I'm using GLUT 3.7.6_3, if that makes a difference. I can change windowing system if there's a good reason.
I'm running Windows (XP), so would prefer answers that work on Windows, but Linux answers are ok too. I can use Linux if it's not possible to do the video stuff easily on Windows. I have a friend who makes a .png image for each frame of the video and then stitches them together using "mencoder" on Linux.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 glReadPixels 函数(请参阅 示例)
但是,如果您尝试显示的内容是由简单的对象(即球体、杆等)组成的,我会将每个帧“导出”到 POV-ray 文件,渲染这些文件,然后用这些图片制作视频。你将会达到更高的质量。
you can use the glReadPixels function (see example)
But if the stuff you are trying to display is made of simple objects (i.e. spheres, rods, etc..), I would "export" each frame into a POV-ray files, render these, and then make a video out of these pictures. you will reach a much higher quality like that.
使用 FRAPS 等第三方应用程序来为您完成这项工作。
他们网站上有视频样本。他们看起来不错。
编辑:
您可以执行一个工具,通过像
system("C:\screen_recorder_app.exe -params")
那样调用它来从 C 应用程序记录屏幕。检查camstudio,它有命令行版本。Use a 3rd party application like FRAPS to do the job for you.
They have video samples on the site. They seem good.
EDIT:
You could execute a tool to record the screen from your C application by calling it like
system("C:\screen_recorder_app.exe -params")
. Check camstudio, it has a command line version.