@DerGav wrote:
Hi everyone,
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 ofbRecording
)
insetup()
: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!!!
Posts: 5
Participants: 3