0
votes

I would like to record audio using AVCaptureSession, and Audio only (without video). I followed RosyWriter sample (removing all code concerning video), but when I create my AsseWriter for audio I have an error with hte line :

assetWriter = [[AVAssetWriter alloc] initWithURL:captureURL fileType:(NSString*)kUTTypeAUdio error:&error];

the error is : Invalide file type UTI...

captureURL is as following :

NSURL captureURL = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@%@", NSTemporaryDirectory(), @"captureTest.mp3"]];

Do you know how to fix it ? I tried with kUTTypeMP3 or kUTTypeMPEG4Audio but nothing change.

I try to use only audio, because I need to do a AVCaptureSession and separate audio from video to send them separatly to a server.

I'm interested in any sample of code that can help me.

Thanks for you help

1

1 Answers

0
votes

kUTTypeAudio is too vague - try something like AVFileTypeWAVE or AVFileTypeAppleM4A.

p.s. iOS doesn't have an mp3 encoder (it does have a decoder)