Capturing OpenGL Graphics in Video

I wrote an openGL application and would like to create a video with the graphics displayed in the Glut window. Do you know how to do this?

From a previous question in SO, I know that one possible solution is to use glReadPixels to get frames that were processed by openGL, and then use the FFmpeg library to create the video. I really don't know how to use FFmpeg, so I'm not sure how to write a program that takes frames and displays video. Although the link in the original question is broken, I found this video encoding example that may be useful for those trying to help.

Two questions:

  • How can I use FFmpeg to record a program that takes frames and displays video?
  • My application is written in OCaml, so I use lablgl and lablglut . Any ideas on how FFmpeg ideas can be implemented in this case?
+4
source share
3 answers

You can use libpng to write your frames to separate PNG files, and then use the ffmpeg command-line tool to encode this into a video.

+3
source

Option for png answser: output to bmp. Create a white image of the same size in Paint (or whatever is available on Mac), open it using notepad, select the file header (for 800 * 600 it is 42 4D 36 F9 15 00 00 00 00 00 36 00 00 00 28 00 - 00 00 20 03 00 00 58 02 00 00 01 00 18 00 00 00 00 00 00 00 F9 15 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 27), add the results glReadPixels, flush, close.

So yes, there are a lot of files, but this is usually not a problem, since most openGL applications do not use the hard drive too much.

(I know this is pretty dirty, but this is the easiest way to implement it - I did it on the train once, without any documentation)

+2
source

To capture a video for demonstration, the best way is probably fraps

0
source

Source: https://habr.com/ru/post/1340043/


All Articles