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.
Pages: 1 2 3 ... 5
faster Movie class (Read 33657 times)
faster Movie class
Apr 3rd, 2007, 10:58pm
 
hello,

I propose a replacement for the native movie class. I wrote it for my sister who needed to play a huge movie in realtime inside processing. it runs really smooth with about 30% cpu usage on my core2duo mbp.

I gave it all the methods of the native movie class (copied and pasted some code also) and some more:
- volume control (since sound works now)
- prossibility to write directly into the applet, saving 1 copy of the image data

also it works a tiny bit different: you have to repeatedly call task() on it to do the work, but that can be done nicely in draw(). one could also use a worker thread I suppose, but I wanted to avoid nasty race conditions.

also right now I use it as a file in the pde, and that for some reason doesnt allow me to declare Class type variables, so the call back does't work right now. but alternatively task() will return true if a new image was made so in draw you can do something like this:

draw()
{
 if (movie.task())
    //draw movie somewhere like any PImage
}

and due to single tasking you are guarantueed the image wont get overwritten while you work with it.

of course when it would be compiled natively as part of the movie toolbox the callback should also work (just 2 lines to uncomment in the constructor)

oh, and since I changed from grabbing single frames (which made slooow) to just playing the movie and have it deliver me frames I have no way right now to drop frames, so there is no fps setting, each frame will be rendered (as long as quicktime itself doesn't drop frames...does it?).

ah, and the file is at (no attachments here?):

http://danieloberhoff.de/processing/FasterMovie.pde

Re: faster Movie class
Reply #1 - Apr 4th, 2007, 12:10pm
 
very nice!

made some minor changes:
- fixed aspect (movies were distorted on mac) as done in processing.video.Movie
- fixed callback for movieImageAvailable
- added registerPre, so there's no need to call task() anymore

files are here:
FasterMovie.pde
fasterMovieExample.pde

F
Re: faster Movie class
Reply #2 - Apr 4th, 2007, 2:21pm
 
ah, the pre() hack is pretty cool, invisible single threaded magic Wink.

one more remark: do NOT try to include processing.video.* (or processing.video.Movie to be more specific) since Movie collides with quicktime's Movie. I this should some time replace Movie in processing.video then I would propose calling it PMovie.

Cheers
Re: faster Movie class
Reply #3 - Apr 4th, 2007, 2:42pm
 
maddanio wrote on Apr 4th, 2007, 2:21pm:
ah, the pre() hack is pretty cool, invisible single threaded magic Wink.


not a hack, standard processing library thing, see here:
http://dev.processing.org/libraries/

maddanio wrote on Apr 4th, 2007, 2:21pm:
one more remark: do NOT try to include processing.video.* (or processing.video.Movie to be more specific) since Movie collides with quicktime's Movie. I this should some time replace Movie in processing.video then I would propose calling it PMovie.

Cheers


i didn't include processing.video.* ... i know it would possibly collide. but you could work around that happening if you state all instances of "Movie" as "quicktime.std.movies.Movie". that way people still can use processing.video as well ...

i think it was once called PMovie ... not sure why it changed or if i'm wrong. but i agree with your point.

best,
F
Re: faster Movie class
Reply #4 - Apr 5th, 2007, 7:40pm
 
You might also want to check out this thread: Slightly rewritten video.Movie library. It allows you to start utilizing PMovie.

I've been using it to avoid clashes in sketches where I use both MovieMaker and Quicktime movies.
Re: faster Movie class
Reply #5 - Apr 5th, 2007, 10:17pm
 
Ah, yes. But I think it's most useful to people if it is left as a file that can be just added as a file to the project, unless it would be decieded to be used in the source tree. And the way it is now I simply don't use processing.video.Movie.
Re: faster Movie class
Reply #6 - Apr 17th, 2007, 4:57pm
 
Nice work! It's very fluid.

But it only plays once for me, even in loop. I'm a novice at Java and I tried to figure out how to change the code to make it repeat but to no avail. How could I implement this?

And would it be difficult to add the possibility of changing the source .mov? Have it play one movie for a while and then a mousePressed, for example, and it loads and plays a different movie.

Thanks.

Re: faster Movie class
Reply #7 - Apr 17th, 2007, 5:03pm
 
That it doesn't loop is a bug. Can you post a short example that reproduces this?  To open a new file you should really just dump the old movie and make a new one, as the concept is that the movie IS the file, and the class just wraps around this file and plays it.
Re: faster Movie class
Reply #8 - Apr 18th, 2007, 12:35am
 
ok, I got it, the problem was that it would never catch the end of the move but stop just before. update atz the old place:

http://danieloberhoff.de/processing/FasterMovie.pde

cheers
Re: faster Movie class
Reply #9 - Apr 18th, 2007, 7:12am
 
It works! Very nice.

When I have a bit of time I might try to add a change source function to keep the same FastMovie instance (if I can figure it out.

In the meantime I got it to change movies with -

fm.stop();
fm = null;
mImage = null;
fm = new FasterMovie(this, "movie2.mov", false);
fm.loop();

Thanks!
Re: faster Movie class
Reply #10 - Apr 18th, 2007, 10:29am
 
Hi,

I am not sure if this would really save so much work (saying mymovie.load(file) would probably be equivalent to mymovie = new FasterMovie(this,file), maybe you can sayve some lines by automatically stopping/restarting, but that would also make the code less readable imho).

But if you really need it what you have to do is factor out most of the stuff in the constructor into a load function and then call that from the constructor.

Cheers

Daniel
Re: faster Movie class
Reply #11 - Jul 17th, 2007, 2:39pm
 
Hi there,

I did some updates to the FasterMovie class. Replaced every instance of 'Movie' by 'quicktime.std.movies.Movie', so it can be used together with processing.video.*.

Also copied over the function 'duration()' from processing.video.movie.
Quote:


public float duration() {
   try {
     return (float)movie.getDuration() / (float)movie.getTimeScale();

   } catch (StdQTException e) {
     e.printStackTrace();
   }
   return -1;
 }



Daniel, I emailed it to you.

Cheers,
patrick
Re: faster Movie class
Reply #12 - Jul 17th, 2007, 3:35pm
 
Ok, I assume that youd didn't break anything and just replaced the old version under:

http://danieloberhoff.de/processing/FasterMovie.pde

I hope I am not breaking anyone's Neck with this? Glad to hear that it is actually used, since it turned out for the original project that it was still too slow and we had to fall back to pure java and fight our private war with QTJ, no fun...
Re: faster Movie class
Reply #13 - Dec 7th, 2007, 2:00pm
 
maddanio wrote on Apr 3rd, 2007, 10:58pm:
oh, and since I changed from grabbing single frames (which made slooow) to just playing the movie and have it deliver me frames I have no way right now to drop frames, so there is no fps setting, each frame will be rendered (as long as quicktime itself doesn't drop frames...does it).





hey,

i am realy happy about this faster Movie class.
it works pretty nice!
thank you.

but there is no way to change the speed like in speed () in the video library, is it


Re: faster Movie class
Reply #14 - Dec 7th, 2007, 2:24pm
 
yes, there is fasterMovie.speed()
have not used it and don't know if it works though.
Pages: 1 2 3 ... 5