title: How to fix my orientation issue with merging videos from front and back camera
body: <p>I am merging multiply videos (implantation of pause button) and everything working fine except when merging video from the back camera with video from front camera then one of the videos comes turned upside down in the new video(merged video). My code:</p>
  <pre><code>let mixComposition = AVMutableComposition() 
  
  let videoTrack = mixComposition.addMutableTrackWithMediaType(AVMediaTypeVideo, preferredTrackID: CMPersistentTrackID())
  let trackAudio = mixComposition.addMutableTrackWithMediaType(AVMediaTypeAudio, preferredTrackID: CMPersistentTrackID())
  
  var insertTime = kCMTimeZero
  for var i = 0; i &lt; currentAssets.count; i++ {
      let tracks = currentAssets[i].tracksWithMediaType(AVMediaTypeVideo)
      let audios = currentAssets[i].tracksWithMediaType(AVMediaTypeAudio)
                      
      let assetTrack:AVAssetTrack = tracks[0] as AVAssetTrack
      try videoTrack.insertTimeRange(CMTimeRangeMake(kCMTimeZero, currentAssets[i].duration), ofTrack: assetTrack, atTime: insertTime)
      let assetTrackAudio:AVAssetTrack = audios[0] as AVAssetTrack
      try trackAudio.insertTimeRange(CMTimeRangeMake(kCMTimeZero, currentAssets[i].duration), ofTrack: assetTrackAudio, atTime: insertTime)
      insertTime = CMTimeAdd(insertTime, currentAssets[i].duration)
  }
  videoTrack.preferredTransform = assetTrack.preferredTransform
  
  let documentsURL = NSFileManager.defaultManager().URLsForDirectory(.DocumentDirectory,inDomains: .UserDomainMask).last!
  let mediaURL = documentsURL.URLByAppendingPathComponent(AppMediaFolder)
  let savePath = mediaURL.URLByAppendingPathComponent(&quot;\(NSUUID().UUIDString).mp4&quot;).path!
          
  self.createDirectoryIfExists(mediaURL)
  let url = NSURL(fileURLWithPath: savePath)
          
  currentAssets.removeAll()
  currentAssets.append(AVAsset(URL: url))
          
  //Create Exporter
  let exporter = AVAssetExportSession(asset: mixComposition, presetName: AVAssetExportPresetHighestQuality)!
  exporter.outputURL = url
  exporter.outputFileType = AVFileTypeMPEG4
  exporter.shouldOptimizeForNetworkUse = true
                  
  </code></pre>