【问题标题】:Determine if a video file is NDF or DF (Drop Frame or Non-Drop Frame)确定视频文件是 NDF 还是 DF(丢帧或非丢帧)
【发布时间】:2012-08-27 00:51:23
【问题描述】:

我需要确定一部电影是丢帧还是非丢帧。

我正在尝试在其中一个 xcode 视频框架(QTMovie 或来自 AVFoundation 的东西)中的视频文件的属性中找到它。运气不好。

我这样做是为了在 FCP-X XML 文件中填写必要的信息。

有人有这方面的经验吗?

重要提示,我在 64 位环境中工作,必须留在那里。

【问题讨论】:

    标签: objective-c cocoa avfoundation quicktime


    【解决方案1】:

    您可以使用CMTimeCodeFormatDescriptionGetTimeCodeFlags() 获取给定时间码格式描述参考的时间码标志。您可以通过向AVAssetTrack 询问其formatDescriptions 来获取格式描述参考。

    我认为它看起来像这样:

    BOOL isDropFrame (AVAssetTrack* track)
    {
        BOOL result = NO;
        NSArray* descriptions = [track formatDescriptions];
        NSEnumerator* descriptionEnum = [descriptions objectEnumerator];
        CMFormatDescriptionRef nextDescription;
        while ((!result) && ((nextDescription = (CMFormatDescriptionRef)[descriptionEnum nextObject]) != nil))
        {
            if (CMFormatDescriptionGetMediaType(nextDescription) == kCMMediaType_TimeCode)
            {
                uint32_t timeCodeFlags = CMTimeCodeFormatDescriptionGetTimeCodeFlags ((CMTimeCodeFormatDescriptionRef)nextDescription);
                result = ((timeCodeFlags & kCMTimeCodeFlag_DropFrame) != 0);
            }
        }
        return result;
    }
    

    【讨论】:

    • 谢谢!我已经花了一些时间试图让它工作,但我对它的语法并不完全清楚。我从 AVAssetTrack 调用了 formatDescriptions,它返回一个数组,但我不确定如何将适当的“CMTimeCodeFormatDescriptionRef desc”放入 CMTimeCodeFormatDescriptionGetTimeCodeFlags()。你介意提供一个例子吗?
    • 这看起来可能是它!我必须做的唯一改变是将 [descriptionEnum nextObject] 转换为 (CMFormatDescriptionRef)。还有一个拼写错误……我会修改答案。
    • 太棒了!很高兴我能帮上忙!如果有效,请检查右侧的绿色检查。 :-)
    • 我怎么可能将 23.976 fps 定义为 frameDuration: {1001/24000 = 0.042} 我认为应该是丢帧。但是tcFlags: 2 意味着timecodeFlags & kCMTimeCodeFlag_DropFrame 返回nil
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-12-14
    • 1970-01-01
    • 1970-01-01
    • 2020-01-30
    • 1970-01-01
    • 2018-03-16
    • 2019-01-11
    相关资源
    最近更新 更多