私はH264ビデオファイルを読み込む機能があります。私はそれを使って多くのビデオファイルを連続して読みたいと思っています。それはファイル(ランダムな時間)のために働くようであり、少数のファイルのために部分的に失敗し(いくつかのフレームを読み込み、すべてのフレームではない)、完全に失敗します(0フレームを読み込みます)。私は同じビデオファイルをループすることでこれをテストしたので、この不確実性は奇妙です。OSX LionでAVAssetReaderを使用してビデオファイルを連続して読み込むことができません
私が取得エラーメッセージは次のとおりです。
エラードメイン= AVFoundationErrorDomainコード= -11800「操作を完了できませんでした」のUserInfo = 0x105d07480 {NSLocalizedFailureReasonが不明なエラーが(-6662)が発生= NSLocalizedDescriptionは操作を= NSUnderlyingError = 0x100159350 "操作を完了できませんでした(OSStatusエラー-6662)。"}
私はARCとOSX Lionを使用しています。すべてのヘルプははるかに高く評価されています
void uncompressMovie(NSString *moviePath) {
AVAsset *asset = [AVAsset assetWithURL:[NSURL fileURLWithPath:moviePath]];
NSArray* video_tracks = [asset tracksWithMediaType:AVMediaTypeVideo];
AVAssetTrack *video_track = [video_tracks objectAtIndex:0];
// Decompress to ARGB with the asset reader
NSDictionary *decompressionVideoSettings = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithUnsignedInt:kCVPixelFormatType_32ARGB], (id)kCVPixelBufferPixelFormatTypeKey,
[NSDictionary dictionary], (id)kCVPixelBufferIOSurfacePropertiesKey,
nil];
AVAssetReaderTrackOutput *asset_reader_output = [AVAssetReaderTrackOutput assetReaderTrackOutputWithTrack:video_track outputSettings:decompressionVideoSettings];
NSError *error = [[NSError alloc] init];
AVAssetReader *asset_reader = [[AVAssetReader alloc] initWithAsset:asset error:&error];
if ([asset_reader canAddOutput:asset_reader_output]) {
[asset_reader addOutput:asset_reader_output];
if ([asset_reader startReading] == YES) {
int count = 0;
while ([asset_reader status]==AVAssetReaderStatusReading) {
sampleBuffer = [asset_reader_output copyNextSampleBuffer];
if (sampleBuffer == NULL) {
if ([asset_reader status] == AVAssetReaderStatusFailed)
break;
else
continue;
}
count++;
// Will do some work here
CFRelease(sampleBuffer);
}
if (count == 0) {
NSLog(@"I am doomed %@", [asset_reader error]);
exit(1);
}
NSLog(@"Processed %d frames from %@", count, moviePath);
} else
NSLog(@"Couldn't start");
}
if ([asset_reader status] != AVAssetReaderStatusCompleted)
[asset_reader cancelReading];
// unlink([moviePath UTF8String]);
}
複数のビデオファイルを読むのに問題がありますが、説明とサンプルコードでは複数のファイルを扱うことができないとの質問があります。私が何かを見逃していない限り、あなたは質問の言語を改善する必要があるようです。 –
私は、同じ時間に多くのファイルではなく、バックファイルを読み込むことを意味することを示しています。 –