6

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.

Adam Nellis
  • 1,500
  • 1
  • 16
  • 23
  • 1
    Saving individual frames and doing the conversion to video in an external tool (mencoder is probably a good guess) sounds like the best solution to me. – Joachim Sauer Feb 08 '11 at 11:52
  • see bigger discussion on topic here: http://stackoverflow.com/questions/154730/capturing-video-out-of-an-opengl-window-in-windows – dm76 Feb 08 '11 at 12:26

2 Answers2

8

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.

dm76
  • 4,130
  • 8
  • 35
  • 46
  • Not that it matters too much for this particular instance, but using PBOs is more efficient than glReadPixels() as PBOs allow for DMA. – jay.lee Feb 13 '11 at 00:29
1

Use a 3rd party application like FRAPS to do the job for you.

Fraps can capture audio and video up to 2560x1600 with custom frame rates from 1 to 120 frames per second!

All movies are recorded in outstanding quality.

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.

karlphillip
  • 92,053
  • 36
  • 243
  • 426