저는 caf 형식의 오디오 파일을 만드는 iPhone 음성 녹음 응용 프로그램을 개발 중입니다.iPhone : CAF 파일에 녹음하면 정적으로 만 생성됩니다.
내가이 파일들을 재생할 때, 여기서 유일하게 정적 인 것이 있습니다. 또한, 파일의 크기는 매우 크다. 10 초 녹음시 최대 1.7MB.
mp3와 같은 다른 형식으로 녹음 할 수 있습니까? 누구든지 그렇게하는 방법에 대한 몇 가지 예제 코드가 있습니까?
감사합니다.
저는 caf 형식의 오디오 파일을 만드는 iPhone 음성 녹음 응용 프로그램을 개발 중입니다.iPhone : CAF 파일에 녹음하면 정적으로 만 생성됩니다.
내가이 파일들을 재생할 때, 여기서 유일하게 정적 인 것이 있습니다. 또한, 파일의 크기는 매우 크다. 10 초 녹음시 최대 1.7MB.
mp3와 같은 다른 형식으로 녹음 할 수 있습니까? 누구든지 그렇게하는 방법에 대한 몇 가지 예제 코드가 있습니까?
감사합니다.
이렇게하려면 AVAudioRecorder 클래스를 사용해야합니다. AVAudioRecorder reference
그런 다음, 다음과 같은 코드를 사용할 수 있습니다 : 여기에 개발자 참조에 대한 링크입니다
// Init audio with record capability
AVAudioSession *audioSession = [AVAudioSession sharedInstance];
[audioSession setCategory:AVAudioSessionCategoryPlayAndRecord error:nil];
// Set recording setting
NSMutableDictionary* recordSetting = [[NSMutableDictionary alloc] init];
[recordSetting setValue :[NSNumber numberWithInt:kAudioFormatMPEGLayer3] forKey:AVFormatIDKey];
[recordSetting setValue:[NSNumber numberWithFloat:48000] forKey:AVSampleRateKey];
[recordSetting setValue:[NSNumber numberWithInt: 2] forKey:AVNumberOfChannelsKey];
// Create a AVAudioRecorder object
tmpUrl = [NSURL fileURLWithPath:[NSTemporaryDirectory() stringByAppendingPathComponent: [NSString stringWithFormat: @"tmp.mp3"]]];
AVAudioRecorder *recorder = [[AVAudioRecorder alloc] initWithURL:tmpUrl settings:recordSetting error:nil];
// Start the recorder
[recorder record];
// record your voice here
[recorder stop];
// Play recorded sound
AVAudioPlayer *player = [[AVAudioPlayer alloc] initWithContentsOfURL:tmpUrl error:nil];
[player play];
다음
당신이이!
이 질문은 귀하를 도울 수있는 충분한 세부 정보를 제공하지 않습니다. 예를 들어 더 많은 정보가 필요합니다. 어떤 특정한 방법으로 기록하고 있습니까? – TechZen