Determine if a video file is NDF or DF (Drop Frame or Non-Drop Frame)

一笑奈何 提交于 2019-12-08 13:25:01

问题


I need to find whether a movie is Drop Frame or Non-Drop Frame.

I'm trying to find it in the attributes for a video file in one of the xcode video frameworks (either QTMovie or something from AVFoundation). Not having much luck.

I'm doing this to fill in necessary information in an FCP-X XML file.

Does anyone have any experience with this?

Important note, I am working in a 64 bit environment, and must stay there.


回答1:


You can use CMTimeCodeFormatDescriptionGetTimeCodeFlags() to get the time code flags for a given timecode format description ref. You can get the format description ref by asking an AVAssetTrack for its formatDescriptions.

I think it would look something like this:

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;
}


来源:https://stackoverflow.com/questions/12135167/determine-if-a-video-file-is-ndf-or-df-drop-frame-or-non-drop-frame

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!