你好,歡迎來到IOS教程網

 Ios教程網 >> IOS編程開發 >> IOS開發綜合 >> iOS-視頻格式轉換(MOV-)MP4)

iOS-視頻格式轉換(MOV-)MP4)

編輯:IOS開發綜合
AVURLAsset *avAsset = [AVURLAsset URLAssetWithURL:[NSURL fileURLWithPath:path] options:nil];
NSArray *compatiblePresets = [AVAssetExportSession exportPresetsCompatibleWithAsset:avAsset];

if ([compatiblePresets containsObject:AVAssetExportPresetLowQuality])

{

AVAssetExportSession *exportSession = [[AVAssetExportSession alloc]initWithAsset:avAsset presetName:AVAssetExportPresetPassthrough];
    NSString *exportPath = [NSString stringWithFormat:@"%@/%@.mp4",
                            [NSHomeDirectory() stringByAppendingString:@"/tmp"],
                            @"1"];
    exportSession.outputURL = [NSURL fileURLWithPath:exportPath];
    NSLog(@"%@", exportPath);
    exportSession.outputFileType = AVFileTypeMPEG4;
    [exportSession exportAsynchronouslyWithCompletionHandler:^{

        switch ([exportSession status]) {
            case AVAssetExportSessionStatusFailed:
                NSLog(@"Export failed: %@", [[exportSession error] localizedDescription]);
                break;
            case AVAssetExportSessionStatusCancelled:
                NSLog(@"Export canceled");
                break;
                case AVAssetExportSessionStatusCompleted:
                NSLog(@"轉換成功");
                break;
            default:
                break;
        }
    }];
}
  1. 上一頁:
  2. 下一頁:
蘋果刷機越獄教程| IOS教程問題解答| IOS技巧綜合| IOS7技巧| IOS8教程
Copyright © Ios教程網 All Rights Reserved