The movie duration in QuickTime Player 7 – what are its meas. units?

Hello,

I want to get a user friendly representation as that of hh:mm:ss. The duration property returns the figure of 1154434 for the track. What are the units? I assume those might be milliseconds. The calculation logic is as follows:

on GetTimeCodeFormatted(TheTime)
	
	set timecodems to TheTime
	
	set hh to timecodems div (36 * (10 ^ 5)) -- the whole number of hours in the milliseconds representation.
	
	set intermsec to round ((timecodems mod (36 * (10 ^ 5))) / 1000) rounding as taught in school -- the remainder of seconds converted from milliseconds (the milliseconds are the left operand in the expression in the outer parentheses).
	
	set mm to intermsec div 60 -- the remainder of seconds, calculated in the previous step, converted to the whole number of minutes.
	
	set sec to intermsec mod 60 -- the remainder of seconds from the number of seconds calculated 2 steps back.
	
	if the length of (hh as text) < 2 then
		set hh to "0" & hh
	else
		set hh to hh as text
	end if
	
	if the length of (mm as text) < 2 then
		set mm to "0" & mm
	else
		set mm to mm as text
	end if
	
	if the length of (sec as text) < 2 then
		set sec to "0" & sec
	else
		set sec to sec as text
	end if
	
	
	set timeCodeBrushed to hh & ":" & mm & ":" & sec
	return result
end GetTimeCodeFormatted

Running this handler on the referred number results in 19 min 14 sec which isn’t correct because the actual track duration is 3 min 12 sec. An online unit converter supported the validity of my calculation returning the same number of minutes I’m getting with the code – 19,2 minutes.

Given that, what is 1154434? How do I arrive at proper values other than using the method offered by another user at https://macscripter.net/viewtopic.php?pid=93366#p93366?

Model: MacBook Pro 9,1 (mid-2012 15") Core i7 2.3 GHz, 16 GB RAM, 1TB SSD
AppleScript: 2.7
Browser: Safari 605.1.15
Operating System: macOS 10.14

scrutinizer82. According to the QuickTime Player dictionary, the duration property is returned in seconds. I downloaded an example MOV video, which is 30 seconds long, and that’s what the the following script returned. However, I am using QuickTime Player 10.5 and that could be the reason for our differing results.

set theMovie to (choose file) as text

tell application "QuickTime Player"
	activate
	open file theMovie
	set movieDuration to duration of document 1 --> 30.571
end tell

As far as converting the length of a movie to the desired format, I’ll defer to other forum members who have great expertise in this area.

A minor elaboration on what peavine wrote… seconds as a real number. If you’re getting an integer, it’s likely a different property than duration.

You can confirm this by looking at the dictionary entry for ‘document’. I would guess that the number returned is possibly the data size (aka file size in bytes), or perhaps the data rate. What is the file size of your movie? If you get properties of the video, then it will return the data size, duration, and data rate. And if you don’t want to see any of the other properties, focus on them:

[format]get {data size, duration, data rate} of document 1
→ {184453923, 1420.156, 129882}[/format]

And out of curiosity, what is the file format? If it is an mp4, for example, you could run ‘mdls’ on it in the Terminal, which would provide the file size in bytes, the duration, and the bit rate, which would help you clarify what to expect.

Finally, here is an alternate method of converting to your desired format:

set x to 9111.4 -- seconds (approximately 151 minutes or 2.53 hours)

-- get hours, minutes, seconds
set hh to x div hours
set mm to x mod 3600 div minutes
set ss to round (x mod 3600 mod minutes) rounding as taught in school

-- pad as needed
if length of (mm as text) is 1 then set mm to "0" & mm
if length of (ss as text) is 1 then set ss to "0" & ss

set timeCodeBrushed to hh & ":" & mm & ":" & ss as text

QTP 7 is a different kind of beast compared to QTP X. In QuickTime Player 7, duration is just what’s in the screenshot. It’s not an alias to the data size. I know this because I wrote a variation of this script tackling frames mapped to specific points in the timeline and using the milliseconds metaphor pinpoints exact frames I need.

Model: MacBook Pro 9,1 (mid-2012 15") Core i7 2.3 GHz, 16 GB RAM, 1TB SSD
AppleScript: 2.7
Browser: Safari 605.1.15
Operating System: macOS 10.14