Page 1 of 1
Control frames of a QuickTime movie
Posted: Mon Dec 08, 2008 4:46 pm
by hamlynart
Hi Folks,
How can I control the current frame of a QT movie in RunRev?
I'd like to be able to monitor an input and make the movie jump to the corresponding frame. Can this be done?
Thanks
Jim H
Posted: Mon Dec 08, 2008 6:29 pm
by bn
Hi Jim,
this is a tricky one.
the player gives you the duration of the movie and the timescale. The duration is the length of the movie in seconds, if you divide the duration by the timescale. Timescale is typically 600 in Quicktime, but not necessarily so. The timescale indicates in how many intervalls a second is split in the movie. Depends on the type of movie you use. To get at the length of a frame in revolution you need to know the framerate, the framerate you can look up in the Quicktime Player-> info.
Lets assume you have a movie that plays at 25 frames per sec and it has the standard timescale of 600 then you take the duration (as provided by the Player object in Rev) and divide it by 24. This is the duration of a frame at 25 frames per second in a timescale of 600 (600/25=24): that gives you the number of frames.
The other way around is:
multiply 24 by the framenumber and tell the player object to set the curenttime to that number. That goes to the frame number you want.
This is only true if the framerate is 25 and the timescale 600.
If you are on a mac then you could open the movie of interest in the quicktime player and then you open the scripteditor to run this applescript
Code: Select all
tell application "QuickTime Player"
tell document 1 -- make shure its a movie
set theDuration to the duration
set theTimeScale to the time scale
tell track 1 -- make shure track 1 is a video track
set theFrames to count of frames
set theFrameLength to duration of frame 1
set y to the duration of every frame
end tell
end tell
end tell
display dialog "length in seconds: " & theDuration / theTimeScale & return & "framerate: " & theTimeScale / theFrameLength
I have tried to explain this from a different angle here
just try in your project to advance the currenttime by 24 and see if it is the next frame, that is kind of a low tech solution, but it often works.
hth
Bernd
Posted: Tue Dec 09, 2008 12:04 am
by bn
try this in a button
Code: Select all
on mouseUp
put the currenttime of player "myPlayer" into tTemp
add 24 to tTemp
set the currenttime of player "myPlayer" to tTemp
end mouseUp
If this advances your player by one frame then you know that the frame-duration of one frame is 24. So your movie has a framerate of 25 assuming the timescale is 600
If you dont get there post a little more of your problem and we can work it out.
cheers
Bernd
Posted: Tue Dec 09, 2008 12:51 am
by hamlynart
Thanks Bernd,
That's doing something but it seems a little unpredictable - after a few clicks it stops advancing. However, I put a "answer tTemp" at the end and now it advances every click - but of course I don't want a dialog coming up all the time!
Strange that it doesn't work so well without the answer call.
Jim
Posted: Tue Dec 09, 2008 1:19 am
by hamlynart
Hmmm - well on inspection actually the playhead was advancing and very occasionally the frame would jump forward.
I've tinkered with things a bit and its a little better - but still not nearly so good as simply dragging the playhead.
Here's what I've got so far:
Code: Select all
on mouseDown
put the currenttime of player "myPlayer" into tTemp
add 24 to tTemp
set the currenttime of player "myPlayer" to tTemp
put tTemp into fld "myFrame"
end mouseDown
on mouseStillDown
add 24 to tTemp
set the currenttime of player "myPlayer" to tTemp
put tTemp into fld "myFrame"
end mouseStillDown
In the midst of writing this I went back and tried it again. The trick is to have the movie playing - then it works perfectly!!
Thanks a million Bernd.
Jim H
Posted: Tue Dec 09, 2008 1:55 am
by bn
Jim,
it is a little jerky with the mouseDown or mouseStillDown so I tried this in the script of the player
Code: Select all
constant cFrame = 24
local tCurrent
on arrowKey pDirection -- up|down|left|right
if pDirection = "right" then
put the currenttime of player "myPlayer" into tCurrent
send "NextFramePlease" to me in 5 milliseconds
end if
if pDirection is "left" then
put the currenttime of player "myPlayer" into tCurrent
send "prevFramePlease" to me in 5 milliseconds
end if
end arrowKey
on NextFramePlease
add cFrame to tCurrent
set the currenttime of player "myPlayer" to tCurrent
end NextFramePlease
on prevFramePlease
subtract cFrame from tCurrent
set the currenttime of player "myPlayer" to tCurrent
end prevFramePlease
this works really nice for me with the arrowKeys
Anyway I thought you wanted to jump to a frame so it was just to find out the duration of the frame.
There are a lot of things one can do with the player and then there are some things that dont work so well. Let's see...
regards
Bernd
Posted: Tue Dec 09, 2008 9:19 am
by Klaus
Hi Jim,
you really should check Trevors WONDERFUL Enhanced QuickTime External:
http://www.mangomultimedia.com/develope ... ncedqt.php
Beneath other goodies it will let you query the framerate of movies e.g.
Best
Klaus
Posted: Tue Dec 09, 2008 9:55 am
by hamlynart
Thanks for all the help. I'll check out the externals but to be honest I'm getting what I need from:
Code: Select all
set the currenttime of player "myPlayer" to fld "myField"
It jumps about a little but I'm guessing that this is mostly to do with my sensor inputting rogue readings - some filtering to do I suspect.
Cheers
Jim H