Some messy functions for video editing AVFoundation on mac OSX