我想用AVAssetExportSession.When合成两个音频我用AVAsset用'tracksWithMediaType:AVMediaTypeAudio‘得到音轨,我得到一个空数组。这些音频文件是由'AVAudioRecorder‘录制的,并且它们有.aac扩展名。我用来获取跟踪的代码:
AVAsset * asset = [AVAsset assetWithURL:[NSURL URLWithString:model.localPath]];
NSArray * tracks = [asset tracksWithMediaType:AVMediaTypeAudio];
AVAssetTrack * track = nil;
if (tracks.count) {
track = tracks[0];
}初始化AVAudioRecorder的设置
AVAudioSession * audioSession = [AVAudioSession sharedInstance];
[audioSession setCategory:AVAudioSessionCategoryRecord error:nil];
[audioSession setActive:YES error:nil];
NSMutableDictionary *recordSettings = [[NSMutableDictionary alloc] init];
[recordSettings setValue :[NSNumber numberWithInt:kAudioFormatMPEG4AAC] forKey: AVFormatIDKey];
[recordSettings setValue :[NSNumber numberWithFloat:11025.0] forKey: AVSampleRateKey];//44100.0
[recordSettings setValue :[NSNumber numberWithInt:2] forKey: AVNumberOfChannelsKey];
[recordSettings setValue:[NSNumber numberWithInt:AVAudioQualityMax] forKey:AVEncoderAudioQualityKey];我还尝试使用其他.mp3文件来获取跟踪,但它是一个空数组。音频文件的本地路径为:
/var/mobile/Containers/Data/Application/DDAB48C4-A233-4B4C-B3B7-5F66AE076239/Documents/media/1497494042.aachttps://stackoverflow.com/questions/44557616
复制相似问题