title: AVAsset tilt with AVAssetExportSession
body: <p>I have this code to add a overlay to my asset and export it to a URL:</p>
  
  <pre><code>AVAsset *videoAsset = editableAsset;
  AVMutableComposition* mixComposition = [AVMutableComposition composition];
  
  AVMutableCompositionTrack *compositionVideoTrack = [mixComposition addMutableTrackWithMediaType:AVMediaTypeVideo preferredTrackID:kCMPersistentTrackID_Invalid];
  AVAssetTrack *clipVideoTrack = [[videoAsset tracksWithMediaType:AVMediaTypeVideo] lastObject];
  AVMutableCompositionTrack *compositionAudioTrack = [mixComposition addMutableTrackWithMediaType:AVMediaTypeAudio preferredTrackID:kCMPersistentTrackID_Invalid];
  
  [compositionVideoTrack insertTimeRange:CMTimeRangeMake(kCMTimeZero, videoAsset.duration) ofTrack:clipVideoTrack atTime:kCMTimeZero error:nil];
  
  if ([videoAsset tracksWithMediaType:AVMediaTypeAudio].count != 0) {
      AVAssetTrack *clipAudioTrack = [[videoAsset tracksWithMediaType:AVMediaTypeAudio] objectAtIndex:0];
      [compositionAudioTrack insertTimeRange:CMTimeRangeMake(kCMTimeZero, videoAsset.duration) ofTrack:clipAudioTrack atTime:kCMTimeZero error:nil];
  }
  
  [compositionVideoTrack setPreferredTransform:[[[videoAsset tracksWithMediaType:AVMediaTypeVideo] lastObject] preferredTransform]];
  
  CGSize sizeOfVideo = [videoAsset naturalSize];
  
  CALayer *layerCa = [CALayer layer];
  layerCa.contents = (id)[UIImage imageNamed:@"Overlay.png"].CGImage;
  layerCa.frame = CGRectMake(0, 0, sizeOfVideo.width, sizeOfVideo.height);
  layerCa.opacity = 1.0;
  
  CALayer *parentLayer=[CALayer layer];
  CALayer *videoLayer=[CALayer layer];
  parentLayer.frame=CGRectMake(0, 0, sizeOfVideo.width, sizeOfVideo.height);
  videoLayer.frame=CGRectMake(0, 0, sizeOfVideo.width, sizeOfVideo.height);
  [parentLayer addSublayer:videoLayer];
  [parentLayer addSublayer:layerCa];
  
  AVMutableVideoComposition *videoComposition=[AVMutableVideoComposition videoComposition] ;
  videoComposition.frameDuration=CMTimeMake(1, 30);
  videoComposition.renderSize = sizeOfVideo;
  videoComposition.animationTool=[AVVideoCompositionCoreAnimationTool videoCompositionCoreAnimationToolWithPostProcessingAsVideoLayer:videoLayer inLayer:parentLayer];
  
  AVMutableVideoCompositionInstruction *instruction = [AVMutableVideoCompositionInstruction videoCompositionInstruction];
  instruction.timeRange = CMTimeRangeMake(kCMTimeZero, [mixComposition duration]);
  AVAssetTrack *videoTrack = [[mixComposition tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0];
  AVMutableVideoCompositionLayerInstruction* layerInstruction = [AVMutableVideoCompositionLayerInstruction videoCompositionLayerInstructionWithAssetTrack:videoTrack];
  instruction.layerInstructions = [NSArray arrayWithObject:layerInstruction];
  videoComposition.instructions = [NSArray arrayWithObject: instruction];
  
  NSString* docFolder = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
  NSString* outputPath = [docFolder stringByAppendingPathComponent:@"output.mov"];
  if ([[NSFileManager defaultManager] fileExistsAtPath:outputPath])
      [[NSFileManager defaultManager] removeItemAtPath:outputPath error:nil];
  
  AVAssetExportSession *exportSession = [[AVAssetExportSession alloc] initWithAsset:editableAsset presetName:AVAssetExportPresetHighestQuality];
  exportSession.videoComposition = videoComposition;
  exportSession.outputURL = [NSURL fileURLWithPath:outputPath];
  exportSession.outputFileType = AVFileTypeQuickTimeMovie;
  [exportSession exportAsynchronouslyWithCompletionHandler:^{
  
      dispatch_async(dispatch_get_main_queue(), ^{
  
          assetURL = [NSURL fileURLWithPath:outputPath];
  
      });
  
  }];
  </code></pre>
  
  <p>The strange think: It tilt the AVAsset and I get a landscape video instead of portrait. But I dont have any code to change the orientation. Can you explain it to me?</p>