有没有办法使用AppleScript读取Quicktime电影的时间码轨道?

3
我希望您能够在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,视频灰度:false,音频采样大小:0,类:轨道,音频采样率:0.0,声音平衡:0,预加载:false,流比特率:-1.0,持续时间:960300,语言:"英语",音频通道数:0,层:0,内容:缺失值,低音增益:0,开始时间:0,数据格式:"时间码",高音增益:0,音频特征:false,声音音量:0,掩码:缺失值,视频深度:0,位置:{0,0},ID:4,高质量:false,去隔行扫描字段:false,href:"",自然尺寸:{0,0},单个场:false,种类:"时间码",索引:4,数据大小:38412,视觉特征:false,数据速率:100,永不清除:false,透明度:49,章节列表:{},名称:"时间码轨道",备用:{},操作颜色:{32768,32768,32768},启用:true,类型:"tmcd",流品质:-1.0,传输模式:传输模式未知,当前矩阵:{ {1.0, 0.0, 0.0}, {0.0, 1.0, 0.0},{0.0, 0.0, 1.0} }。
其中没有任何与时间码有关的属性。请注意,内容属性为"缺失值"。
如果我尝试获取电影的当前时间,即使时间码不从0开始,它也会返回0。
根据我迄今在网上找到的信息,我认为这是不可能的。请证明我错了。
谢谢! -stib
2个回答

2

我找到了一个解决方法。有一个名为timecodereader的开源命令行应用程序,可以在这里找到。

现在需要进行一些修改,在timecodereader.m文件的152行,需要将输出从stderr更改为stdout,以便AppleScript可以读取结果。修改如下:

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

为了

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

一旦您构建好并将结果放在可执行路径中,您就可以直接使用。
set theStartTC to do shell script "timecodereader /Posix/Path/To/My/Movie.mov"

它返回一个包含时间码第一帧的字符串。


1
你可能只需要重定向标准错误流。在shell命令字符串的末尾加上 2>&1 就可以将标准错误流重定向到标准输出流所指向的位置。 - Chris Johnsen

0
你可以使用曲目名称而不是种类:
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

我可以获取曲目,使用种类或名称,只是我无法访问该曲目中的时间码。 - stib

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接