title: How to extract and save audio from a .mp4 file
body: <p>I am having a bit of trouble saving an audio file of a .mp4 file. The following code does not seem to be working.</p>
  
  <pre><code>    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES);
  NSString *documentsDirectory = [paths objectAtIndex:0];
  NSString *audioPath = [documentsDirectory stringByAppendingPathComponent:@"soundOneNew.m4a"];
  AVURLAsset *asset = [AVURLAsset URLAssetWithURL:full_url options:nil];
  AVAssetExportSession *exportSession = [AVAssetExportSession exportSessionWithAsset:asset presetName:AVAssetExportPresetPassthrough];
  exportSession.outputURL = [NSURL fileURLWithPath:audioPath];
  exportSession.outputFileType = AVFileTypeAppleM4A;
  CMTime vocalStartMarker = kCMTimeZero;
  CMTime vocalEndMarker = exportSession.asset.duration;
  CMTimeRange exportTimeRange = CMTimeRangeFromTimeToTime(vocalStartMarker, vocalEndMarker);
  
  //supported file types
  NSArray *supportedTypeArray = exportSession.supportedFileTypes;
  
  for (NSString *str in supportedTypeArray){
      NSLog(@"Supported file types  : %@",str);
  }
  
  exportSession.timeRange = exportTimeRange;
  if ([[NSFileManager defaultManager] fileExistsAtPath:audioPath]) {
      [[NSFileManager defaultManager] removeItemAtPath:audioPath error:nil];
  }
  NSLog(@"Audio Path %@", audioPath);
  [exportSession exportAsynchronouslyWithCompletionHandler:^{
      if (exportSession.status == AVAssetExportSessionStatusFailed) {
          NSLog(@"Audio export failed");
      }
      else {
          NSLog(@"AudioLocation : %@",audioPath);
      }
  }];
  </code></pre>
  
  <p>At the end of the execution I won't be getting an audio file in the specified directory.</p>