录制音频问题

时间:2015-06-05 07:34:53

标签: ios objective-c xcode audio audio-recording

我正在开发一个用于录制视频和音频的应用程序,但似乎音频无效。有时候它有效,但大部分时间都没有。

这是我的代码

self.captureSession = [[AVCaptureSession alloc] init];

[self.captureSession setSessionPreset:AVCaptureSessionPreset352x288];

AVCaptureDevice *videoDevice = [self frontCamera];
AVCaptureDevice *audioDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeAudio];

self.videoInput = [AVCaptureDeviceInput deviceInputWithDevice:videoDevice error:nil];
self.audioInput = [[AVCaptureDeviceInput alloc] initWithDevice:audioDevice error:nil];

self.stillImageOutput = [[AVCaptureStillImageOutput alloc] init];
NSDictionary *stillImageOutputSettings = [[NSDictionary alloc] initWithObjectsAndKeys:
                                          AVVideoCodecJPEG, AVVideoCodecKey, nil];
[self.stillImageOutput setOutputSettings:stillImageOutputSettings];

self.movieOutput = [[AVCaptureMovieFileOutput alloc] init];

// Setup capture session for taking pictures
[self.captureSession addInput:self.videoInput];
[self.captureSession addInput:self.audioInput];
[self.captureSession addOutput:self.stillImageOutput];
[self.captureSession addOutput:self.movieOutput];

0 个答案:

没有答案