We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
many movies (Read 956 times)
many movies
Jun 16th, 2009, 3:06am
 
Bonjour

I have a large number of Quicktime movies and would like to switch between them. Is it possible to change the Quicktime file associated with the movie object "on the fly"?

Merci,

PM
Re: many movies
Reply #1 - Jun 16th, 2009, 3:55am
 
hi

i did a movie bank sketch, but it seems to unveil a lot of problems within quicktime and java, perhaps there's a safer way ??

this is the movie bank sketch i am using:


import processing.video.*;

String file[] = {  
 "movie1.mov",  "movie2.mov",  "movie3.mov", "movie4.mov",  "movie5.mov",  
 "movie6.mov",  "movie7.mov",  "movie8.mov", "movie9.mov",  "movie10.mov" };

Movie mb[] = new Movie[file.length];

Movie movie;
int movieindex = 0;

void setup(){
 size(800,600);
 for(int i=0; i<file.length; i++){
   mb[i] = new Movie(this,file[i]);
   mb[i].loop();
 }
 movie = mb[movieindex];
}


void movieEvent(Movie movie) {
 if(mb[movieindex].available()){
   mb[movieindex].read();
   movie = mb[movieindex];
 }
}



void draw(){
 image(movie,0,0,width,height);
}


void keyPressed(){
 if(key==' ')
   movieindex = (movieindex + 1 )%file.length;
}


two types of errors come out with this sketch sporadically, when changing movies, on mac os x.5.5, intel machine..

one invalid memory access and crash, like:
Invalid memory access of location 65561800 eip=ffff0937

with crash reporter:
Java information:
Version: Java HotSpot(TM) Client VM (1.5.0_16-133 mixed mode)
Virtual Machine version: Java HotSpot(TM) Client VM (1.5.0_16-133) for macosx-x86, built on Aug 27 2008 11:00:20 by root with gcc 4.0.1 (Apple Inc. build 5465)
Exception type: Bus Error (0xa) at pc=0x9676eb2d

Current thread (0x0102d580):  JavaThread "Thread-8" [_thread_in_native, id=9915392]
Stack: [0xb13c0000,0xb1440000)
Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j  quicktime.qd.Pict.GetMoviePict(II)I+0
j  quicktime.qd.Pict.fromMovie(Lquicktime/std/movies/Movie;I)Lquicktime/qd/Pict;+5
j  quicktime.std.movies.Movie.getPict(I)Lquicktime/qd/Pict;+2
j  processing.video.Movie.read()V+73
j  movieBank_p5_2.movieEvent(Lprocessing/video/Movie;)V+24
j  sun.reflect.GeneratedMethodAccessor1.invoke(Ljava/lang/Object;[Ljava/lang/Object
WinkLjava/lang/Object;+40
J  sun.reflect.DelegatingMethodAccessorImpl.invoke(Ljava/lang/Object;[Ljava/lang/Ob
ject;)Ljava/lang/Object;
J  java.lang.reflect.Method.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang
/Object;
v  ~RuntimeStub::alignment_frame_return Runtime1 stub
j  processing.video.Movie.run()V+68
j  java.lang.Thread.run()V+11
v  ~StubRoutines::call_stub
Java Threads: ( => current thread )
 0x01034a20 JavaThread "DestroyJavaVM" [_thread_blocked, id=-1333784576]
 0x0102f290 JavaThread "Thread-11" [_thread_blocked, id=10218496]
 0x0102e7a0 JavaThread "Thread-10" [_thread_in_native, id=9918976]
 0x0102ddb0 JavaThread "Thread-9" [_thread_blocked, id=10029056]
=>0x0102d580 JavaThread "Thread-8" [_thread_in_native, id=9915392]
 0x0102cba0 JavaThread "Thread-7" [_thread_blocked, id=9763840]
 0x0102c4e0 JavaThread "Thread-6" [_thread_blocked, id=9680384]
 0x0102bfc0 JavaThread "Thread-5" [_thread_blocked, id=9596928]
 0x0102b730 JavaThread "Thread-4" [_thread_blocked, id=9564160]
 0x0102b040 JavaThread "Thread-3" [_thread_blocked, id=9482752]
 0x0102aa70 JavaThread "Thread-2" [_thread_blocked, id=9335296]
 0x010257a0 JavaThread "Animation Thread" [_thread_in_native, id=9216000]
 0x0101eee0 JavaThread "AWT-EventQueue-0" [_thread_blocked, id=9172480]
 0x0101c0d0 JavaThread "Java2D Disposer" daemon [_thread_blocked, id=9133056]
 0x010172e0 JavaThread "AWT-Shutdown" [_thread_blocked, id=8891392]
 0x01016d60 JavaThread "AWT-AppKit" daemon [_thread_in_native, id=-1605664864]
 0x0100f6f0 JavaThread "Low Memory Detector" daemon [_thread_blocked, id=8505856]
 0x0100e850 JavaThread "CompilerThread0" daemon [_thread_blocked, id=8502272]
 0x0100e310 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=8498688]
 0x0100d690 JavaThread "JDWP Command Reader" daemon [_thread_in_native, id=8495104]
 0x0100d1c0 JavaThread "JDWP Event Helper Thread" daemon [_thread_blocked, id=8471040]
 0x0100c460 JavaThread "JDWP Transport Listener: dt_socket" daemon [_thread_blocked, id=8423936]
 0x01007c40 JavaThread "Finalizer" daemon [_thread_blocked, id=8490496]
 0x01007860 JavaThread "Reference Handler" daemon [_thread_blocked, id=8486912]
Other Threads:
 0x01006fb0 VMThread [id=8483328]
 0x01010230 WatcherThread [id=8509440]




the other error type quicktime decompressor needed to see photojpeg files (doesnt really crash, picture doesnt move, and console keeps
looping out these errors)



at java.lang.reflect.Method.invoke(Method.java:585)
     at processing.video.Movie.run(Movie.java:684)
     at java.lang.Thread.run(Thread.java:613)
quicktime.std.StdQTException[QTJava:7.5.5g],-50=paramErr,QT.vers:7558000
     at quicktime.std.StdQTException.checkError(StdQTException.java:38)
     at quicktime.qd.Pict.fromMovie(Pict.java:105)
     at quicktime.std.movies.Movie.getPict(Movie.java:796)
     at processing.video.Movie.read(Movie.java:424)
     at movieBank_p5.movieEvent(movieBank_p5.java:54)
     at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.jav
a:25)
     at java.lang.reflect.Method.invoke(Method.java:585)
     at processing.video.Movie.run(Movie.java:684)
     at java.lang.Thread.run(Thread.java:613)
quicktime.std.StdQTException[QTJava:7.5.5g],-50=paramErr,QT.vers:7558000
     at quicktime.std.StdQTException.checkError(StdQTException.java:38)
     at quicktime.qd.Pict.fromMovie(Pict.java:105)
     at quicktime.std.movies.Movie.getPict(Movie.java:796)
     at processing.video.Movie.read(Movie.java:424)
     at movieBank_p5.movieEvent(movieBank_p5.java:54)
     at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.jav
a:25)
     at java.lang.reflect.Method.invoke(Method.java:585)
     at processing.video.Movie.run(Movie.java:684)
     at java.lang.Thread.run(Thread.java:613)
