         
         // 1 - Prepare VideoAssetTrack and DurationTimeRange for further use
         let videoAssetTrack = videoAsset.tracksWithMediaType(AVMediaTypeVideo).first as! AVAssetTrack
-       
+        
         let durationCMTime = CMTimeMakeWithSeconds(Float64(duration), 30)
         let durationTimeRange = CMTimeRangeMake(kCMTimeZero, durationCMTime)
         

        
        composition.animationTool = AVVideoCompositionCoreAnimationTool(postProcessingAsVideoLayer: videoLayer, inLayer: parentLayer)
    }
    
    
}


extension VideoManipulateUtil {
    
    
}


extension VideoManipulateUtil {
    
    
    public func getCoreAnimationBeginTimeAtZero() -> CFTimeInterval {
        return AVCoreAnimationBeginTimeAtZero
    }
    
    public func querySizeWithAssetURL(#videoURL: NSURL) -> CGSize {
        let videoAsset = AVURLAsset(URL: videoURL, options: nil)
        return self.querySize(video: videoAsset)
    }
    
    
    private func querySize(#video: AVAsset) -> CGSize {
        
        let videoAssetTrack = video.tracksWithMediaType(AVMediaTypeVideo).first as! AVAssetTrack
        let videoTransform = videoAssetTrack.preferredTransform
        
        var isVideoAssetPortrait = false
        
        if (videoTransform.a == 0 && videoTransform.b == 1.0 && videoTransform.c == -1.0 && videoTransform.d == 0) {
            isVideoAssetPortrait = true
        }
        if (videoTransform.a == 0 && videoTransform.b == -1.0 && videoTransform.c == 1.0 && videoTransform.d == 0) {
            isVideoAssetPortrait = true
        }
        
        var natureSize = CGSizeZero
        if isVideoAssetPortrait {
            natureSize = CGSizeMake(videoAssetTrack.naturalSize.height, videoAssetTrack.naturalSize.width)
        } else {
            natureSize = videoAssetTrack.naturalSize
        }
        
        return natureSize
    }
}
        
        // 3.2 - Create an AVMutableVideoCompositionLayerInstruction for the video track and fix the orientation.
        let videolayerInstruction = AVMutableVideoCompositionLayerInstruction(assetTrack: videoTrack)
        
        videolayerInstruction.setTransform(videoAssetTrack.preferredTransform, atTime: kCMTimeZero)
        videolayerInstruction.setOpacity(0.0, atTime: videoAsset.duration)
        
