Problems with recording ofApp "output"

Hi everyone, :hand:
hope this is the right place to post this.
I’m new to open frameworks and have just started to play around with it a bit. I’m working on a video synthesizer based on the one from the “openFrameworks essentials” book by Denis Perevalov. I’d like to add the possibility to record the created video material and am having problems with that.
I’m trying to use the ofxVideoRecorder addon and this is my code: (pressing the r key toggles the state of bRecording)
in setup():

ofSetFrameRate(60);
ofSetLogLevel(OF_LOG_VERBOSE);
//    vidRecorder.setFfmpegLocation(ofFilePath::getAbsolutePath("ffmpeg"));
// use this is you have ffmpeg installed in your data folder
fileName = "testMovie";
fileExt = ".mov"; // ffmpeg uses the extension to determine the container type. run 'ffmpeg -formats' to see supported formats

// override the default codecs if you like
// run 'ffmpeg -codecs' to find out what your implementation supports (or -formats on some older versions)
vidRecorder.setVideoCodec("mpeg4");
vidRecorder.setVideoBitrate("800k");
vidRecorder.setAudioCodec("mp3");
vidRecorder.setAudioBitrate("192k");

ofAddListener(vidRecorder.outputFileCompleteEvent, this, &ofApp::recordingComplete);

bRecording = false;

screenFbo.allocate(1920, 1080, GL_RGB);
myPixels.allocate(1920, 1080, OF_IMAGE_COLOR );

and this in update():

 if(bRecording)
{
    screenFbo.readToPixels(myPixels);
    bool success = vidRecorder.addFrame(myPixels);
    if (!success) {
        ofLogWarning("This frame was not added!");
    }
}

// Check if the video recorder encountered any error while writing video frame or audio smaples.
if (vidRecorder.hasVideoError()) {
    ofLogWarning("The video recorder failed to write some frames!");
}

if (vidRecorder.hasAudioError()) {
    ofLogWarning("The video recorder failed to write some audio samples!");
}

in the draw() function:

screenFbo.begin();

//all my draw functions go here

screenFbo.end();
screenFbo.draw(0,0);

The recording does sort of work but I get weird artifacts at the bottom of the screen, as you can see in the following screenshot…


Any ideas how I can get rid of that?
Is my approach right? where should I be adding the frames?
Is there a way to improve the quality of the recording?
Is there another “typical” way to approach a problem like this with openFrameworks or does it really put the focus on interactive projects only?

Thanks a lot in advance!!! :grin:

i have read somewhere that people use a binding to http://www.imagemagick.org somehow.

there is also the option to record an image sequence.

i have not been able to get ofxVideoRecorder to work either.

ah ok, thanks! I’ll give that a look :slightly_smiling:

what happens if you save the fbo as an image does the artifact appear? it will help determine if its something with the fbo or ofxvideorecorder. My first guess would be that the allocation sizes are off and the fbo has some junk hanging around. Are you using ofClear(255) inside your draw phase to clear the fbo each time?

Hi thanks for replying! :slight_smile:
When I save the the fbo as an image with the following code, I still get the artifacts. They seem to be taken from my screen…
screenFbo.readToPixels(myPixels); ofImage img; img.setFromPixels(myPixels); img.save("fboTest.png");

Where should I use ofClear(255)? I inserted it at the beginning of draw() and that didn’t change anything.