Using threads to load and playback movies

edited April 2015 in How To...

I'm working on an application that plays multiple HD movies, and it's pretty slow and janky all on the main thread.

I have found a few blog posts about using threads with Processing, but can't find in the documentation where they're described. Google shows a few dead links going to a github wiki?

Does anybody know the canonical location of the documentation for using threads with processing?

Or have any suggestions of how to use threads to speed up the loading and playback multiple HD movies?


  • edited November 2014

    Threads are an advanced Java subject. Since Processing is a Java framework, threads work alright on it too.

    AFAIK, already runs in a separate Thread.
    Notably, each movieEvent() callback happens in a new Thread as well.

    I don't see how more threads would solve your problem.
    Playing a bunch of videos at the same time is painfully slow in any situation!
    You should stop() or pause() Movie instances when they're not needed!

    Take a look at this recent forum question for some examples: (*)

  • Admittedly my Java is poor, but I don't see anywhere here that shows the movie running in its own thread

    Also doesn't seem that movieEvent runs in its own thread there either.

    I can play several (at least 4) HD movies in Quicktime with all of them playing smoothly, so it's possible on my hardware. Just have to figure out how to do it through Processing!

  • edited November 2014

    Also doesn't seem that movieEvent() runs in its own thread there either.

    We can make a little test w/ println(Thread.currentThread());:

    If we paste the statement above in setup() or draw(), we're gonna see: Thread[Animation Thread,5,main].
    While inside movieEvent(), something like: Thread[Thread-110,5,main].

    We also can see inside protected void initGStreamer(PApplet parent, String filename) {} method that it instantiates a buncha imported classes. Who knows which Thread objects happen to be created by them? :-??

    I can play several (at least 4) HD movies in Quicktime with all of them playing smoothly,...

    I dunno which is the secret of those media players either! 8-}
    "" library is a wrapper for "org.gstreamer." library.

    Besides dealing w/ all that, we still gotta "stamp" those Movie objects on the canvas via image() or set().
    Who knows 1 day some1 creates a much more optimized video library for Processing? (:|

Sign In or Register to comment.