【发布时间】:2023-12-18 11:29:02
【问题描述】:
我正在使用 AVCaptureAudioDataOutputSampleBufferDelegate 捕获音频
_captureSession = [[AVCaptureSession alloc] init];
[self.captureSession setSessionPreset:AVCaptureSessionPresetLow];
// Setup Audio input
AVCaptureDevice *audioDevice = [AVCaptureDevice
defaultDeviceWithMediaType:AVMediaTypeAudio];
AVCaptureDeviceInput *captureAudioInput = [AVCaptureDeviceInput deviceInputWithDevice:audioDevice error:&error];
if(error){
NSLog(@"Error Start capture Audio=%@", error);
}else{
if ([self.captureSession canAddInput:captureAudioInput]){
[self.captureSession addInput:captureAudioInput];
}
}
// Setup Audio output
AVCaptureAudioDataOutput *audioCaptureOutput = [[AVCaptureAudioDataOutput alloc] init];
if ([self.captureSession canAddOutput:audioCaptureOutput]){
[self.captureSession addOutput:audioCaptureOutput];
}
[audioCaptureOutput release];
//We create a serial queue
dispatch_queue_t audioQueue= dispatch_queue_create("audioQueue", NULL);
[audioCaptureOutput setSampleBufferDelegate:self queue:audioQueue];
dispatch_release(audioQueue);
/*We start the capture*/
[self.captureSession startRunning];
代表:
- (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection {
// do something with sampleBuffer
}
问题是如何从 sampleBuffer 播放音频?
【问题讨论】:
-
嗨,您找到解决方案了吗?如果是这样,请更新答案。
-
嗨,Newbee,不,仍在搜索
-
任何解决方案。我也陷入了这个问题
-
没有,还没有解决办法
标签: iphone objective-c ios avfoundation