opengl video sketch gets stuck after a minute

edited January 2018 in Library Questions

I'm trying to run a sketch (motion font) but after a minute or so it gets stuck no matter what I'm getting a lot of errors

java.lang.NullPointerException
    at processing.opengl.Texture.copyBufferFromSource(Texture.java:827)
    at sun.reflect.GeneratedMethodAccessor7.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at processing.video.Movie.read(Unknown Source)
    at draft_write_text_and_blend.movieEvent(draft_write_text_and_blend.java:179)
    at sun.reflect.GeneratedMethodAccessor5.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at processing.video.Movie.fireMovieEvent(Unknown Source)
    at processing.video.Movie.invokeEvent(Unknown Source)
    at processing.video.Movie$1.bufferFrame(Unknown Source)
    at org.gstreamer.elements.BufferDataAppSink$AppSinkNewBufferListener.newBuffer(BufferDataAppSink.java:163)
    at org.gstreamer.elements.AppSink$2.callback(AppSink.java:184)
    at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.sun.jna.CallbackReference$DefaultCallbackProxy.invokeCallback(CallbackReference.java:485)
    at com.sun.jna.CallbackReference$DefaultCallbackProxy.callback(CallbackReference.java:515)
Could not run the sketch (Target VM failed to initialize).
For more information, read revisions.txt and Help ? Troubleshooting.

the code for the sketch itself:

String str = "בבוקריוםאהזברהקמה";
String alphabet = "אבגדהוזחטיכךלמםנןסעפצץקרשת";
int wordsNum = 2;

int frameNum = 0;

int t = 0;

int[] wordsLength;

float fontMultiplier = 1;

float kerning =-110;
float leading =-100;
float charLocation = 0;
float lineLocation = 0;

float fontHeight = 122*fontMultiplier;
float fontWidth = 160*fontMultiplier;

float horMargin = 100+fontWidth;
float vertMargin = 70;

Movie[] letterAsso;


import processing.video.*;
void setup() {
  size(1200, 900, P2D);

  frameRate(60);

  // finding out how many words are there    (important for the wordsLength array)

  for (int i = 0; i<str.length(); i++) {
    if (str.charAt(i)==' ') {
      wordsNum++;
    }
  }

  println("number of words is: ", wordsNum);

 int letCount = 0;

  wordsLength = new int[wordsNum];
  for (int i = 0; i<str.length(); i++) {
    if (str.charAt(i)==' '||i==str.length()-1) {
      wordsLength[t]=letCount;
      letCount=0;
      t++;
    } else {
      letCount++;
    }
  }
  println(wordsLength);



  letterAsso = new Movie[alphabet.length()];
  for (int i=0; i<alphabet.length(); i++) {
      letterAsso[i] = new Movie(this, alphabet.charAt(i)+".mov");
    }

  //for (int i=0; i<alphabet.length()/3; i++) {

  //    letterAsso[i].loop();

  //      println("breakpointB"+i);
  //  }

  //for (int i=alphabet.length()/3; i<2*alphabet.length()/3; i++) {

  //    letterAsso[i].loop();

  //      println("breakpointC"+i);
  //  }

  //for (int i=2*alphabet.length()/3; i<alphabet.length(); i++) {

  //    letterAsso[i].loop();

  //      println("breakpointC"+i);
  //  }


  t=0;
}

void draw() {

  background(255);
  blendMode(MULTIPLY);

  if(frameCount-1<alphabet.length()){
          letterAsso[frameCount-1].loop();
  }
  charLocation = 0;
  lineLocation = 0;
  t = 0;
  for (int let = 0; let < str.length(); let++) {
    float letterxLocation = width-horMargin+charLocation-fontWidth;
     //println(str.length());
    image(letterAsso[alphabet.indexOf(str.charAt(let))], letterxLocation, vertMargin+lineLocation, fontWidth*fontMultiplier, fontHeight*fontMultiplier);
    //println(letterAsso[alphabet.indexOf(str.charAt(let))]);


    //for (int i=0; i<str.length(); i++) {
    //  if (str.charAt(i)!=' ') {
    //    currentLetter[i] = new Movie(this, str.charAt(i)+".mov");
    //    //currentLetter[i].frameRate(2);
    //    currentLetter[i].loop();
    //    currentLetter[i].jump(random(0, 7));
    //  } else {
    //    currentLetter[i] = new Movie(this, "space.mov");
    //  }
    //}

    // Character Location

    charLocation = charLocation - fontWidth - kerning;

    // checking if it's a new word

    if (str.charAt(let)==' ' && t < wordsNum) {

      // creatng a new line

      if (width-horMargin+charLocation-wordsLength[t+1]*(fontWidth+kerning) < horMargin) {
        charLocation = 0;
        lineLocation = lineLocation + fontHeight + leading;
      }
      t++;
    }
  }
  fill(0);
  textSize(16);


  text("Frame rate: " + int(frameRate), 10, 20);

  //saveFrame("output/framer_####.jpg");

  //blendMode(BLEND);
  //filter(INVERT);
}


void keyPressed(){
  if (keyCode == BACKSPACE) {
  if (str.length() > 0) {
    str = str.substring(0, str.length()-1);
  }
} else if (keyCode == DELETE) {
  str = "";
} else if (keyCode != SHIFT) {
  str = str + key;
}
}

void movieEvent(Movie m) {
  m.read();
}
Tagged:
Sign In or Register to comment.