         videoComposition.frameDuration = videoAssetTrack.minFrameDuration
         videoComposition.instructions = [instruction]
         videoComposition.animationTool = AVVideoCompositionCoreAnimationTool(postProcessingAsVideoLayer: videoLayer, inLayer: parentLayer)
-        
         
         
         let outputUrl = VideoMaskingUtils.getPathForTempFileNamed("output.mov")

        
        let videoFrameRect = CGRect(x: 0, y: 0, width: width, height: height)
        
        
        let firstVideoCompositionInstruction = AVMutableVideoCompositionInstruction()
        // Set the time range of the first instruction to span the duration of the first video track.
        firstVideoCompositionInstruction.timeRange = sourceVideoDuration
        
        let secondVideoCompositionInstruction = AVMutableVideoCompositionInstruction()
        secondVideoCompositionInstruction.timeRange = sourceVideoDuration
        
        let firstVideoLayerInstruction = AVMutableVideoCompositionLayerInstruction(assetTrack:mutableVideoCompositionTrack)
        firstVideoLayerInstruction.setTransform(videoAssetTrack.preferredTransform, atTime: kCMTimeZero)
        
        let secondVideoLayerInstruction = AVMutableVideoCompositionLayerInstruction(assetTrack:mutableVideoCompositionTrackTwo)
        secondVideoLayerInstruction.setTransform(secondVideoAssetTrack.preferredTransform, atTime: kCMTimeZero)
        
        
        firstVideoCompositionInstruction.layerInstructions = [firstVideoLayerInstruction]
        secondVideoCompositionInstruction.layerInstructions = [secondVideoLayerInstruction]
        
        let mutableVideoComposition = AVMutableVideoComposition(propertiesOfAsset: sourceVideo)
        mutableVideoComposition.instructions = [firstVideoCompositionInstruction, secondVideoCompositionInstruction]
        mutableVideoComposition.renderSize = videoFrameRect.size
        
        let outputUrl = VideoMaskingUtils.getPathForTempFileNamed("output.mov")
        
        VideoMaskingUtils.exportCompositedVideo(mutableCompositon, toURL: outputUrl, withVideoComposition: mutableVideoComposition)
        
        VideoMaskingUtils.removeTempFileAtPath(outputUrl.absoluteString)
    }

        parentLayer.addSublayer(videoLayer)
        parentLayer.addSublayer(watermarkLayer)
        
        let layerInstruction = AVMutableVideoCompositionLayerInstruction(assetTrack: mutableVideoCompositionTrack)
        layerInstruction.setTransform(mutableVideoCompositionTrack.preferredTransform, atTime: kCMTimeZero)
        layerInstruction.setOpacity(0.0, atTime: sourceVideoDuration.duration)
