You can still get some more performance by avoiding unnecessary texture copies. Basically, you should call putPixelsIntoTexture() only when you are sure a new video frame has been read. Take a look at the following code:
- import processing.opengl.*;
- import codeanticode.gsvideo.*;
- import codeanticode.glgraphics.*;
- GSMovie movie;
- GLTexture tex;
- boolean newfr;
- int rcount, dcount;
- int lastrm, lastdm;
- float readfr, drawfr;
- int frint = 1;
- void setup() {
- size(960, 540, GLConstants.GLGRAPHICS);
- tex = new GLTexture(this);
- movie = new GSMovie(this, "movie.mov");
- movie.loop();
- }
- void movieEvent(GSMovie mov) {
- mov.read();
- newfr = true;
-
- rcount += 1;
- int m = millis();
- if (m - lastrm > 1000 * frint) {
- readfr = float(rcount) / frint;
- rcount = 0;
- lastrm = m;
- }
- }
- void draw() {
- if ((1 < movie.width) && (1 < movie.height) && newfr) {
- tex.putPixelsIntoTexture(movie);
- image(tex, 0, 0, 960, 540);
- newfr = false;
-
- text("read fr: "+ int(readfr), 10, 10);
- text("draw fr: "+ int(drawfr), 10, 25);
- }
-
- dcount += 1;
- int m = millis();
- if (m - lastdm > 1000 * frint) {
- drawfr = float(dcount) / frint;
- dcount = 0;
- lastdm = m;
- }
- }
I also put manual framerate calculations, since the internal frameRate variable might not be accurate all the time. Also, there are actually two different framerates you need to consider: the rate at which the read() function is called (which should be same as the original video framerate if no frames are being dropped) and the rate at which the draw() function is called (which can be higher than the read rate).
On OSX, using the new frame trick with full HD video (1080p), I gain several frames, but the read framerate is still lower than the original video's framerate at some points. This is also dependent on the platform: on Linux I'm able to play 1080p with no frames dropped, performance on OSX is a little worse, followed by Windows. Hardware will also have an effect.