ofxVideoRecorder horizontal lines

Hello, I’m currently trying to use ofxVideoRecorder to record the video of an OF application. The only thing that I get on the screen until now are a bunch of horizontal lines moving from top to bottom, they look like this:
no
It should look like this:
Screenshot%20from%202018-03-17%2017-59-10

Clearly I’m doing something wrong setting the video recorder, but i do not know what. I’m using the ofxVideoRecorder version from the Entropy project, as it looks like the more up to date.

these are my settings:

    finalFbo.allocate( ofGetWidth(),ofGetHeight(), GL_RGB);
    finalFbo.begin();
    ofClear(0, 0, 0, 0);
    finalFbo.end();

    ofSetFrameRate(60);
    ofSetLogLevel(OF_LOG_VERBOSE);

    fileName = "testMovie";
    fileExt = ".mov";

    vidRecorder.setVideoCodec("mpeg4");
    vidRecorder.setVideoBitrate("800k");

    ofAddListener(vidRecorder.outputFileCompleteEvent, this, &ofApp::recordingComplete);
    bRecording = false;
    ofEnableAlphaBlending();

This is my update method

    finalFbo.begin();
    ofClear(0, 0, 0, 255);
    SM.draw();  // SM is an object that simply draw an FBO
    finalFbo.end();

and this is my draw method

void ofApp::draw(){
    if(bRecording){ // I'm toggling this with the keyboard to start and stop recording
        ofPixels pixels; // this is used to store the pixels read from the fbo
        finalFbo.readToPixels(pixels);
        bool success = vidRecorder.addFrame(pixels);
        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!");
    }

    // draw the FBO
    ofSetColor(255);
    finalFbo.draw(0, 0);
}

And this is the message that I receive shortly before closing the recorder:

frame=  671 fps= 62 q=31.0 size=   51629kB time=00:00:22.33 bitrate=18937.8kbits/s speed=2.08x    
frame=  702 fps= 62 q=31.0 size=   53979kB time=00:00:23.36 bitrate=18924.0kbits/s speed=2.08x    
frame=  734 fps= 62 q=31.0 size=   56957kB time=00:00:24.43 bitrate=19096.4kbits/s speed=2.08x    
frame=  765 fps= 62 q=31.0 size=   59925kB time=00:00:25.46 bitrate=19276.2kbits/s speed=2.07x    
frame=  797 fps= 62 q=31.0 size=   62988kB time=00:00:26.53 bitrate=19447.0kbits/s speed=2.08x    
frame=  829 fps= 62 q=24.8 size=   66069kB time=00:00:27.60 bitrate=19610.0kbits/s speed=2.08x    
frame=  860 fps= 62 q=31.0 size=   68881kB time=00:00:28.63 bitrate=19706.8kbits/s speed=2.08x    
frame=  892 fps= 62 q=31.0 size=   71589kB time=00:00:29.70 bitrate=19746.0kbits/s speed=2.08x    
frame=  923 fps= 62 q=31.0 size=   74089kB time=00:00:30.73 bitrate=19748.4kbits/s speed=2.08x    
frame=  954 fps= 62 q=31.0 size=   76587kB time=00:00:31.76 bitrate=19750.2kbits/s speed=2.08x    
frame=  985 fps= 62 q=24.8 size=   79024kB time=00:00:32.80 bitrate=19736.8kbits/s speed=2.07x    
45
[warning] ofxVideoDataWriterThread: 18:15:49:102 - The thread is not running anymore let's get out of here!
[verbose] ofxVideoDataWriterThread: closing pipe: /media/data/Sources/OF/my-current-master/apps/myApps/visualsMechatronica/bin/data/ofxvrpipe0
The recoded video file is now complete.
[rawvideo @ 0x558ac8c3a0e0] Invalid buffer size, packet size 4020960 < expected frame_size 5697975
Error while decoding stream #0:0: Invalid argument
frame=  992 fps= 62 q=31.0 Lsize=   79525kB time=00:00:33.03 bitrate=19721.5kbits/s speed=2.07x    
video:79519kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.007167%

This sounds suspicious “Invalid buffer size, packet size 4020960 < expected frame_size 5697975”.
Any idea how to fix this?

I think that the main problem was the window that was too big and the recorder can not catch up. Changing the dimension of the window from 1920x1024 to 1024x768 remove the lines and produce better results.
Also setting the codec to

vidRecorder.setVideoCodec("libx264");

and increasing the bitrate

vidRecorder.setVideoBitrate("5000k");

improved the quality overall. Although it’s far from good.

Hello Edapx!
Are you on OSX? I’ve never tried but might work pretty well a Syphon Recorder solution.

1 Like

Hello @charli_e, thanks for your suggestion. I’m working on linux at the moment because I need a good graphics card and that one that I have on the mac one is not powerful enough. Setting up screen dimension a bit smaller than what I was doing and tuning the ffmpeg setting led me to some acceptable results. I have extracted the code needed to handle ofxVideoRecorder and the setting that I’m using in a separate class her https://github.com/edap/visualsMechatronica/blob/master/src/Recorder.cpp, just in case you are interested or someone else will face the same problem.

Another tool you can try to record the screen is https://github.com/nullkey/glc/wiki

I used that to record my OF sketches, and the results were better than with ffmpeg in my case.

Thanks Abe, I will have a look at this.