quicktime.std.StdQTException[QTJava:7.5.5g],-50=paramErr,QT.vers:7558000
     at quicktime.std.StdQTException.checkError(StdQTException.java:38)
     at quicktime.qd.Pict.fromMovie(Pict.java:105)
     at quick
Re: many movies
Reply #2 - Jun 16th, 2009, 4:47am
 
I tried  something ultrabasic:

void draw() {
if (keyPressed == true) {
     
myMovie = new Movie(this, "here I change my movie .. ");
  myMovie.loop();

}

I can hear the sound of the movie changing, but I get this error:

Exception in thread "Animation Thread" java.lang.ArrayIndexOutOfBoundsException: Coordinate out of bounds!


Re: many movies
Reply #3 - Jun 16th, 2009, 9:45am
 
I was trying to do something similar recently.  See:

http://processing.org/discourse/yabb2/?num=1243649285
Re: many movies
Reply #4 - Jun 16th, 2009, 10:09am
 
Thanks Scott

in the meantime I tried already to:

myMovie.stop();
myMovie=null;
myMovie = new Movie(this, "PlayMyNewQuicktimeHere.mov");

but this is not stopping the object to play all sounds of all movies at the same time and freezing the first Quicktime movie associated to the object

Is it not possible to change the Quicktime movie associated to a movie object dynamically?

Merci

Heiko
Re: many movies
Reply #5 - Jun 16th, 2009, 10:15am
 
The short answer is no, it's not possible to change the associated movie dynamically.  The Movie class doesn't support that.

But you should be able to fake it, which is what we're both trying to do here, by essentially taking your current Movie object and creating a new one with the same name, overwriting the old one.  (That's not technically what's really happening within Java, but is an easy way to think about it.)

myMovie = new Movie(...) should do just that, but it sounds like you're getting some playback issues.  Another way you could do it is set up an array of myMovie[] objects, and then, for your playback, just cycle through different ones, as in:

myMovie[0].stop();
myMovie[1].play();

Then just increment the numbers each time you want to switch clips.

It's not really ideal to re-instantiate objects on the fly, anyway, as you'll notice slight performance hiccups.  Instantiating a whole array of objects at launch is "more efficient", though potentially more confusing in terms of the code involved.
Page Index Toggle Pages: 1