title: Error while saving captured audio using AVAssetWriterInput
body: <p>We are developing an audio recording application for 10.7.5 and above.
  We are using <code>AVCaptureAudioDataOutput</code> to capture audio and data is written using <code>AVAssetWriterInput</code>.</p>
  
  <p>Properties set to the <code>AVAssetWriterInput</code> as below:</p>
  
  <p><strong>AVFormatIDKey         : kAudioFormatMPEG4AAC</strong><br/>
  <strong>AVSampleRateKey       : This values is taken from device using below code</strong>  </p>
  
  <pre><code> AudioStreamBasicDescription streanDesc;
   UInt32 propSize = sizeof(AudioStreamBasicDescription);
   AudioDeviceGetProperty(mInputDevice, 0, YES, kAudioDevicePropertyStreamFormat, &amp;propSize,&amp;streanDesc);
  </code></pre>
  
  <p><strong>AVNumberOfChannelsKey     : This is taken from AudioStreamBasicDescription.</strong><br/>
  <strong>AVEncoderBitRateKey   : This is hardcoded to 96000.</strong></p>
  
  <p>This works fine for most of the audio device except for USB mic of sample rate 32khz and iSight device with sample rate 48khz.
  When we use these two devices as input audio device, while writing audio data we are getting  the following error -</p>
  
  <pre><code>Error Domain=AVFoundationErrorDomain Code=-11821 "Cannot Decode" UserInfo=0x279470 {NSLocalizedFailureReason=The media data could not be decoded. It may be damaged., NSUnderlyingError=0x292370 "The operation couldn’t be completed. (OSStatus error 560226676.)", NSLocalizedDescription=Cannot Decode}".
  </code></pre>
  
  <p>However in case of USB mic if we hardcode the <code>AVSampleRateKey</code> to 44100 it works perfectly fine but does not work for iSight device. </p>
  
  <p>What is correct value to be provided for <code>AVSampleRateKey</code>? Can any one help me to resolve this issue.</p>