有没有办法用applescript读取Quicktime电影的时间码轨迹

有没有办法用applescript读取Quicktime电影的时间码轨迹,applescript,quicktime,Applescript,Quicktime,我想从Applescript中的quicktime电影中提取时间码 通过使用此脚本 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

我想从Applescript中的quicktime电影中提取时间码

通过使用此脚本

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
我可以得到时间码轨迹,轨迹的属性是:

{是音频可变速率:true,是视频 灰度:假,音频样本大小:0, 类别:曲目,音频采样率:0.0, 声音平衡:0,预载:假, 流式传输比特率:-1.0, 时长:960300,语言:“英语”, 音频通道计数:0,层:0, 内容:缺少值,低音增益:0, 开始时间:0,数据格式:“时间码”, 高音增益:0,音频 特征:假,音量:0, 掩码:缺少值,视频深度:0, 位置:{0,0},id:4,高 质量:假,逐行扫描 字段:false,href:,natural 维度:{0,0},单个字段:false, 种类:“时间代码”,索引:4,数据 尺寸:38412,可视 特征:错误,数据速率:100, 从不清除:错误,透明度:49, 章节列表:{},名称:“时间码轨道”, 备选:{},操作颜色:{32768, 32768,32768},enabled:true, 类型:“tmcd”,流媒体质量:-1.0, 传输模式:传输模式未知, 维度:{0,0},当前 矩阵:{1.0,0.0,0.0},{0.0,1.0, 0.0},{0.0,0.0,1.0}

这些似乎都与时间码无关。请注意,contents属性是“缺少值”

如果我尝试获取电影的当前时间,它将返回0,即使时间码不是从0开始

根据我在网上的发现,我认为这是不可能的。请证明我错了

短暂性脑缺血发作
-stib

我找到了一个解决办法。有一个开源的命令行应用程序叫做timecodereader

现在需要对timecodereader.m的第152行进行一些修改,您需要将输出从stderr更改为stdout,以便applescript可以读取结果。像这样:

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

一旦您构建了它并将结果放入您的可执行路径中,您就可以使用它了

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

它返回一个带有第一帧时间码的字符串。

您可以使用曲目的名称而不是种类:

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

我可以用它的种类或名称来获取曲目,只是我无法访问该曲目中的时间码。你可以重定向stderr。将'2>&1'放在shell命令字符串的末尾,将stderr重定向到stdout要去的任何地方。
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