Saving video in OF


Using the FOBS video library that’s been incorporated into Linux, I’ve written a basic application that demonstrates how to save video from an OF app. It uses the FFmpeg encoder, so you will have to get familiar with it if you want to alter the encoding settings.

Currently this demo only saves video, not audio, even though there’s a function to set the audio parameters.

I copied the graphics example as the output of the Draw() function. Replace this with your own code.

Compile, and then run the program. Hit the ‘s’ key once to start saving and encoding video. A video file will be saved in the same directory as the app.

You can change the name of the file by replacing ‘savefile.avi’ in the line:
savemovie = new ofRecordMovie(“savefile.avi”);

You can change the codec and format of the saved file in the following lines:
error = savemovie->chooseFormat(“avi”);
error = savemovie->chooseVideoCodec(1024,768,2000.0, 15, “msmpeg4”);

The parameters for chooseVideoCodec are:
(width, height, bit rate, frames per second, codec)

To date I’ve successfully tested these combinations:
format “avi”, codec = “msmpeg4”
format “mp4”, codec = “mpeg4”
format “mov”, codec = “h263p”

I also got xvid and x264 to work, but these require extra compilation and changes to the basic OF framework and are not LGPL in license so I’ve not included them here for the moment.

download the example (for OF 0.02) here.

One problem that I have is that my code only works if I use the static ffmpeg libs.
This is already set in the above Makefile, so you won’t notice it however.

Let me know of any improvements, bugs etc…