相关疑难解决方法(0)

播放AVCaptureAudioDataOutputSampleBufferDelegate中的音频

我正在使用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];
Run Code Online (Sandbox Code Playgroud)

代表:

  - (void)captureOutput:(AVCaptureOutput *)captureOutput  didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection …
Run Code Online (Sandbox Code Playgroud)

iphone objective-c avfoundation ios

9
推荐指数
1
解决办法
3262
查看次数

标签 统计

avfoundation ×1

ios ×1

iphone ×1

objective-c ×1