Video Crashes with JNA: could not detach thread

Hello together,

I’ve recently started using the video functions of processing for a uni project. Sadly I seem to run into the mentioned error on all maschines I’m working on.

Even with the most basic version on the playback always get the error “JNA: could not detach thread”
eventually crashing the playback (See screenshot)
I have tried reinstalling processing and java, but nothing changes. Whats bothering me more is, that is sometimes it goes through ok.

Any Idea what may cause this?

import processing.video.*;
Movie myMovie;
void setup() {
  size(200, 200);
  myMovie = new Movie(this, "noisestorm_crab_rave.mp4");
  myMovie.play();
  myMovie.volume(0);
}
void draw() {
}
void movieEvent(Movie m) {
  m.read();
  println(m.time());
}

1 Like

Ok, I tried and checked some things.

It seems like the " void movieEvent(Movie m) " function is causing the problem.
I did not check it before, and when i handle all the updates in void draw(), with the movie.available() funtion, it’s working.

So for now its working well.

2 Likes

Hi,
it seems strange to me but it looks like i have it figured out now,
maybe it was my error for not understanding the way the Videolibraray works, or its a strange problem.
The following seems to generate a proper videostream with the correct framecount, in playbackrates up to 6x, without getting into any JNA error or crashes.

import processing.video.*;
Movie myMovie;
boolean ended = false;
float playbackSpeed = 6.0;
float videoFrameRate = 29.97;
void setup() {
  size(200, 200);
  /* End of playback function by ajohnsonlaird
     https://forum.processing.org/two/discussion/26225/movie-duration-always-returns-0-0-framerate-and-speed-do-not-seem-to-affect-playback
  */
  myMovie = new Movie(this, "noisestorm_crab_rave.mp4"){
        @Override public void eosEvent() {
        super.eosEvent();
        myEoS();
        }
  };
  myMovie.play();
  myMovie.speed(playbackSpeed);
  myMovie.volume(0);
  myMovie.noLoop();
  myMovie.frameRate(playbackSpeed * videoFrameRate);
}

void draw() {
  if (myMovie.available() && !ended) {
          myMovie.read();
          println(myMovie.time());
  }
  image(myMovie, 0, 0);
}

// Called every time a new frame is available to read
void movieEvent(Movie m) {
  if (!ended) {
    m.read();
  }
}

void myEoS() {
  ended = true;
}
1 Like