How to do a video texture on OpenGL?

Started by angros47, July 07, 2024, 17:03:23

Previous topic - Next topic

angros47

I would like to be able to open a video file (I am mainly interested in MP4 format; the ability to support other formats, too, would be nice, but not required), and use it as a texture in an OpenGL context. I managed to do it pretty easily in WebGl, and it was pretty simple (only video formats supported by browser can be used, of course) but the same operation is not so simple in OpenGl, since I need to decode the video with some external library.
To load static pictures and use them as textures I have used stbi_image, and it works pretty well, but I never found anything equivalent for videos. I found a single lesson on NeHe tutorial, but it for Windows only, and is pretty outdated.
For Linux, the few tutorials I have found that mention decoding a video assume ffmpeg is installed, while on modern Ubuntu it is usually not installed, since gstreamer is used in its place (and I found zero examples using gstreamer)

Anyone can recommend a guide/tutorial to how to open a video file, and decode it in a memory buffer that can be rendered as a texture? I am looking for a multiplatform solution (at least Windows and Linux: I am not interested in anything that is Windows only), I am interested in particular to MP4 files (to have a solution consistent with what can be done in WebGl). For Linux, I am not interested in anything that requires to install ffmpeg, since Ubuntu (and, I assume, other modern distros) don't ptovide it out of the box anymore.
What I would like is either an open source compact decoder for MP4 (but I assume there is no one, since it seems a pretty complex format to decode), or something that can use the decoding libraries already installed in Windows/Linux with no extra dependencies. Does such a solution exist?
Thanks