问题
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