How to set audio sample rate on AVCaptureSession?
Asked Answered
K

1

6

I am using AVCaptureSession to record video and audio into sample buffers using AVCaptureVideoDataOutput and AVCaptureAudioDataOutput.

The default audio sample rate for the iPhone (4 and 4S) is 44100Hz. I would like to set this to 48000Hz however AVCaptureSession does not seem to have any settings for audio sample rate.

I have tried to use AVAudioSession to change the hardware sample rate (using setPreferredHardwareSampleRate) but though it reports the hardware sample rate as changed (after activating the session) this does not affect the actual rate of samples I'm getting in AVCaptureAudioDataOutput's sample delegate.

Is there any way to set the audio sample rate from within AVCaptureSession itself?

Kalk answered 24/7, 2012 at 13:33 Comment(1)
Nope. I ended up writing my own code for resampling the data buffers in software. I had to do this on the device but if you're streaming this should probably better be done server side.Kalk
K
0

Per Apple support, there is no way to do this in iOS 5. They suggest this feature might be added in a later version, maybe even 6.

Kalk answered 1/8, 2012 at 6:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.