tell application "QuickTime Player 7"
tell document 1
properties
set numSelectStart to get selection start
set numSelectDura to get selection duration
set aliasCurentMovie to original file as alias
set listNatDimension to natural dimensions as list
end tell
end tell
set theTime to "0"
set theTimeDec to "00"
set theTimeDecNo to "00"
set theTimeInt to "00"
set theTime to numSelectStart as number
set theTime to theTime / 600 as number
set theTimeDec to (theTime mod 1) as text
set theTimeDecNo to doReplace(theTimeDec, "0.", "")
set theTimeInt to theTime - theTimeDec as integer
set theTimeInt to FormatSeconds(theTimeInt)
set theStartTime to "" & theTimeInt & "." & theTimeDecNo & ""
log theStartTime
set theTime to "0"
set theTimeDec to "00"
set theTimeDecNo to "00"
set theTimeInt to "00"
set theTime to numSelectDura as number
set theTime to theTime / 600 as number
set theTimeDec to (theTime mod 1) as text
set theTimeDecNo to doReplace(theTimeDec, "0.", "")
set theTimeIntNo to theTime - theTimeDec as integer
set theTimeInt to FormatSeconds(theTimeIntNo)
set theDuraTime to "" & theTimeInt & "." & theTimeDecNo & ""
log theDuraTime
set theOriginalMovie to POSIX path of aliasCurentMovie as text
set theImageWidth to item 1 of listNatDimension as text
set theImageHeight to item 2 of listNatDimension as text
set theExpFile to (theOriginalMovie & "_" & theImageWidth & "X" & theImageHeight & "_" & theTimeIntNo & "sec.mp4") as text
set theffmpegPath to "'/usr/local/bin/ffmpeg'"
set theCommandCom to (theffmpegPath & " -i \"" & theOriginalMovie & "\" -ss " & theStartTime & " -t " & theDuraTime & " -strict -2 \"" & theExpFile & "\"") as text
log "\n" & theCommandCom & "\n"
return theCommandCom
to doZeroSupp(n)
if n < 10 then
return "0" & n
else
return n as text
end if
end doZeroSupp
to doReplace(theText, orgStr, newStr)
set oldDelim to AppleScript's text item delimiters
set AppleScript's text item delimiters to orgStr
set tmpList to every text item of theText
set AppleScript's text item delimiters to newStr
set tmpStr to tmpList as text
set AppleScript's text item delimiters to oldDelim
return tmpStr
end doReplace
on FormatSeconds(totalSeconds)
set theHours to (totalSeconds div hours)
set theRemainderSeconds to (totalSeconds mod hours)
set theMinutes to (theRemainderSeconds div minutes)
set theRemainderSeconds to (theRemainderSeconds mod minutes)
if length of (theHours as text) = 1 then
set theHours to "0" & (theHours as text)
end if
if length of (theMinutes as text) = 1 then
set theMinutes to "0" & (theMinutes as text)
end if
if length of (theRemainderSeconds as text) = 1 then
set theRemainderSeconds to "0" & (theRemainderSeconds as text)
end if
set theTimeString to theHours & ":" & theMinutes & ":" & theRemainderSeconds as text
return theTimeString
end FormatSeconds