NOTE:- Merge Videos Side By Side WITHOUT Losing Video Quality
I think that is a Very Very Important Question, After a lot of search
To achieve this, I would create a new AVMutableComposition object containing 2 tracks, and set transform on each to place them side by side:
let composition = AVMutableComposition(urlAssetInitializationOptions: <your options>)
let videoTrackA = composition.addMutableTrack(withMediaType:.video, preferredTrackID:kCMPersistentTrackID_Invalid);
let videoTrackB = composition.addMutableTrack(withMediaType:.video, preferredTrackID:kCMPersistentTrackID_Invalid);
videoTrackA.preferredTransform = CGAffineTransform(translationX: <yourX_for_A>, y:0.0)
videoTrackB.preferredTransform = CGAffineTransform(translationX: <yourX_for_B>, y:0.0)
Then. save it using:
let exporter = AVAssetExportSession(asset:<yourAsset>, presetName:<yourPresetName>)
exporter.exportAsynchronously(completionHandler: <yourCompletionHandler>)
(Swift code not tested).
in fact, AVAssetExportSession is for simple needs, and it is too simple for your situation.
You must use AVAssetWriter.
You add AVAssetWriterInput to your AVAssetWriter.
You can configure trasnform of the AVAssetWriterInput using its transform property.
Then, you feed your AVAssetWriterInput with CMSampleBuffer (each images buffer) using append calls.
See full Apple documentation for detailed example: https://developer.apple.com/library/archive/documentation/AudioVideo/Conceptual/AVFoundationPG/Articles/05_Export.html#//apple_ref/doc/uid/TP40010188-CH9-SW2