Pregunta

I am recording audio using AVAudioRecorder it is recording smoothly and i can play or get the save file I am using following code to initialize AVAudioRecorder

 NSDictionary *settings = [NSDictionary dictionaryWithObjectsAndKeys:
                          [NSNumber numberWithInt:kAudioFormatMPEG4AAC], AVFormatIDKey,
                          [NSNumber numberWithInt:AVAudioQualityLow], AVEncoderAudioQualityKey,
                          [NSNumber numberWithInt:16], AVEncoderBitRateKey,
                          [NSNumber numberWithInt: 1], AVNumberOfChannelsKey,
                          [NSNumber numberWithFloat:16000], AVSampleRateKey,
                          nil];

NSArray *searchPaths =NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentPath_ = [searchPaths objectAtIndex: 0];
NSString *pathToSave = [documentPath_ stringByAppendingPathComponent:[self dateString]];

self.pathfinal = pathToSave;
NSURL *url = [NSURL fileURLWithPath:pathToSave];
recorder = [[AVAudioRecorder alloc] initWithURL:url settings:settings error:&error];

if (!recorder)
{
    return NO;
}
recorder.delegate = self;
recorder.meteringEnabled = YES;
if (![recorder prepareToRecord])
{
    return NO;
}

if (![recorder record])
{
    return NO;
}

but some of my clients are facing an issue when they stop the recorded (the step where it will save on disk) it does not save anything it creates the file but with no data every time they record.

But when using different iPhone it was not an issue. iPhone had 2gb free hard disk space. Any idea what could be causing that?

¿Fue útil?

Solución

In my case, just try not to use AVEncoderBitRateKey will solve the problem.

See this question.

Otros consejos

There is no need of AVEncoderBitRateKey to record AAC format audio. AAC is a low quality audio recording. AVEncoderBitRateKey is used to record high quality audio.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top