Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

What are some of the preferred methods or libraries for creating video from an OpenGL graphics simulation?

For example, I want to create a visualization(video) of an N-Body gravity simulation by rendering non-real-time OpenGL frames.

The simulation is already coded, I just don't know how to convert it to video.

EDIT: I am also interested in providing the described functionality: The user can adjust parameters including the time step between captured frames and then initiate the simulation. The user waits for the simulation to complete, and then can watch the results. The user is able to increase or decrease the playback speed of the simulation whereas in slow motion, more frames are used i.e., you see higher resolution time steps, and when the speed is increased, you see lower resolution time steps at a higher rate, but the frames per second flashing on the screen is constant.

share|improve this question
1  
Have you tried outputting the raw OpenGL framebuffers as pngs using glReadPixels and libpng? If you do that you can use something like ffmpeg to generate a video for you. –  Mokosha Nov 2 '13 at 0:01
1  
FRAPS can make movies from DX or OGL applications –  srand Nov 2 '13 at 0:25
add comment

1 Answer

up vote 3 down vote accepted

The easy way: Use glReadPixels on the framebuffer every time you are about to swap, then feed these frames into libavcodec / libavformat (ffmpeg).


If you would like a video larger than the screen, there is the hard way:

Use an FBO to render your frames into a texture, then retrieve your data through glGetTexImage and feed it to your video encoder.

(If performance is absolutely critical for some reason, instead of glGetTexImage, you would ask the graphics driver to do async DMA uploads using a PBO, and use multiple buffers to allow one image to copy & encode while the next renders)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.