« RubyCocoa slides | Main | High-performance httpd components »
February 26, 2005
OpenGL -> Quicktime
After the Ruby meeting, I resumed work on a project I've been working on. I have an OpenGL window which I'm rendering text and graphics into, but wanted the capability to create a Quicktime movie from the contents of the window. This is more difficult than you'd think, there are a few things to keep track of.
First of all, there doesn't seem to be a simple Cocoa framework call that renders a movie from an OpenGL window or view. This means I have to come up with a scheme of grabbing images from the OpenGL frame buffer and stick them into a Quicktime object.
Quicktime uses a graphics handle called a GWorld for most of its rendering calls. So, I've been working on a way to grab the pixels from the Open GL frame buffer (glGetPixels()) with a fixed clock to enforce frame rate (since simple OpenGL calls can run much faster than 30 or 60fps), and then turn the pixels into a frame of video which is then added to my GWorld, rendering it as a new frame in the movie.
I've been working on this on and off for a couple days, it's the hardest OS X coding task I've tried so far. I know I can get it to work, but I won't know how well it performs until it's done. It feels like this should't be a huge cpu drain, and if there are problems, I can always use my new friends Shark and OpenGL Profiler to help me out. Hopefully, I'll have this figured out and polished by next week.
Once the movie creation is working, then I'm going to hook in embedding of audio tracks with the video. This lets me add background music to the movies. I'm working on a prototype that lets me move the audio offsets around and draw the audio clip on a movie timeline window (think non-linear editing like FCP), so that will get polished and integrated.
The end result will be a framework that lets me render graphics/video/text to my OpenGL view, select tracks to play in the background, and render a completed Quicktime movie.
Posted by djb at February 26, 2005 04:14 PM