1

我有一个奇怪的(对我来说)问题。我用我的 iphone 3gs 录制了两个 .mov 文件。当我在 mac 上打开它们时,它们是 640x480。当我在我的应用程序中打开时,使用 AVURLAsset、AVAssetReader 等的标准调用......我仍然得到 480x360。

你们中有人可以帮助(澄清)这个吗?正常吗?当我从相机捕捉时,我可以以 640x480 运行,即 CMSampleBuffer 具有正确的宽度和高度,因此我创建的 UIImage 更远。

AVURLAsset* asset;
NSString* fileBundle;
NSURL* url;
NSError* error;
NSArray* videoTracks;
AVAssetTrack* track;
NSMutableDictionary* dictionary;

fileBundle = [[NSBundle mainBundle] pathForResource:@"TestMovies/movie1" ofType:@"mov"];
url = [NSURL fileURLWithPath:fileBundle];

asset = [[AVURLAsset alloc] initWithURL:url options:nil];
movieAsset = [[AVAssetReader alloc] initWithAsset:asset error:&error];
videoTracks = [asset tracksWithMediaType:AVMediaTypeVideo];
track = [videoTracks objectAtIndex:0];
dictionary = [[NSMutableDictionary alloc] init];
[dictionary setObject:[NSNumber numberWithInt:kCVPixelFormatType_32BGRA] forKey:(id)kCVPixelBufferPixelFormatTypeKey];
movieOutput = [[AVAssetReaderTrackOutput alloc] initWithTrack:track outputSettings:dictionary];
[movieAsset addOutput:movieOutput];
[movieAsset startReading];

然后,在一个定时成员中:

if( [movieAsset status] == AVAssetReaderStatusReading ) {
    CMSampleBufferRef buf;
    UIImage* img = [[UIImage alloc] initWithCMSampleBufferRef:buf];

显然 UIImage 的扩展包含在项目中......

4

0 回答 0