how to start a movie from the last frame

Linden's icon

Hello Forum

i want to start two movies which read the same file simultaniously>
one playing forward >>
one playing backward<<
when i bang the two mov objects the one who is set to play backward (rate -1) always starts from frame 0 and then jumps to the last frame and goes on.
is there a way to prevent this behaviour and start the movie from the last frame directly??
thank you

Rob Ramirez's icon

did you try sending the frame message with the last frame as it's argument prior to starting playback in reverse? you can get the last frame by subtracting 1 from the framecount attribute value.

with video related questions, it's very important we know which OS you are on, and if you've modified the default video engine, as each OS and engine combination has a different backend with different behavior.

Linden's icon
Max Patch
Copy patch and select New From Clipboard in Max.

hello thanks for the answer.
i am on mac osx and i think it runs avf enginge!
so to understand the data flow:
jit.mov gets the filepath > then it can calculate the framcount> then it needs to subtract>and then start the playback??
that means i cannot switch between files without a pause??
also what is the difference between playlist and using a umenu or a list of filepath with an mov object?
it seems that with a playlist you can swith directly between vids whereas with a movie object it always stops for a little while?
here is a patch which demonstrates my problems:

Linden's icon

oh i forgot to hook up the "frame" message to the movie! no matter which order i try and also when i work with start stop messages i cannot make it work the way i want it to work.

Christopher Dobrian's icon

Make a jit.movie object. Read in a movie file. When the file is done opening, jit.movie will send out a 'read' message of its own. Use that to trigger a 'getframecount' message. Subtract 1 from the framecount, go to that frame, set rate to -1 (backward), and start the movie (and start banging it).

Max Patch
Copy patch and select New From Clipboard in Max.

P.S. Any time you open a file of any kind, you're introducing an unknown delay. If timing is critical, you need to work out a scheme to open the files in advance of needing to use them.

Linden's icon

thanks for the answer!
hmmm when i use countdown.mov i can clearly see that it shows 10 and then jumps to 1 at least in my system...
so there is no way to make smooth transition between selecting files unless they are preloaded?
is a playlist kinda preloading? cause with a playlist at least it makes smooth transitions between selecting different mov files!

Rob Ramirez's icon

hi Linden.
this stuff is a little tricky with the AVF engine, because much of its behavior is asynchronous which means it's not so straight forward to trigger a series of actions using messages.

the first change to make to your patch, is to use "asyncread" rather than "read" to load your files. you then use the "read" notification, as demonstrated by christopher above, to perform other actions. the "read" message in AVF is there for legacy behavior with older patches that use jit.movie, but should be avoided if possible.

the second change to make is that you must use the "seeknotify" notification after sending your frame request, to start frame output. this is a special behavior of jit.movie with the avf engine that accounts for asynchronous seeking behavior, meaning you can't send a seek request (e.g. the "frame" message) and immediately bang the object expecting to get that exact frame.

i've modified the patch slightly to show how to achieve your stated goals.

and yes, if you want to avoid the pause you either preload the videos, with a jit.movie object for each file (which is how jit.playlist works), or use two jit.movie objects and ping-pong back and forth between them.

Max Patch
Copy patch and select New From Clipboard in Max.