graps : capture OpenGL Frames

graps is a tool for grabing frames from openGL application, without editing the application. graps can be used for making video from an opengl application. graps can also be useful for monitoring fps of opengl application.

graps writes the glReadPixel data to file on each glXSwapBuffers call. graps uses the power of LD_PRELOAD to run without modifying the application.

graps is dirty fraps alternative for screen and realtime video capturing and fps monitoring ( hence benchmarking ).

graps can be downloaded from here. See readme.txt for help.

Update1 [08.09.2007] :
- recording to video [ using mencoder ]. Thanks to Mineral for hints (see comments).
- grapsctl, separated frame capturing and writing to image/video.
- bug fixes : ppm header (thanks matt) and width*width (thanks Mineral).
- graps v0.2 release.

14 Responses to “graps : capture OpenGL Frames”

  1. kopos Says:

    nice…
    so its an alternative to fraps?! cool :D how does it compare in performance wrt fraps?

  2. smr Says:

    vs fraps
    @kopos
    i never tried fraps. but i guess nowhere close to fraps. in graps i’m using a hack to make it work. the point is that its small and it works.

  3. chetan Says:

    images created upside down
    Hi,

    I tried using graps , but the images formed are upside-down !!!
    Where may be the fault ?

  4. smr Says:

    Re:
    Yeah… by default graps creates upside down images. coz thats what glReadPixel gives. Correcting this in realtime might cause fps to drop a little.
    A flag can be enabled in graps config file to do this correction in realtime.

  5. Luca Adesso Says:

    keypress activation
    it’s possible to have it activated by a keypress or combination of key?

    I’d like to use graps to make video in World of Warcraft, but not of everything.
    I use WoW with cedega-engige, using the opengl so i think it’s possible to use it.
    Maybe something like > /dev/null till you choose to grab everything and then again > /devnull

  6. smr Says:

    Re:
    @Luca
    it can be easily done using some IPC. another program talks to graps using fifo etc. or simple file locking will work. i wont be able to implement it now.. little busy. u can try it yourself.

  7. ORB Says:

    Re:
    hey this works, nice,

    i was thinking if u could also include
    some shell script 2 convert those frames 2 a single video
    can b a post job and user’s wish dependant

  8. Matt Says:

    Re:
    It works great, I’ve coded a little scripts that does ‘convert $input -format “tga” -flip $output” on each ppm file and then I use mencoder to create a video.
    Just what I needed =]

    BTW, there’s a bug when creating the ppm file. The maximum color value should be 255 not 254 (when writing the ppm header).

  9. Mineral Says:

    Project is dead? I found similar project: wiki.vislab.usyd.edu.au/moinwiki/VideoCreationGuide (file glxdump.c), but your is more cool :)

    Idea grab glXSwapBuffers is great! It can’t skip any frame! Low fps, but all frames will go via graps!

    I was need write screensaver, but uncompressed images fast wasted my hdd… So I patched this for direct video encoding :)

    At first, I found bug, see “grap.width*grap.width*3″ at sources :)
    Next, file open, which write images, moved to “graps_firsttime”, and changed to constant name, so all frames go to single file. And removed header writing + file closing. As result I have single file of raw RGB24 video :)

    Need patch? Can send to you.

    Make fifo:
    $ mkfifo videopipe
    where “videopipe” - is file, which white graps

    Then start video encoder, like this:
    $ mencoder videopipe -rawvideo w=1000:h=700:fps=25:format=RGB24 -demuxer rawvideo -o output.avi -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=800

    and start any openGL software, for example, screensaver:
    $ bash run.sh kxsrun flyingtoasters — -geometry 1000×700

    When openGL application stopped, video encoding will stop too. Enjoy :)

    Very important make similar sizes at mencoder and at window size.

  10. Can Kavakl?o?lu Says:

    Many thanks for great explanation. Was looking for this trick for quite a time now.

    One note, in the readme file it says the preferences file is called “~/grapsrc”. But the code is looking for “~/.grapsrc” with the dot . I guess you need to fix one of them.

    I have used parts of your code and put a reference to your page from this project’s at:

    http://robot.cmpe.boun.edu.tr/~ckavaklioglu/usarlinuxhook

    Thanks again.
    Can Kavaklioglu

  11. Can Kavaklioglu Says:

    Hello,

    I will be using the flip function. I guess I found a bug. If the

    j2 = image_height - j;

    line is left as it is, the top row of the image does not get flipped. I think it should be

    j2 = image_height - j -1;

    At least this is the case in my code.

    Thanks again.
    Can Kavaklioglu

  12. Doug Says:

    I was hopeful after capturing glxgears worked but when I try to capture from a Java3D window all I get is static. I can capture using glxdump but the performance is lacking and there are slight amounts of jumping to the video.

    Has anybody and ideas about this or even seen this scenario( native GL app works, Java3D does not )?

  13. Doug Says:

    Correction to the above entry: By setting the capture frame size to the exact size of the Java3D frame, the recording was clear as a bell. Sweet.

  14. Doug Says:

    what would be really cool is a way to direct the video stream out a 1394 port in DV format. I’m thinking screencasting here and capturing the video on a HD camcorder. My Sony HDR-HC5 only captures from a DV formatted Fireware/i.Link/IEEE1394 link.

Leave a Reply