来自Quick Time的SMPTE TimeCode

时间:2011-09-05 15:54:40

标签: objective-c xcode cocoa

如何获取时间码开始和QT电影的持续时间?我已经发现我必须使用QTKIt和QTStringFromSMPTETime,但我在网上找不到任何例子。

1 个答案:

答案 0 :(得分:0)

以下是使用QTKit和QuickTime API的示例:

QTTrack * tcTrack = [[self.movie tracksOfMediaType:QTMediaTypeTimeCode] objectAtIndex:0];
if (tcTrack != nil) {
    QTMedia * media = [tcTrack media];
    if (media != nil) {
        NSLog(@"sample : %@", [media attributeForKey:QTMediaSampleCountAttribute]);
        Media qtMedia = [media quickTimeMedia];
        MediaHandler mh = GetMediaHandler(qtMedia);
        long frameNum;
        TimeCodeDef tcDef;
        TimeCodeRecord tcData;
        UserData srcRefH;
        TCGetTimeCodeAtTime(mh, 0, &frameNum, &tcDef, &tcData, &srcRefH);
        // frameNum holds the frame number since 00:00:00:00
        // tcData holds the HH:MM:SS:FF data
    }
}