I’ve got to record video from webcam using the add-on ofxQtVideoSaver. This add-on takes in an unsigned char* frameData and stores it in file. This is working nicely.
In my application I have several animations happening over the original camera image. This animatios are both 2D and 3D objects that are drawn in the main application window, launched by ofRunApp.
What I need is to be able to record video along with the animations. For example, if there was any way I could retrieve the framedata from the main window, my problem would be solved, but I found no such thing.
Any suggestions please?
You can use an ofImage, member of your ofRunApp and then call
That will give you the current render, then save it using ofQtVideoSaver, remember to set the frameRate according to your app’s framerate:
Thanks for the answer, that was something that I actually tried. The problem is that the grabScreen method is really heavy and recording video using that method drops the framerate from 30fps to 8fps. Any idea of how to go around that ?
Try add syphon to your project. Instead of drawing to the screen draw into an FBO and the use syphon to publish the FBO texture. You can then use syphon recorder to record the output.
I just want to second Syphon, it’s an excellent tool for doing what you’re talking about (among many other things). I don’t have any hard numbers available for how much faster it is than the pure OF approach (i.e. grabbing a pixels from an ofImage) but it’s faster. Another option is to render to an FBO, copy it back, and then thread out saving the pixels to disk so that your main animation thread can continue unimpeded.