Render openGL screen to video file

Hi,

i have an oF project in which I render a glsl fragment shader -> screen via the ofxFX addon.

Now, I want to render the screen -> video file, either via

  • grabbing screen pixels and writing to a video file
  • or directly writing gpu buffer to a video file

I have tried the ofxVideoRecorder addon for grabbing the screen pixels each frame and writing to a video file. But the output is not correct. It shows a portion of the image repeated and in wrong colors. Probably because of the addon’s limitation of 8bit rgb while the fragment shader uses 32bit rgba.

  1. Any chance to do this in oF
  2. What would be the traditional way to render fragment shaders or general openGL content to video files (outside the oF world)

I’ve done oF app to video in multiple ways,

  1. If quality is important and it’s ok to not need to do it in real time, I usually export each frame as a still and then stitch together the image sequence. Only point to note here is that use ofGetFrameNum() as your time scale instead of elapsed time or similar as this process cannot handle real time stuff. (But it’s great to do 8k renders and stitch them together later). I generally draw everything to an FBO and then export that FBO as an image.

  2. Straight up Quick Time screen capture. Easy. Fast. Real time. Not always the best quality though.

  3. I’ve also done Syphon output to Syphon Recorder.

There are a few different video file recording add ons out there I think, if none of these approaches apply to you, I’m sure someone will point out some other methods!

2 Likes

@ayruos Thanks all worked with the fbo.
Just out of curiosity:
2. Is there an option to trigger quick time recording via oF.
3. you cannot offline render in oF, correct?

@everyone Solution for rendering screen -> images (later stitched together)
Below is the main part. You will also have to init, and update the fbo somewhere.

I’ve faced the same problem of recording OpenGL content to a video file on MSYS2
My first approach was to pipe frames to an external ffmpeg process.
Then, I’ve moved to use the libAv libs to do the encoding.
You may find the result in my ofxScreenRecorder addon. It is still in its early stage but may be a good start.

1 Like