Progress bar for AVAssetExportSession

后端 未结 4 609
遇见更好的自我
遇见更好的自我 2021-02-02 11:57

I\'ve got an app that exports an AVMutableComposition into a .mov file, and I\'d like for the user to see the status of the export with a progress bar

4条回答
  •  春和景丽
    2021-02-02 12:55

    Same issue i have faced in iOS 8.0, i resolved it using dispatch quee

    - (void)convertVideoToLowQuailtyWithInputURL:(NSURL*)inputURL outputURL:(NSURL*)outputURL handler:(void (^)(AVAssetExportSession*))handler{
    
    [[NSFileManager defaultManager] removeItemAtURL:outputURL error:nil];
    AVURLAsset *asset = [AVURLAsset URLAssetWithURL:inputURL options:nil];
    
    exportSession2 = [[AVAssetExportSession alloc] initWithAsset:asset presetName:AVAssetExportPresetLowQuality];
    exportSession2.outputURL = outputURL;
    exportSession2.outputFileType = AVFileTypeQuickTimeMovie;
    
    [exportSession2 exportAsynchronouslyWithCompletionHandler:^(void)
     {
         handler(exportSession2);
     }];
    
     dispatch_async(dispatch_get_main_queue(), ^(void){
    
          self.exportProgressBarTimer = [NSTimer scheduledTimerWithTimeInterval:.1 target:self selector:@selector(updateExportDisplay) userInfo:nil repeats:YES];
     });
    

    }

提交回复
热议问题