This did the magic for me (iOS9, Swift 3, iPhone 6):
Based on: https://www.raywenderlich.com/94404/play-record-merge-videos-ios-swift
Change mainComposition.renderSize to:
mainComposition.renderSize = CGSize(width: self.mainCompositionWidth, height: self.mainCompositionHeight)
where mainCompositionWidth , mainCompositionHeight are CGFloat and are calculated as follows:
self.mainCompositionWidth = UIScreen.mainScreen().bounds.width self.mainCompositionHeight = UIScreen.mainScreen().bounds.height while (self.mainCompositionWidth%16>0) { // find the right resolution that can be divided by 16 self.mainCompositionWidth = self.mainCompositionWidth + 1.0 } while (self.mainCompositionHeight%16>0) { // find the right resolution that can be divided by 16 self.mainCompositionHeight = self.mainCompositionHeight + 1.0 }
Also change the scaleFitRatio in videoCompositionInstructionForTrack to:
scaleToFitRatio = self.mainCompositionWidth / assetTrack.naturalSize.height
This caused the bottom green line to disappear and the video filled the screen.
Andre Simon
source share