Can I pauze a movie frame by frame?

edited July 2016 in Library Questions

I am new to this forum but I really hope you can help me out on this one.

I'm trying to blend multiple movies into one. For blending multiple images I already got my code to work quite nicely I think (example below). Now I want to do the same for every frame in multiple movies. I experimented with this somewhat and I can get the movie frames to blend on click. Now I want to blend every frame. So my code is this:


Movie movie1;
Movie movie2;

void setup (){

  movie1 = new Movie(this, "MVI_8256.MOV");
  movie2 = new Movie(this, "MVI_8257.MOV");;;

void movieEvent (Movie m){
  if (movie1.available() && movie2.available()){;;

void blend(){
  //code to blend

void draw (){
  image(movie1, 0, 0, 640, 360);
  image(movie2, 0, 640, 640, 360);

To me it looks as though the logic should work but i get a JNA: could not detach thread error. It seems that I can't pause a movie inside the movieEvent().

Hopefully one of you can help me out with some good advice!



  • edited July 2016

    Indeed you've come across some weird bug. 8-}
    Took a look at pause()'s implementation within "':

    public void pause() {
      if (seeking) return;
      if (!sinkReady) {
      playing = false;
      paused = true;

    Callback movieEvent() is synchronized to the Movie object.
    Apparently invoking pause() while under that synchronization can halt the whole program! @-)
    Much probably the unstable statement is this 1: playbin.pause();

    For now I haven't come up w/ some workaround yet. 8-|
    However I've modified the example "Loop.pde" which comes bundled w/ the Video library.

    Notice that even inside draw(), if we invoke pause() while synchronized w/ the Movie object, it eventually halts the sketch as well: :-&

    Movie movie;
    void setup() {
      size(640, 360);
      ( movie = new Movie(this, "") ).loop();
    void draw() {
      set(0, 0, movie);
      if (frameCount % 60 == 0)  synchronized (movie) {
        println(frameCount, movie);
    void mousePressed() {;
    void movieEvent(final Movie m) {;
      //if (frameCount % 60 == 0) {
      //  println(frameCount, m);
      //  m.pause();
  • Answer ✓

    May I suggest instead of pausing the movie, just traverse the movies frame by frame? I have a post done previously where, using provided examples from the video library, I show the concept:

    In this reference, the sketch shows a movie frame based on the position of the mouse pointer along the width of the sketch. You will need to modify it to suit your needs.

    I hope this helps and you will be able to go around "this" bug.


  • Hey GoTo and KF thanks so much for your time and advice. Great to get some good answers so soon! GoTo thanks so much for confirming the bug and KF that looks like that could really work. I will let you guys know how things go!

    Best, Maarten

  • Ok it was actually quite easy to get the movies to do what i want using your post Kfrajer. The first experiment video has just finished uploading. There remains a lot to be done:)

    Thanks again!

  • Great to hear @Marteen! What you are doing is really cool.


Sign In or Register to comment.