2012-03-30 6 views
7

के साथ 3 वीडियो विलय करने में त्रुटि मैं AVAssetExportSession का उपयोग करके 3 वीडियो मर्ज करने (संलग्न) करने का प्रयास कर रहा हूं, लेकिन मुझे यह त्रुटि मिल रही है। अजीब तरह से 1 या 2 वीडियो के लिए यह काम किया।आईओएस 5: AVAssetExportSession

Error Domain=AVFoundationErrorDomain Code=-11820 "Cannot Complete Export" UserInfo=0x458120 {NSLocalizedRecoverySuggestion=Try exporting again., NSLocalizedDescription=Cannot Complete Export} 

मैंने त्रुटि के मामले में फ़ंक्शन को फिर से करने की कोशिश की लेकिन मुझे जो मिला वह केवल अनंत त्रुटि संदेश है। यह मेरे कोड का स्निपेट है।

AVMutableComposition *mixComposition = [AVMutableComposition composition]; 
AVMutableCompositionTrack *compositionTrack = [mixComposition addMutableTrackWithMediaType:AVMediaTypeVideo preferredTrackID:kCMPersistentTrackID_Invalid]; 
NSError * error = nil; 
NSMutableArray * timeRanges = [NSMutableArray arrayWithCapacity:arrayMovieUrl.count]; 
NSMutableArray * tracks = [NSMutableArray arrayWithCapacity:arrayMovieUrl.count]; 

for (int i=0; i<[arrayMovieUrl count]; i++) { 
    AVURLAsset *assetClip = [arrayMovieUrl objectAtIndex:i]; 
    AVAssetTrack *clipVideoTrackB = [[assetClip tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0]; 

    [timeRanges addObject:[NSValue valueWithCMTimeRange:CMTimeRangeMake(kCMTimeZero, assetClip.duration)]]; 
    [tracks addObject:clipVideoTrackB]; 
} 
[compositionTrack insertTimeRanges:timeRanges ofTracks:tracks atTime:kCMTimeZero error:&error]; 

AVAssetExportSession *exporter = [[AVAssetExportSession alloc] initWithAsset:mixComposition presetName:AVAssetExportPreset1280x720]; 
NSParameterAssert(exporter != nil); 
exporter.outputFileType = AVFileTypeQuickTimeMovie; 
exporter.outputURL = outputUrl; 
[exporter exportAsynchronouslyWithCompletionHandler:^{ 
    switch ([exporter status]) { 
     case AVAssetExportSessionStatusFailed: 
      NSLog(@"Export failed: %@", [exporter error]); 
      break; 
     case AVAssetExportSessionStatusCancelled: 
      NSLog(@"Export canceled"); 
      break; 
     case AVAssetExportSessionStatusCompleted: 
      NSLog(@"Export successfully"); 
      break; 
     default: 
      break; 
    } 
    if (exporter.status != AVAssetExportSessionStatusCompleted){ 
     NSLog(@"Retry export"); 
     [self renderMovie]; 
    } 
}]; 

क्या मेरे कोड या आईओएस 5 में कुछ गड़बड़ है?

उत्तर

5

मुझे समस्या मिली है। तो समस्या वास्तव में थी क्योंकि मैं प्रत्येक वीडियो को पूर्वावलोकन मोड में एक साथ प्रदर्शित करने के लिए AVPlayerLayer का उपयोग करता हूं। इस प्रश्न का जिक्र करते हुए AVPlayerItem fails with AVStatusFailed and error code "Cannot Decode", काम करने के लिए अधिकतम 4 एक साथ AVPlayer की अनियंत्रित सीमा है। और इस सीमा से किसी भी तरह AVAssetExportSession को काम करने से रोकता है जब उस समय 4 AVPlayer उदाहरण होता है।

समाधान AVPlayer को निर्यात करने से पहले, या AVPlayer का उपयोग न करने से पहले रिलीज़ करना है।

+0

आप – Edwin

+0

के बजाय उत्परिवर्तनीय संरचना की एक प्रति का उपयोग कर निर्यातक को प्रारंभ भी कर सकते हैं उद्देश्य सी एक्सकोड 8.2.1 में AVPlayer को कैसे रिलीज़ करें? – sohil