JMC is awesome, now how do I use it?
in
Contributed Library Questions
•
3 years ago
I was working on some video code with Processing but the included video library kept choking on larger files and GSvideo just wouldn't run. I've got JMC video running now and the example code handles large files really smoothly. This is one OSX 10.6.4 with JavaFX 1.2
I believe my current problem is that now I can't figure out how to properly access the pixels from movieEvent.
I've started just trying to port some example code made for other libraries to use JMC. When I run the code I just get a black screen. I've read the JMC JDocs, but honestly I find that kind of stripped down documentation difficult to follow. It seems like JMC has a different way of dealing with movieEvent... I think. Or I'm making some sort of ridiculous schoolboy error.
The code I've been toying with at the moment should be recognizable from the processing site:
- /**
- * Pixelate
- * by Hernando Barragan.
- * Built-in video library replaced with gsvideo by Andres Colubri
- *
- * Load a QuickTime file and display the video signal
- * using rectangles as pixels by reading the values stored
- * in the current video frame pixels array.
- */
- import jmcvideo.*;
- JMCMovie myMovie;
- int numPixels;
- int blockSize = 10;
- color myMovieColors[];
- void setup() {
- size(640, 480, P2D);
- noStroke();
- background(0);
- myMovie = new JMCMovie(this,"MGBTR.mov", RGB);
- myMovie.loop();
- numPixels = width / blockSize;
- myMovieColors = new color[numPixels * numPixels];
- }
- // Read new values from movie
- void movieEvent(JMCMovie myMovie) {
- myMovie.read();
- myMovie.loadPixels();
- for (int j = 0; j < numPixels; j++) {
- for (int i = 0; i < numPixels; i++) {
- myMovieColors[j*numPixels + i] = myMovie.get(i, j);
- }
- }
- }
- // Display values from movie
- void draw() {
- for (int j = 0; j < numPixels; j++) {
- for (int i = 0; i < numPixels; i++) {
- fill(myMovieColors[j*numPixels + i]);
- rect(i*blockSize, j*blockSize, blockSize-1, blockSize-1);
- }
- }
- }
Thanks for having a look and any input.
1