0

What I need is to merge two movie files. What I need is to read from the files and write the sample to a different file. How can I read form one file and after its over continue reading the 2nd file. So that I continuously receive sample buffers which can be appended to the AVAssetwritter.

borncrazy
  • 1,589
  • 1
  • 12
  • 9

1 Answers1

0

You need to create an AVMutableComposition, add an AVMutableCompositionTrack to that and then add each asset to the AVMutableCompositionTrack.

Here is another question which adequately demonstrates that process. Stitching two videos

Once you have the AVMutableComposition, then you need to associate it with your AVAssetReader. After that, you have what you're looking for.

However, if you just want a basic stitch (plus audio) then look at using AVAssetExport which avoids needing to bother with the AssetReader and AssetWriter and will export the AVMutableComposition in one go.

Note that if you want audio as well, that's another track on your AVMutableComposition.

Community
  • 1
  • 1
Tim Bull
  • 2,375
  • 21
  • 25