0
我想通过使用AVAssetExportSession
来合成两个音频。当我使用AVAsset
通过使用'tracksWithMediaType:AVMediaTypeAudio
'来获取轨道时,我得到一个空数组。 这些音频文件由'AVAudioRecorder
'记录,它们有.aac
扩展名。 我用得到的代码跟踪:AVAsset'tracksWithMediaType'返回一个空数组?(音频)
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.aac