Check whether a video file is interlace/progressive

I am trying to see whether a video file the user has selected is interlaced/progressive, and then do some manipulation depending on that.

I have tried to check whether the cmsamplebuffer i have extracted is defined as top field first or bottom field first however this returns null for all inputs.


NSMutableDictionary *pixBuffAttributes = [[NSMutableDictionary alloc] init];
[pixBuffAttributes setObject:
[NSNumber numberWithInt:kCVPixelFormatType_422YpCbCr8]
forKey:(NSString*)kCVPixelBufferPixelFormatTypeKey];
myAsset = [[AVURLAsset alloc] initWithURL:urlpath options:pixBuffAttributes];
myAssetReader = [[AVAssetReader alloc] initWithAsset:myAsset error:nil];
myAssetOutput = [[AVAssetReaderTrackOutput alloc]initWithTrack:
  [[myAsset tracksWithMediaType:AVMediaTypeVideo]
  objectAtIndex: 0]
  outputSettings:pixBuffAttributes];
[myAssetReader addOutput:myAssetOutput];
[myAssetReader startReading];
CMSampleBufferRef ref = [myAssetOutput copyNextSampleBuffer];
if(CVBufferGetAttachments(ref, kCVImageBufferFieldDetailKey, nil) == nil)
{
  //always the case
}
else
{
  //never happens
}

regardless of the input file's interlacing the above always returns nil. I'm probably trying to test this in totally the wrong manor, so any help much appreciated!

Answered by jeschot in 117782022

You can use the formatDescriptions property of AVAssetTrack, then call CMFormatDescriptionGetExtension with the keys kCMFormatDescriptionExtension_FieldCount and kCMFormatDescriptionExtension_FieldDetail


Jan E.

Accepted Answer

You can use the formatDescriptions property of AVAssetTrack, then call CMFormatDescriptionGetExtension with the keys kCMFormatDescriptionExtension_FieldCount and kCMFormatDescriptionExtension_FieldDetail


Jan E.

Check whether a video file is interlace/progressive
 
 
Q