How do you combine two video files side-by-side for 3d as one movie?

I have a 3d camera app that I'm working on and I am wondering how to put the two videos side-by-side to save to Photos as one video using this delegate method:
Code Block swift
func fileOutput(_ output: AVCaptureFileOutput,
                        didFinishRecordingTo outputFileURL: URL,
                        from connections: [AVCaptureConnection],
                        error: Error?) {


Thank You!
Accepted Answer
Hi there. AVCaptureMovieFileOutput is only capable of recording from one video source at a time. You have a couple of options.
  • Use AVCaptureMultiCamSession + 2 VideoDataOutputs + 1 AVAssetWriter. Get buffers from each of the video data outputs and then composite them into a larger buffer (positioning them side by side), and then pass that new buffer to AVAssetWriter to record to a movie. This is very similar to the sample code we published last year called AVMulticamPip (https://developer.apple.com/documentation/avfoundation/cameras_and_media_capture/avmulticampip_capturing_from_multiple_cameras). This app composites the second camera as a picture-in-picture in the corner of the screen, and changes the primary camera as you double tap on the screen.

  • Use two different AVCaptureMovieFileOutputs to write 2 different movie files to disk -- one representing each camera. After recording, read the two movies back frame by frame and composite them together, and re-write using AVAssetWriter.

Thank You!
How do you combine two video files side-by-side for 3d as one movie?
 
 
Q