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.
IndexProgramming Questions & HelpVideo Capture,  Movie Playback,  Vision Libraries › JMC: display several video frames simultaneously
Page Index Toggle Pages: 1
JMC: display several video frames simultaneously? (Read 1231 times)
JMC: display several video frames simultaneously?
Feb 4th, 2010, 2:29pm
 
i'm trying to display about 200 instances of one video, as described here.
Using JMC to draw the video texture in OpenGL works fine, frameRate is a-okay.

i'm looping through all tiles and setting the position in the video accordingly, however it is displaying the same video frame for all tiles in the loop, even if it should offset the playback position by some amount for each tile, i.e. it should look like this:

...

but does look like this:

...


Code:
import processing.opengl.*;
import peasy.*;
import javax.media.opengl.*;
import java.util.*;
import jmcvideo.*;


PGraphicsOpenGL pgl;
GL gl;
PeasyCam cam;
JMCMovieGL3D scan;
float count = 0;

void setup()
{
size(800, 600, OPENGL);
cam = new PeasyCam(this, 1000);
cam.setRotations(.8, 0, 0);
cam.setMinimumDistance(50);
cam.setMaximumDistance(4000);

scan = new JMCMovieGL3D(this, "scan1.mov", RGB);
}

void draw()
{
background(0);
doGLStuff();
count+=0.00005;
}

void drawSlices(int num)
{
float perc = 0;
for(int i = 0; i < num; i++)
{
perc+= 1.0/num;
perc = (perc+count)%1;
pushMatrix();
scan.setPlaybackPercentage(perc);
scan.image(gl, -scan.width/2, -scan.height/2, -(num/2*27)+i*27, scan.width, scan.height*1.4);
popMatrix();
}
}

void doGLStuff()
{
pgl = (PGraphicsOpenGL) g;
gl = pgl.beginGL();
gl.glDisable(GL.GL_DEPTH_TEST);
gl.glEnable(GL.GL_BLEND);
gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE);

drawSlices(200);

pgl.endGL();
}


it seems that setPlaybackPercentage() does not update during the loop?
does the setPlaybackPercentage() method not update quick enough, or only at the end of draw() or something? i've had a look at the JMC source, but couldn't do anything helpful to it...

is there a better way to access the pixels of the video directly …?
Re: JMC: display several video frames simultaneously?
Reply #1 - Feb 4th, 2010, 2:40pm
 
have you checked that this:

perc+= 1.0/num;

isn't returning the same number all the time (num is an int...). actually, that looks ok

but do you mean this:

perc = (perc+count)%1;

or should that be %100 as it's a percentage?
Re: JMC: display several video frames simultaneously?
Reply #2 - Feb 4th, 2010, 2:51pm
 
that should be okay, the percentage function wants a 0.0 - 1.0, not real percentage…

just doublechecked:

perc+= 1.0/(float)num;
perc = (perc+count)%1.0;
println(perc)

this is not the culprit.
Re: JMC: display several video frames simultaneously?
Reply #3 - Feb 4th, 2010, 3:23pm
 
ah, ok. docs and examples does seem to support that (badly named variable though)

http://www.mat.ucsb.edu/~a.forbes/PROCESSING/jmcvideo/javadoc/

all the examples use centerImage:

"centerImage(javax.media.opengl.GL gl)
Draws the image across the center of the parent canvas, preserving the original aspect ratio of the video."

and you're using image:

"image(javax.media.opengl.GL gl, float x, float y, float w, float h)
Draws the video texture at the specified coordinates."

and i wonder whether there's a difference between 'the image' and 'the video texture' and whether you need to call texture() before image():

"texture(javax.media.opengl.GL gl)
Binds the video frame to this object's texture."

um, "Not needed if you are calling the automatic "image" methods.". what does that mean?
Re: JMC: display several video frames simultaneously?
Reply #4 - Feb 4th, 2010, 3:28pm
 
</strawclutching>
Re: JMC: display several video frames simultaneously?
Reply #5 - Feb 4th, 2010, 4:25pm
 
hmmm i think the first argument to image() does take care of the texture() thing already…
(adding texture() doesn't seem to do anything at least)

in the JMC source there's one thing called MediaProvider, which seems to hold the video data and probably provides low level access… .dunno maybe one can force it to update the video  - however i can't find a javadoc for it. hmmm….

edit: mediaProvider is part of sun's internal jmc API, so it's not public and discouraged to use etc etc… hrmpfff..



Re: JMC: display several video frames simultaneously?
Reply #6 - Feb 6th, 2010, 12:15pm
 
so i actually went and installed Windows, to be able to use the glgraphics and gsvideo libraries instead, as it looked like there is more accurate access to video data from it. What can i say?

  • nope. i couldn't get any closer to what i want to do.
  • jmcvideo is much faster at rendering videos as gl textures, at least in my setup.


conclusion: stuck.
Page Index Toggle Pages: 1