              #videoComposition: AVMutableVideoComposition,
                   #composition: AVMutableComposition) -> AVAssetExportSession {
     let session = AVAssetExportSession(asset: composition, presetName: preset)
-    session.videoComposition = videoComposition
+    session.videoComposition = videoComposition.copy() as AVVideoComposition
     // session.outputFileType = "com.apple.m4v-video"
-    session.outputFileType = AVFileTypeAppleM4V
+    // session.outputFileType = AVFileTypeAppleM4V
+    session.outputFileType = AVFileTypeQuickTimeMovie
     return session
 }
 

import Cocoa
import AVFoundation

// Set the transition duration time to one second.
let transDuration = CMTimeMake(1, 1)

// The movies below have the same dimensions as the movie I want to generate
let movieSize = CGSizeMake(400, 252)

// This is the preset applied to the AVAssetExportSession.
let exportPreset = AVAssetExportPresetAppleM4VCellular

// Path and file name to where the generated movie file will be created.
// If a previous file was at this location it will be deleted before the new
// file is generated. BEWARE
let exportFilePath:NSString = "~/Desktop/TransitionsMovie.m4v"

// Create the list of paths to movie files that generated movie will transition between.
// The movies need to not have any copy protection.

let movieFilePaths = [
    "~/Movies/clips/418_clip1_sd.m4v",
    "~/Movies/clips/418_clip2_sd.m4v",
    "~/Movies/clips/418_clip3_sd.m4v",
    "~/Movies/clips/418_clip4_sd.m4v",
    "~/Movies/clips/418_clip5_sd.m4v",
    "~/Movies/clips/418_clip6_sd.m4v"
]

// Convert the file paths into URLS after expanding any tildes in the path


    var passThroughTimeRanges:[NSValue] = [NSValue]()
    var transitionTimeRanges:[NSValue] = [NSValue]()
    var cursorTime = kCMTimeZero
            
    for (var i = 0 ; i < assetsWithVideoTracks.count ; ++i)
    {
        let asset = assetsWithVideoTracks[i]
