Question

I am trying to render a video using ofxVideoRecorder on a headless server. The video renders correctly with a normal window, i.e.

ofSetupOpenGL(640,420, OF_WINDOW);

However, I get messed up frames (could not attach image) with a ofAppNoWindow.

ofAppNoWindow headless;
ofSetupOpenGL(&headless,640,420,OF_WINDOW);
ofRunApp(new testApp());

I have also tried, ofAppNoWindow headless; headless.setupOpenGL(640,420,OF_WINDOW); headless.runAppViaInfiniteLoop(new testApp());

I render objects in ofFbo in update method(). I tried saving image with and without headless window. The image saves correctly without headless window.

I think the issue is with FBO drawing incorrectly with ofApppNoWindow

This is the Fbo draw code

fbo.begin();
 ofClear( 255, 255, 255, 0 );
 ofEnableAlphaBlending();
 element.draw(); //element is my class
fbo.end();

Here is the screen capture code.

fbo.readToPixels(pixels);
pixels.setNumChannels(3);
vidRecorder.addFrame(pixels); //ofxVideoRecorder object

Would appreciate any help to enable near realtime video rendering and writing.

Was it helpful?

Solution 2

Answering my question. Thanks to @arturo at forums.openframeworks.co Hope this helps others.

The ofAppNoWindow does not create a OpenGL context. Hence OpenGL resources such as FBO are unavailable. Therefore you cannot really "read" the FBO. This can be verified by checking if the fbo is allocated (fbo.isAllocated() in openFrameworks).

OTHER TIPS

I had to setup an Openframeworks in a remote private server with GPU from Rapidswitch, and after struggling few hours I could make it work.

In order to have OpenGL you must have a X server running. Xvfb is not an option because it is not HW accelerated, so you will have to config your Xserver with no screen attached.

My system is Ubuntu 14.04.5 LTS

  • First, I checked that the GPU was present:

    $ lspci  | grep NVIDIA
    01:00.0 VGA compatible controller: NVIDIA Corporation GM107 [GeForce GTX 750 Ti] (rev a2)
    
  • Then, I've installed the nvidia drivers (I've chosen that version for no special reason, following a comment in a post).

    $ sudo apt-get install nvidia-346  nvidia-settings
    
  • I run sudo nvidia-xconfig and this is the top of my /etc/X11/xorg.conf

    # nvidia-xconfig: X configuration file generated by nvidia-xconfig
    # nvidia-xconfig: version 352.93  (buildmeister@swio-display-x86-rhel47-07)  Tue Apr  5 18:55:28 PDT 2016
    
  • Then, I modified /etc/X11/xorg.conf adding the AllowEmptyInitialConfiguration option:

    Section "Device"
        Identifier     "Device0"
        Driver         "nvidia"
        VendorName     "NVIDIA Corporation"
        Option         "AllowEmptyInitialConfiguration"
    EndSection
    
  • Finally, I could start my X server on display :0

    sudo /usr/bin/X :0

If everything was ok the command will launch the X server with HW acceleration. We can run glxinfo -display :0 | grep renderer to check that it is indeed using the GPU. This was my output:

$ glxinfo -display :0 | grep renderer
OpenGL renderer string: GeForce GTX 750 Ti/PCIe/SSE2

Finally, you just export your display export DISPLAY=:0 and run any OPENGL code. You can check that it is working using the toy example glxgears.

This is my output:

 $ glxgears
 Running synchronized to the vertical refresh.  
 The framerate should be approximately the same as the monitor refresh rate.
 63388 frames in 5.0 seconds = 12677.544 FPS
 63382 frames in 5.0 seconds = 12676.304 FPS
 ...

Now you're ready to run your OpenFrameworks projects. You don't need to make any change to the source code.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top