AQRecorder AAC在AVPlayer中播放
问题描述:
我在iOS上录制的aac音频文件存在一些问题。 我需要录制音频并使用AVPlayer播放。录制工作正常,文件已创建。我可以在Mac上播放它。但是当我尝试在AVPlayer中播放它(文件)时 - 没有声音。AQRecorder AAC在AVPlayer中播放
财产记录音频
mRecordFormat.mSampleRate = 8000;
mRecordFormat.mFormatID = kAudioFormatMPEG4AAC;
mRecordFormat.mFormatFlags = kAudioFormatMPEG4AAC_LD;
mRecordFormat.mFramesPerPacket = 0;
mRecordFormat.mChannelsPerFrame = 1;
mRecordFormat.mBitsPerChannel = 0;
mRecordFormat.mBytesPerPacket = 0;
我尝试不同的设置,但没有结果。请帮助
P.S.其他文件(MP3等)正常播放
答
好吧,我找到几年前的解决方案。 更改记录的逻辑来
NSDictionary *settings = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithInt:kAudioFormatMPEG4AAC], AVFormatIDKey,
[NSNumber numberWithFloat:16000], AVSampleRateKey,
[NSNumber numberWithInt:2], AVNumberOfChannelsKey,
[NSNumber numberWithInt:AVAudioQualityMedium], AVSampleRateConverterAudioQualityKey,
[NSNumber numberWithInt:64000], AVEncoderBitRateKey,
[NSNumber numberWithInt:8], AVEncoderBitDepthHintKey,
nil];
error = nil;
_recorder = [[AVAudioRecorder alloc] initWithURL:url settings:settings error:&error];
,并在iOS,安卓和MacOS /赢得这个记录文件播放。所以就是这样。