Основные проблемы AVAssetReader чтение образцов видео

Я ищу, чтобы прочитать образцы видео через AVAssetReader, и я сталкиваюсь со всеми видами препятствий. Может ли какой-то один пост-код, который устанавливает AVAsset из видео с именем Movie.m4v из пакета приложений и использует AVAssetReader для циклического просмотра видеокадров (CMSampleBufferRef).

Вот часть кода, который я использую сейчас , который не работает :

NSString *path = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"Movie.m4v"];
AVAsset *avAsset = [[AVURLAsset alloc] initWithURL:[NSURL URLWithString:path] options:nil];
NSError *error = nil;
AVAssetReader *reader = [[AVAssetReader alloc] initWithAsset:avAsset error:&error]; // crashing right around here!

// I've gotten avassetreader to not crash upon initialization by grabbing an asset from the ALAssetsLibrary but it says it has 0 tracks!

NSArray *videoTracks = [avAsset tracksWithMediaType:AVMediaTypeVideo]; 
AVAssetTrack *videoTrack = [videoTracks objectAtIndex:0];
NSDictionary *options = [NSDictionary dictionaryWithObject:[NSNumber numberWithInt:kCVPixelFormatType_32BGRA] forKey:(id)kCVPixelBufferPixelFormatTypeKey];
AVAssetReaderTrackOutput *asset_reader_output = [[AVAssetReaderTrackOutput alloc] initWithTrack:videoTrack outputSettings:options];
[reader addOutput:asset_reader_output];
[reader startReading];

CMSampleBufferRef buffer;
while ( [reader status]==AVAssetReaderStatusReading ){

    buffer = [asset_reader_output copyNextSampleBuffer];
    NSLog(@"READING");



}
6
задан zoul 21 June 2011 в 06:54
поделиться