Writing metadata to video with AVFoundation

I am trying to build a tool to concatenate two MP4 videos while maintaining crucial metadata within. The metadata is in the source video both as header metadata and as a timecode track. I've been trying for starters to simply read a single MP4 using AVAsset and write that same video out using AVAssetExportSession and AVMutableComposition. I find that even though I add all tracks from the source asset to the composition and also set the export session's metadata to be equal to the source asset's metadata, if I read the result after exporting, I find that none of the header metadata is present, and the timecode track is also not present. How can I get these metadata pieces to be actually written out?
Writing metadata to video with AVFoundation
 
 
Q