2016-03-10

AVFoundation音频格式在录音过程中变动

Views: 7222 | Add Comments

Mac 在录音过程中, 在下面的方法中处理音频数据:

- (void)captureOutput:(AVCaptureOutput *)captureOutput
        didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
        fromConnection:(AVCaptureConnection *)connection

不过, 音频的采样率, 位深, 声道数有可能经常变动. 要注意!

可以这样设置:

NSDictionary *settings = @{
                           AVFormatIDKey: @(kAudioFormatLinearPCM),
                           AVLinearPCMBitDepthKey: @(16),
                           AVLinearPCMIsFloatKey : @(NO),
                           // AVSampleRateKey: @(44100), // not for MAC
                           };
_audioDataOutput.audioSettings = settings;

仅对 Mac 有效, iOS 不能用.

Related posts:

  1. Xcode修改编译输出的目录
  2. iOS 应用修改状态栏和导航栏颜色
  3. 修改Xcode项目编译输出路径
  4. Google Talk 界面开发分析
  5. 把Firefox的播放背景音乐功能去掉
Posted by ideawu at 2016-03-10 15:21:54

Leave a Comment