We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
VideoGL (Read 1806 times)
VideoGL
Apr 10th, 2007, 7:18am
 
How could I play a movie in OpenGL for long duration?

We could unfold a movie as a set of textures where each textures would represent a frame of a movie. This video is displayed in OpenGL and it create new representation of the movie. In OpenGL, this is memory intensive, but it makes the video really responsive and fast. This is good for a small set of images as the textures are 32-bits (RGBA).

With the WebCAM, I had this trick to obtain a continuous stream by setting a buffer (with a set of textures) where I was reWriting textures as a new webcam frame was captured. It's working nicely, really effective, but this is memory intensive; the system Memory is the bottleneck.

With lower frames resolutions (80x60), I can play a video in OpenGL for few minutes. But, what could be done for a complete movie (1hour and more)? Wink


(1). Is there a way to make the texture smaller in memory? I've seen that there's different modes for textures in OpenGL (aka  Color-Index Mode). Could it be changed?
http://www.felixgers.de/teaching/jogl/colormode.html

(2). If I'm loading images from a hardDrive instead of a WebCam Capture, do you think that it would be possible to make a video playing continuously in OpenGL?
I was thinking using a multithreaded buffer loader for loading bitmap frames of the movie from the hardDrive.



Re: VideoGL
Reply #1 - Apr 11th, 2007, 5:29pm
 
the video -> opengl texture code is completely unoptimized. you could actually make movies play very nicely by handling your own textures, reading frames from the video and using glUpdateTexture(). at some point this will be added to the video lib (an optimized version of video for opengl playback and another for java2d) but i just haven't had time yet.
Re: VideoGL
Reply #2 - Jul 21st, 2008, 10:32pm
 
Any progress on this?  I am going to give it a try with the GL gl = ((PGraphicsOpenGL)g).gl; stuff, but my OpenGL isn't so great so if there is already some code out there I would appreciate it.
Re: VideoGL
Reply #3 - Jul 21st, 2008, 11:48pm
 
After some research that I should have dome before (sorry!), I see that you can simply draw a screen-sized quad every frame and assign the frame as a texture. I did some tests and the performance seems the same whether I call image() or use the texture method, so this has probably already been implemented?  

However, the performance is still not what I would expect for pushing the whole thing to hardware.  Is that really what is going on in this code?

 beginShape();
 texture(movieFrame);
 vertex(0, 0, 1, 0, 0);
 vertex(width, 0, 1, width, 0);
 vertex(width, height, 1, width, height);
 vertex(0, height, 1, 0, height);
 endShape();
Re: VideoGL
Reply #4 - Jul 22nd, 2008, 7:50am
 
You could have a look at GStreamer from anticode: http://codeanticode.wordpress.com/category/gstreamer/

Tested on my machine, I had much faster results, and it works very well on both Linux and Mac. I like it very much...

Using the previous way to call image() was too slow for me at that time (using QuickTime). I then started to work with pre-formatted  textures representing each frames of a short movie (5s to 1min). I took a while to load, but when loaded, it was superFast.

There's many nasty things that you could do with live movie. Playing back and forth at any speed (80x or more), you still have a video full screen at 30 fps.

You might have a look at GStreamer, I think it might be much faster than the QuickTime video.
Re: VideoGL
Reply #5 - Jul 22nd, 2008, 3:33pm
 
Thanks for the tips! I will try it out.

PS: I remember you from OFFF, Barcelona 07!
Page Index Toggle Pages: 1