2013-10-07 2 views
2

ios 7 (벨소리 소프트웨어 포함)이 작동하지 않습니다. ios 5 및 ios 6이 제대로 작동하고 있습니다. ios 7로 실행하면 벨소리 길이가 원본 파일이 만들어지는 것과 같습니다. 40 초가 필요합니다. 그러나 그것은 300-400 초로 보인다.AVAssetExportSession이 ios 7과 작동하지 않습니다.

- (void)Convert{ 

    AVURLAsset *songAsset = [AVURLAsset URLAssetWithURL:self.audioplayer.url options:nil]; 

    AVAssetExportSession *exporter = [[AVAssetExportSession alloc] 
            initWithAsset: songAsset 
            presetName: AVAssetExportPresetAppleM4A]; 

    //exporter.outputFileType = @"com.apple.m4a-audio"; 

    exporter.outputFileType = AVFileTypeAppleM4A; 

    CMTime start = CMTimeMakeWithSeconds(self.audioplayer.currentTime, 1); 
    CMTime duration = CMTimeMakeWithSeconds(40, 1); 
    CMTimeRange range = CMTimeRangeMake(start, duration); 
    exporter.timeRange = range; 

    NSString *exportFile = [[self kDoc_dosya:self.name] stringByAppendingPathExtension:@"m4r"]; 


    if ([[NSFileManager defaultManager] fileExistsAtPath:exportFile]) 
     [[NSFileManager defaultManager] removeItemAtPath:exportFile error:nil]; 


    NSURL *exportURL = [NSURL fileURLWithPath:exportFile]; 
    exporter.outputURL = exportURL; 

    [exporter exportAsynchronouslyWithCompletionHandler:^{ 

     int exportStatus = exporter.status; 
     switch (exportStatus) { 

      case AVAssetExportSessionStatusFailed: { 

       NSError *exportError = exporter.error; 
       NSLog (@"AVAssetExportSessionStatusFailed: %@", exportError); 
       break; 
      } 
      case AVAssetExportSessionStatusCompleted: { 
       NSLog (@"AVAssetExportSessionStatusCompleted--"); 
       break; 
      } 
      case AVAssetExportSessionStatusUnknown: { NSLog (@"AVAssetExportSessionStatusUnknown"); break;} 
      case AVAssetExportSessionStatusExporting: { NSLog (@"AVAssetExportSessionStatusExporting"); break;} 
      case AVAssetExportSessionStatusCancelled: { NSLog (@"AVAssetExportSessionStatusCancelled"); break;} 
      case AVAssetExportSessionStatusWaiting: { NSLog (@"AVAssetExportSessionStatusWaiting"); break;} 
       default: { NSLog (@"didn't get export status"); break;} 
      } 

     }]; 
} 

답변

1

것은이 코드에 오류가 있습니다 사용하는 경우이 시간 범위

[songAsset insertTimeRange:CMTimeRangeMake(kCMTimeZero, songAsset.duration) 
        ofTrack:[[songAsset tracksWithMediaType:AVMediaTypeAudio] objectAtIndex:0] 
         atTime:kCMTimeZero 
         error:nil]; 
+0

을 설정하는 마십시오. 'AVURLAsset'에 대한 표시 가능한 @interface가 selector의 'insertTimeRange : ofTrack : atTime : error :'을 나타냅니다. ' – user1669335

+1

ok. AVMutableComposition * composition = [AVMutableComposition composition]; AVMutableCompositionTrack * track = [composition addMutableTrackWithMediaType : AVMediaTypeAudio preferredTrackID : kCMPersistentTrackID_Invalid]; [트랙 insertTimeRange : CMTimeRangeMake (kCMTimeZero, songAsset.duration) ofTrack : [songAsset tracksWithMediaType : AVMediaTypeAudio] objectAtIndex : 0] atTime : kCMTimeZero 오류 : 닐]; – user1669335

+0

@ user1669335 :이 문제를 해결할 수 있습니까? – nkd

관련 문제