Video export failed Show error AVAssetExportSessionStatusFailed

223 Views Asked by At

I have tried to find out regarding this issue but didn't find any exact solution for this.

 NSString *strPath = @"video.mp4";
 NSURL *URL = [NSURL fileURLWithPath:strPath];
 AVURLAsset *avAsset = [AVURLAsset URLAssetWithURL:URL options:nil];
 AVAssetExportSession *exportSession = [[AVAssetExportSession alloc]initWithAsset:avAsset presetName:AVAssetExportPresetMediumQuality];
 exportSession.shouldOptimizeForNetworkUse = YES;
 NSString *cachesFolder = [NSTemporaryDirectory() stringByAppendingPathComponent: [NSString stringWithFormat:@"%@", [strPath lastPathComponent]]];
 NSURL *fileUrl = [NSURL fileURLWithPath:cachesFolder];
 exportSession.outputURL = fileUrl;
 exportSession.outputFileType = AVFileTypeMPEG4;

 exportSession exportAsynchronouslyWithCompletionHandler:^{
     switch ([exportSession status]) {
        case AVAssetExportSessionStatusFailed:
           NSLog(@"Export failed");
         break;
        case AVAssetExportSessionStatusCompleted:
           NSLog(@"Export Completed");
         break;
       default:
         break;
 }
Log: Export failed
1

There are 1 best solutions below

0
Tornike Davitashvili On

I can not comment :(

I just test your code and everything work fine. Just check in debug "strPath" is correct (export mov file is in bundle)