Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AQRecorder AAC play in AVPlayer

I have some problem with recorded aac audio file on iOS. I need record audio and play it with AVPlayer. Recording work fine, file created. i can play it on Mac. But when i try play it(file) in AVPlayer - no sound.

property for record audio

mRecordFormat.mSampleRate       = 8000;
mRecordFormat.mFormatID         = kAudioFormatMPEG4AAC;
mRecordFormat.mFormatFlags      = kAudioFormatMPEG4AAC_LD;
mRecordFormat.mFramesPerPacket  = 0;
mRecordFormat.mChannelsPerFrame = 1;
mRecordFormat.mBitsPerChannel   = 0;
mRecordFormat.mBytesPerPacket   = 0;

i try different setting but no results. Help please

P.S. Other files(mp3 etc) playing normaly

like image 649
DimasSup Avatar asked Nov 18 '25 04:11

DimasSup


1 Answers

Ok, i find solution couple years ago. I change record logic to

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];

and this recorded file play on iOS, Android and MacOS/Win. So it's all.

like image 88
DimasSup Avatar answered Nov 20 '25 18:11

DimasSup



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!