AVAssetWriter audio compression settings for multichannel audio

With a 4 channel audio input, I get error while recording a movie using AVAssetWriter and using LPCM codec. Are 4 audio channels not supported by AVAssetWriterInput? Here are my compression settings:

     var aclSize:size_t = 0
     var currentChannelLayout:UnsafePointer<AudioChannelLayout>? = nil

   /* 
    * outputAudioFormat = CMSampleBufferGetFormatDescription(sampleBuffer)
    *  for the latest sample buffer received in captureOutput sampleBufferDelegate
    */
      if let outputFormat = outputAudioFormat {
               currentChannelLayout = CMAudioFormatDescriptionGetChannelLayout(outputFormat, sizeOut: &aclSize)
       }

      var currentChannelLayoutData:Data = Data()

      if let currentChannelLayout = currentChannelLayout, aclSize > 0 {
             currentChannelLayoutData = Data.init(bytes: currentChannelLayout, count: aclSize)
       }

      let numChannels = AVAudioSession.sharedInstance().inputNumberOfChannels

      audioSettings[AVSampleRateKey] =  48000.0
      audioSettings[AVFormatIDKey] = kAudioFormatLinearPCM
      audioSettings[AVLinearPCMIsBigEndianKey] = false
      audioSettings[AVLinearPCMBitDepthKey] = 16
      audioSettings[AVNumberOfChannelsKey] = numChannels
      audioSettings[AVLinearPCMIsFloatKey] = false
      audioSettings[AVLinearPCMIsNonInterleaved] = false
      audioSettings[AVChannelLayoutKey] = currentChannelLayoutData



What error do you see?

AVAssetWriter audio compression settings for multichannel audio
 
 
Q