[ODE] Capturing a window , making a movie

David Whittaker david at csworkbench.com
Mon Apr 14 09:57:02 2003


If it's a drawstuff project, there's a ctrl-something (it's on the console
screen) you can push to output a sequence of ppm files, which can the be
converted to video with an external program.  I suggest ffmpeg.

If not, you can do the same thing using the glReadPixels command.  It
returns almost exactly the ppm format, except you _may_ need to swap the
red and blue color components (I think it's backwards for bmp, but right
for ppm, but I could be wrong), and skip the every fourth byte (alpha). 
The ppm header for a 640x480 picture with 8 bits per pixel looks like:
P3
640 480
255
...640*480*3 bytes of binary picture data from glReadPixels...EOF

Alternatively, you can use P6 and output the values in plain text (space
separated decimal integers), but disk access is slow.

If you want the program to render directly into a movie without the
intermediate step, then you have a whole other problem.  You still use
glReadPixels to get your data, but then you have to run it through a codec
of some sort.  In my experience, all the mpeg codecs out there are some
combination of too slow, undocumented, or produce files that are too
large, even with good compression settings.  It seems the least of the
evils, though, is libavcodec, part of the ffmpeg project.  I believe this
is a cross-platform solution (I know it works on Linux).  It's problem is
a severe lack of documentation, though there is a test program to get you
started, it's quite fast, and can be tweaked to give the exact bitrate
(i.e. a set number of bytes per second of video) you want.  You might also
look into Dali.  It's also cross-platform, but suffers from Large File
Syndrome on Linux (don't ask me why... I might have had a bug, but it
worked fine on Windows, just made 4x larger files on Linux), and you have
to do a lot more work yourself.  libavcodec is almost as simple as setting
up the parameters and sending it frames whenever you feel like it
(almost... I think you have to do a YUV colorspace conversion in there
somewhere).  Dali just gives you the functions to go through every step of
the mpeg creation process, though there is ample documentation to tell you
what those steps are.

Hope that helps,
David

> Hi all,
>  I want to capture an opengl window into a movie, I
> use windows (but if you have linux tips please send
> them too), How can I capture that window and make a
> movie?
>
> Thanks,
> Shaul
>
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Tax Center - File online, calculators, forms, and more
> http://tax.yahoo.com
> _______________________________________________
> ODE mailing list
> ODE@q12.org
> http://q12.org/mailman/listinfo/ode