i have been working on a sketch which plays a quite large array (about 40) of short video clips - 30-90 seconds at 1280x720 resolution- activated by a sensor when someone is in the room
when the room is empty the sketch plays a short 3 sec video on a loop until someone comes into the space
and then the sequential array begins again
the sketch works for a bit, then bogs down losing sync and completely crashes
i am getting the following error message
JNA Callback org.gstreamer.elements.AppSink$33@2ffe7 threw the following exception:
java.lang.Out of MemoryError: Java heap space
i am a completely newbie to processing (or programming at all)
it seems to be a memory leak?
this is my code..does anyone have any suggestions for me?
with thanks
clem
int maxmyMovies=31
; //total # movies
int myMoviesIndex=0; //initial movie to be displayed
int lastMovie = 0; // last movie that played before going back to the grid
int GRID = 0; // this is always the grid index
Movie[] myMovies = new Movie[maxmyMovies] ; //declare array of movies
for (int i=0; i<myMovies.length; i++) {
myMovies[i] = new Movie(this, "trans"+nf(i, 2)+".mov"); //loading movies into the array
}
myMovies[myMoviesIndex].loop(); //play the first movie
void draw() {
image(myMovies[myMoviesIndex], 0, 0, 1280, 720); //display one movie
g.removeCache(myMovies[myMoviesIndex]); //empties cache so no OOM error
// the current movie is done
if (myMovies[myMoviesIndex].time() >= myMovies[myMoviesIndex].duration()) {
if (someoneIsThere) {
if (myMoviesIndex == GRID) { // we're on the grid clip
myMoviesIndex = lastMovie; // go back to where we were last time
}
nextMovie();
}
else {
myMovies[myMoviesIndex].stop(); // stop the current movie
if (myMoviesIndex != GRID) lastMovie = myMoviesIndex; // "save" it for later
myMoviesIndex = GRID; // grid
myMovies[myMoviesIndex].loop();
}
}
//////////////////////////////////////////////////////////////////////////////////////////
void movieEvent(Movie myMovies) {
myMovies.read(); //read new frames from movie
}
void serialEvent( Serial s ) {
try {
String data = s.readString();
data = data.trim(); // gets rid \n and extra spaces if any
sensorValue = Integer.parseInt(data); // converts String --> number
if (sensorValue < 100) { // distance threshold
someoneIsThere = true;
countdown = 150; // time before we decide someone is gone
}
else {
if (countdown == 0) {
someoneIsThere = false;
}
}
// time running
if (countdown > 0) countdown--;
}
catch( Exception e ) {
println("whatever");
}
}
void nextMovie() {
myMovies[myMoviesIndex].stop(); // stop the current movie
myMoviesIndex=(myMoviesIndex+1) % myMovies.length; //increment movie by one and return to zero once size of array is reached
if (myMoviesIndex == GRID) myMoviesIndex = 1; // skip the grid when advancing to the next movie
myMovies[myMoviesIndex].play(); // play the next movie
}
i am a grad student and new to processing
i am working on a piece with an array of video clips
i want the array to be accessed consecutively until the array has been completed at which point it would begin at zero
again
at the moment the mouse press sets it back to the beginning
i am not sure how to fix this
can anyone help?
please find my code below
thanks
import processing.video.*;
int maxmyMovies=5
; //total # movies
int myMoviesIndex=0; //initial movie to be displayed
Movie[] myMovies = new Movie[maxmyMovies] ; //declare array of movies
boolean someoneIsThere = false;
void setup( ){
size(1280, 720);
for (int i=0; i<myMovies.length; i++) {
myMovies[i] = new Movie(this, "trans"+i+".mov"); //loading movies into the array
}
myMovies[myMoviesIndex].loop(); //play the first movie
}
void draw() {
image(myMovies[myMoviesIndex], 0, 0, 1280, 720); //display one movie
if (myMovies[myMoviesIndex].time() >= myMovies[myMoviesIndex].duration()) {
// the current movie is done
if (someoneIsThere) {
nextMovie();
someoneIsThere = false;
}
else {
myMovies[myMoviesIndex].stop(); // stop the current movie
myMoviesIndex = 0;
myMovies[myMoviesIndex].loop();
}
}
void movieEvent(Movie myMovies) {
myMovies.read(); //read new frames from movie
}
void mousePressed() {
someoneIsThere = true;
}
void nextMovie() {
myMovies[myMoviesIndex].stop(); // stop the current movie
myMoviesIndex=(myMoviesIndex+1) % myMovies.length; //increment movie by one and return to zero once size of array is reached
myMovies[myMoviesIndex].play(); // play the next movie
}
i am currently trying to write a sketch using a series of HD video clips with sync sound
they are .mov files in H264
but the sound is not sync'd to the video when i run the sketch
any suggestions?
i am brand new to processing (and not a coder)
i downloaded processing 2.0 today
i am trying to get a video to play and am getting the audio but not the image
does anyone have any suggestions for me
thanks