Sti
Sti

Reputation: 8503

Merging / Overlapping captured videos in iOS

I am trying to merge two videos filmed with the device. I want the end result (the two different video files) to be merged together as one. I can't find any framework-info/documentation on merge-lapping videos anywhere. I've been reading up on AVFoundation for capture and playback, but I can't find anything on this. I am not talking about the usual editing, like adding at the end of another clip, but more like playing them at the same time. To visually represent what I'm looking for:

 Video 1       Video 2
 --------      --------
|        |    |        |
|        |    |        |
|        |    |        |
|   v1   |    |   v2   |
|        |    |        |
|        |    |        |
 --------      --------


Result:

 --------------
|         |    |
|         | v2 |
|         |    |
|          ----|
|      v1      |
|              |
|              |
|              |
|              |
 --------------

To make sure you understand: I am not talking about displaying two instances of video in different views/layers on top of one another, I am talking about creating a new movie file, using one as base (v1) and just applying a small version of another (v2) in a certain origin and scale and position (frame). The end result would be a single file showing two clips.

Does anyone know if this is at all possible?

EDIT: I'm guessing this is essentially the same kind of question like how to add a watermark to a video. I'll start looking there..

Upvotes: 1

Views: 377

Answers (1)

Laz
Laz

Reputation: 538

You should read about AVMutableComposition. You can make two tracks from your assets, add transform instructions with AVMutableVideoCompositionInstruction and export using AVAssetExportSession.

Upvotes: 1

Related Questions