views:

938

answers:

2

I want to extract the timecode from a quicktime movie in Applescript.

By using this script

tell application "QuickTime Player"
    set themovie to open thefile
    set thetracks to tracks of document 1
    repeat with thetrack in thetracks
     if the kind of thetrack is "Timecode" then
      get the properties of thetrack
     end if
    end repeat
end tell

I can get the timecode track, the properties of the track are:

{is audio variable rate:true, is video gray scale:false, audio sample size:0, class:track, audio sample rate:0.0, sound balance:0, preload:false, streaming bit rate:-1.0, duration:960300, language:"English", audio channel count:0, layer:0, contents:missing value, bass gain:0, start time:0, data format:"Timecode", treble gain:0, audio characteristic:false, sound volume:0, mask:missing value, video depth:0, position:{0, 0}, id:4, high quality:false, deinterlace fields:false, href:"", natural dimensions:{0, 0}, single field:false, kind:"Timecode", index:4, data size:38412, visual characteristic:false, data rate:100, never purge:false, transparency:49, chapterlist:{}, name:"Timecode Track", alternate:{}, operation color:{32768, 32768, 32768}, enabled:true, type:"tmcd", streaming quality:-1.0, transfer mode:transfer mode unknown, dimensions:{0, 0}, current matrix:{{1.0, 0.0, 0.0}, {0.0, 1.0, 0.0}, {0.0, 0.0, 1.0}}}

none of which seems to have anything to do with the timecode. Note that the contents property is "missing value"

If I try to get the current time of the movie it returns 0, even if the timecode doesn't start at 0.

I'm thinking by what I've found on the net so far that this is impossible. Please prove me wrong

TIA -stib

+2  A: 

I found a workaround. There is an open source, command line app called timecodereader available here

Now it requires a little hacking, on line 152 of timecodereader.m you need to change the output from stderr to stdout, so that applescript can read the result. Like so:

fprintf(stderr,"%s\n", [timecodeString fileSystemRepresentation]);

to

fprintf(stdout,"%s\n", [timecodeString fileSystemRepresentation]);

once you've built it and put the result in your executable path you can just use

set theStartTC to do shell script "timecodereader /Posix/Path/To/My/Movie.mov"

it returns a string with the first frame of timecode.

stib
Chris Johnsen
ah, of course! thanks!
stib
A: 

you could use the name of the track instead of kind:

on open myfiles

repeat with thefile in myfiles

tell application "QuickTime Player" set themovie to open thefile set thetracks to tracks of document 1 repeat with thetrack in thetracks if the name of thetrack is "Closed Caption Track" then set thetrack's enabled to false

end if

end repeat end tell end repeat end open

Ben Brown
I can get the track ok, using the kind, or the name, it's just that I couldn't access the timecode within that track.
stib