Playing Video In OpenGL


#1

I was wondering if there is a way to pass a video maybe from directshow to opengl? I know its possible to use standard juce 2D graphics context to render directly to opengl framebuffer, but how can I get image context of directshow to pass to opengl, OR is there a quick and better way to play a video file in opengl ?

Thanks,
jay


#2

I was hoping that someone would have an idea about this, I tried createComponentSnapshot with a directshow component thats playing a video, but its not taking out the snapshop of video image! only the control buttons like play ect, also tried paintEntireComponent, still no go. Thanks in advance…


#3

I doubt if you’ll be able to get GL and DirectShow talking to each other… Maybe if you used something like ffmpeg you could directly get the data and push it to GL, but I really don’t know much about that kind of thing.


#4

Thanks jules, I will look for alternatives for video, but howabout the juce WebBrowser Component, any way to get that as a opengl texture?


#5

Are you deliberately picking the most awkward things to convert to a texture?


#6

Haha, by no means, infact being able to convert the webbrowser component to opengl texture can be very useful. Within the unified framework of juce since webbrowser is a component, I naturally assumed paintEntireComponent would take it out, Unfortunately that’s not the case. Anyways, if anyone else has any idea how I can do this, much appreciated. Cheers


#7

Check out Awesomium:
https://awesomium.com/

You’ll have to work out the integration w/ Juce and it is desktop only, but it shouldn’t be too bad to have OSX and Win builds with Juce.


#8

Hey, I’d just like to bump this thread from five years ago. Using the latest JUCE we’re trying to get video playback to get passed into OpenGL as a texture. Since the VideoComponent class has been added I figured there might be some new perspective on the issue.

Right now we’ve created a manual implementation using ffmpeg which does work. However we’re noticing that the performance of the actual video decoding/playback is horrible (!!!) compared to the JUCE demo. It would be nice if we could leverage the speed of the VideoComponent, passing that directly to an OpenGLTexture. Any idea about this Jules (or anyone at the ROLI team)?


#9

I think the video player is pretty much a black-box, I don’t know how you’d even attempt to integrate it with GL…


#10

Darn, that’s what I was afraid of. Thanks for the fast response!


#11

On Windows, you can use MediaFoundation to process frames of video and audio streams.

You would need to convert/set the video frame data to some kind of GL buffer (eg: glDrawPixels, or some vertex+pixel shader using a texture - ShaderToy has somewhat relevant examples).

Official MediaFoundation examples can be found here (not for the faint of heart!):

Needless to say that this process is going to be completely different on any and every other platform.