2013-06-24 128 views
2

我正在创建一个视频文件,并在上面创建图像动画。我跟踪导出进度和状态,但导出进度达到1.0后,不会调用完成回调,并且导出状态仍等于“AVAssetExportSessionStatusExporting”。AVAssetExportSession:导出完成后未调用完成回调

AVAssetExportSession *exportSession = [[AVAssetExportSession alloc] initWithAsset:movieAsset presetName:AVAssetExportPresetMediumQuality]; 
self.session = exportSession; 
[exportSession release]; 
session.videoComposition = self.videoComposition; 
NSString *filePath = NSTemporaryDirectory(); 
NSString *fileName = [[@"Output_" stringByAppendingString:number] stringByAppendingString:@".mov"]; 
filePath = [filePath stringByAppendingPathComponent:fileName]; 
if ([[NSFileManager defaultManager] fileExistsAtPath:filePath]) { 
    [[NSFileManager defaultManager] removeItemAtPath:filePath error:nil]; 
} 
session.fileLengthLimit = 1024 * 1024 * 10; 
session.outputURL = [NSURL fileURLWithPath:filePath]; 
session.outputFileType = AVFileTypeQuickTimeMovie; 
[session exportAsynchronouslyWithCompletionHandler:^{ 
    dispatch_async(dispatch_get_main_queue(), ^{ 
     [self exportDidFinish]; 
    }); 
}]; 

它实际上是创建一个输出文件,它是不可读的。我想看到的是一些错误消息,但导出会话的error属性保持空白。

+0

所以,你收到一些回调与AVAssetExportSessionStatusExporting?你检查所有的出口状态吗? – birukaze

+0

我有一个重复计时器,它将会话的'progress','status'和'error'属性记录到控制台。但是上述代码中的函数'exportDidFinish'永远不会被调用。 '进度'达到1.0后'status'等于'AVAssetExportSessionStatusExporting' – pckill

回答

0

显然,视频文件本身存在问题。我从Apple samples下载了一个示例视频sample_iPod.m4v,并且所有内容均按预期工作。奇怪的是我的文件和样本都是用H.264编码的。是什么让我感到困惑的是,未显示任何错误 - 无论是在控制台也不AVExportSession对象error属性:

2013-07-02 12:56:06.521 test[2330:907] Export running - [progress: 0.838969, error: nil]

2013-07-02 12:56:09.020 test[2330:907] Export running - [progress: 0.932188, error: nil]

2013-07-02 12:56:11.519 test[2330:907] Export running - [progress: 0.999630, error: nil]

2013-07-02 12:56:14.023 test[2330:907] Export running - [progress: 1.000000, error: nil]

2013-07-02 12:56:16.519 test[2330:907] Export running - [progress: 1.000000, error: nil]

...

+0

我遇到同样的问题,但只在IOS7上。然而,我的文件被导出,是我生成的一个视频文件,因此IOS7发生了损坏。你知道为什么文件被损坏吗?我可以将输出更改为不同的输出文件格式,并且偶尔会工作。 – kungfoo

+0

不,我不知道视频文件有什么问题,对不起。 – pckill