Quicktime Player: Set Player Position to Specified Timecode

Hey all,

Does anyone have the following code handy?

  1. Specify a timecode “00:29:03” or whatever specified
  2. The player position goes to that time code
  3. If possible then plays from that position.

TIA

thanks works great. :slight_smile:

General Films Duration and TIME CODE are very different matters.

Time code is not HH:MM:SEC as it appears in this post but HH:MM:SEC;FR and includes the number of frames, as each second duration varies from 23.98 to 60 according to the standard, the country, the money of the film makers, when the film was shoot and more. Yet once converted to a Quicktime file TIME CODE will return the duration and the number of frames.
Please do not mix up duration and time code as they are very different and require different ways to calculate.

exactly!

If we’re talking about real Time Code (SMPTE), use this


set SMTPE to "10:35:32:20"
set TimeOffset to 10

set {hr, mn, sc, fr} to words of SMTPE
tell application "QuickTime Player"
	tell document 1
		set {currentTime, timeScale, theDuration, FrameCount} to {current time, time scale, duration, count (frames of track "Video track")}
		set FrameRate to (FrameCount * timeScale) / theDuration div 1
		set current time to ((((hr as integer) - TimeOffset) * 3600 + mn * 60 + sc) * FrameRate + fr) * (timeScale / FrameRate)
		play
	end tell
end tell

Is there a way to read a text file where I type something like this:
in “0:05:12:20”
out"0:35:13:22"

in order to tell quicktime to copy this selection

copy the selection

create a new movie

paste the selection

and save with the option to give it the name I need?

thank you very much. I am not really capable of using the Quicktime player dictionary

Danwan

HI,

assuming that the in/out time codes in the text file are in this format

0:05:12:20
0:07:13:22
0:10:01:10
0:12:36:48

try this


global currentTime, timeScale, theDuration, FrameCount, FrameRate

set smpteFile to ((path to desktop as Unicode text) & "smpte.txt")
set theClips to paragraphs of (read file smpteFile)

set theMovie to choose file
tell application "QuickTime Player"
	open theMovie
	tell document 1
		set {currentTime, timeScale, theDuration, FrameCount} to {current time, time scale, duration, count (frames of track "Video track")}
		set FrameRate to (FrameCount * timeScale) / theDuration div 1
	end tell
end tell
repeat with i from 1 to count theClips by 2
	tell application "QuickTime Player"
		tell document 1
			set selection start to my GetTimeFromSMPTE(item i of theClips)
			set selection end to my GetTimeFromSMPTE(item (i + 1) of theClips)
			copy
		end tell
		make new document
		tell document 1
			paste
			save it in (choose file name)
			close
		end tell
	end tell
end repeat

on GetTimeFromSMPTE(SMTPE)
	set {hr, mn, sc, fr} to words of SMTPE
	return (((hr as integer) * 3600 + mn * 60 + sc) * FrameRate + fr) * (timeScale / FrameRate)
end GetTimeFromSMPTE