2
我使用後續代碼將caf格式轉換爲m4a格式並保存到Iphone的另一個目錄,它在IOS6中與Xcode 4.6.3一起工作,但是當我更新到Xcode 5時,它是不再工作了。如果在Xcode 5中使用IOS6模擬器,它會再次運行。無法將caf格式轉換爲m4a格式
-(void)saveFile {
NSString *docDirPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
outputFile = [NSURL fileURLWithPath:[docDirPath stringByAppendingPathComponent: [NSString stringWithFormat: @"%i.m4a", currentCueIndex + 1000]]];
}
所以我想知道它是IOS 7的bug還是蘋果改變了一些東西?
感謝
更新
AVURLAsset *audioAsset = [[AVURLAsset alloc]initWithURL:recordedTmpFile options:nil];
AVMutableComposition *mixComposition = [AVMutableComposition composition];
AVMutableCompositionTrack *compositionTrackA = [mixComposition addMutableTrackWithMediaType:AVMediaTypeAudio preferredTrackID:kCMPersistentTrackID_Invalid];
AVAssetTrack *clipAudioTrack = [[audioAsset tracksWithMediaType:AVMediaTypeAudio] lastObject];
[compositionTrackA insertTimeRange:CMTimeRangeMake(kCMTimeZero, audioAsset.duration) ofTrack:clipAudioTrack atTime:kCMTimeZero error:nil];
AVAssetExportSession *exporter =[[AVAssetExportSession alloc] initWithAsset:mixComposition presetName:AVAssetExportPresetAppleM4A];
[self saveFile];
NSParameterAssert(exporter!=nil);
exporter.outputFileType=AVFileTypeAppleM4A;
exporter.outputURL=outputFile;
// Subtract a fraction of a second so the first word isn't chopped off
clipStartTime = clipStartTime - kSilenceBeforeFirstAudio;
CMTime start=CMTimeMake(clipStartTime * 100, 100);
CMTime duration=CMTimeMake(clipDuration * 100, 100);
CMTimeRange range=CMTimeRangeMake(start, duration);
exporter.timeRange=range;
[exporter exportAsynchronouslyWithCompletionHandler:nil];
哪裏是你的代碼,你轉換文件,您剛剛張貼代碼的文件路徑。 – rckoenes
我更新了更多代碼。 @rckoenes – Muke