Hi dear gurus,
Can you please tell me how can I know the duration of any movie that can be played in quicktime, without opening the movie?
I have been messing with the following code…
on open these_items
tell application "Finder" to set sorted_items ¬
to sort these_items by name
activate
repeat with i from 1 to the count of sorted_items
set this_item to (item i of sorted_items)
tell application "QuickTime Player"
tell document this_item
set MovieDuration to the duration
display dialog "Movie duration = " & MovieDuration
end tell
end tell
end repeat
end open
but this is not working…
This is driving me crazy!
Thanks for any help.
Model: PPC MacMini
AppleScript: leopard’s
Browser: Safari 523.10.6
Operating System: Mac OS X (10.5)
it’s possible even without launching QuickTime Player
on open these_items
repeat with oneItem in these_items
tell application "System Events"
try
set q to QuickTime file (oneItem as text)
set MovieDuration to duration of contents of q
display dialog "Movie duration of " & name of q & " = " & MovieDuration
end try
end tell
end repeat
end open
on open these_items
repeat with oneItem in these_items
tell application "System Events"
try
set q to QuickTime file (oneItem as text)
tell (contents of q) to set {timeScale, theDuration} to {time scale, duration}
tell (theDuration / timeScale) to set {hr, mn, sc} to {it div hours, it mod hours div minutes, it mod hours mod minutes div 1}
display dialog "Movie duration of " & name of q & " = " & hr & ":" & mn & ":" & sc
end try
end tell
end repeat
end open
PS: If you want also the number of frames like in SMTPE, then you need QuickTime Player for the frames information
They might – but there’s a chance they may not. It’s possible that it’s broken because it depends on some of the old QuickTime code that has been removed in Mavericks.
I wonder if the command-line tool mils can get what you want from Spotlight data.