私はAVAssetSessionExportを使用してビデオ変換を行っているところに問題があります。 私はUIProgressViewで進捗情報を取得しようとしていますが、私はこのコードセットでは達成できないようです。どのように私はこれを達成することができるかもしれないかに関する提案を得ることができますか?AVAssetSessionExportで進捗情報を常に取得する
(それは私がプログレスバーを更新しています方法ですが、それはうまく動作しません、コメントコードを見て)
NSArray *compatiblePresets = [AVAssetExportSession exportPresetsCompatibleWithAsset:composition];
if ([compatiblePresets containsObject:AVAssetExportPresetHighestQuality]) {
AVAssetExportSession *exportSession = [[AVAssetExportSession alloc]
initWithAsset:composition presetName:AVAssetExportPresetHighestQuality];
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:1];
UITableViewCell *cell = (UITableViewCell *)[(UITableView *)self.view cellForRowAtIndexPath:indexPath];
// UIProgressView *prog = [[UIProgressView alloc] initWithProgressViewStyle:UIProgressViewStyleBar];
// [cell.contentView addSubview:prog];
//
exportSession.outputURL = [NSURL fileURLWithPath:[[ShowDAO userDocumentDirectory] stringByAppendingString:exportFilename]];
exportSession.outputFileType = AVFileTypeQuickTimeMovie;
CMTime start = CMTimeMakeWithSeconds(0, 1);
CMTime duration = CMTimeMakeWithSeconds(1000, 1);
CMTimeRange range = CMTimeRangeMake(start, duration);
exportSession.timeRange = range;
[exportSession exportAsynchronouslyWithCompletionHandler:^{
switch ([exportSession status]) {
case AVAssetExportSessionStatusCompleted:
NSLog(@"Export Completed");
[DSBezelActivityView removeViewAnimated:YES];
//delete unused video file
[[NSFileManager defaultManager] removeItemAtPath: [[ShowDAO userDocumentDirectory] stringByAppendingString:videoFilename] error: NULL];
break;
case AVAssetExportSessionStatusFailed:
NSLog(@"Export failed: %@", [[exportSession error] localizedDescription]);
break;
case AVAssetExportSessionStatusCancelled:
NSLog(@"Export cancelled");
break;
default:
break;
}
}];
// while (exportSession.progress <=0.1){
// NSLog(@"prog : %f",exportSession.progress);
// [prog setProgress:exportSession.progress];
//// sleep(1);
// }
[exportSession release];