Re: QuickTime Time from SMPTE Time
Re: QuickTime Time from SMPTE Time
- Subject: Re: QuickTime Time from SMPTE Time
- From: Nigel Garvey <email@hidden>
- Date: Fri, 24 Aug 2001 14:39:25 +0100
Brennan Young wrote on Thu, 23 Aug 2001 23:44:19 +0200:
>
Anyway, to convert timecodes of the form "00:02:43.09" i.e.
>
Hours:Minutes:Seconds:timescale,
>
you'll need to know the timescale you are working with, for example 30 if
>
it is NTSC.
>
After that it's basic maths.
>
>
The hard part is parsing the timecodes.
>
I thought I could use applescript's text item delimiters but they seem only
>
to be used when converting
>
from lists to strings, not the other way round.
There's some problem with your system or with your script if you can't
use TIDs to convert strings to lists of text items. One problem I
personally found with the parseTimeCode() handler is that the variable
name 'timeStamp' clashes with a Tanaka's OSAX keyword. The following
works for me:
on parseTimeCode(timeStampStr)
try
set AppleScript's text item delimiters to {":"}
set timeUnits to timeStampStr's text items
set AppleScript's text item delimiters to {"."}
set secUnits to timeUnits's last item's text items
set AppleScript's text item delimiters to {""}
set timeUnits to items 1 thru -2 of timeUnits & secUnits
if the result's length is not 4 then error
repeat with thisItem in timeUnits
if thisItem's length is not in {2, 3} then error
set thisItem's contents to thisItem as integer
end repeat
return timeUnits
on error
set AppleScript's text item delimiters to {""}
beep
set prmpt to "Badly formed timecode!" & return
set prmpt to prmpt & "Expected \"HH:MM:SS:ttt\" or \"HH:MM:SS:tt\"
but got "
set prmpt to prmpt & return & "\"" & timeStampStr & "\""
display dialog prmpt buttons {"Rats"} default button 1
return {}
end try
end parseTimeCode
parseTimeCode("00:02:43.09")
--> {0, 2, 43, 9}
NG