Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Produce video from OpenGL C program

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.

like image 250
Adam Nellis Avatar asked Feb 08 '11 11:02

Adam Nellis


1 Answers

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.

like image 170
dm76 Avatar answered Sep 29 '22 03:09

dm76