1

I am trying to capture video from iPhone camera and save the movie mixed with an audio file. I can capture the video with the audio (from mic) with no problems. What I want to do is capture the video but instead of mic audio, use a music track (a .caf file). I am capturing the video with AVAssetWriter. I've tried to set up an AVAssetReader to read the audio file, but I couldn't make it work with the AVAssetWriter (maybe because the decoding of audio happens real fast). Also, I don't want to save the movie without audio and mix it afterwards with an AVAssetExportSession. It would be to slow for my purpose. Any Ideas ? Thanks in advance.

2 Answers2

0

Capture the video using AVAssetWriter, Capture audio lets say with AvAudioRecorder , then mix audio and video using AVExportSession , lots of posts on this topic.

Jad
  • 188
  • 2
  • 12
  • That will not help. I don't want to use AVExportSession. It should be done on the fly, when the user finishes the capture it is already with the mixed audio. – Clóvis Marsupial Aug 04 '12 at 06:58
  • Well mine works pretty good , the only problem is that users have to wait a bit till the video is extracted.I don't think you can do it on the fly, and if there's one surely it's really really difficult. And for the sync problem you have to use something like that : [compositionVideoTrack scaleTimeRange:CMTimeRangeMake(kCMTimeZero,videoAsset.duration) toDuration:audioAsset.duration]; – Jad Aug 07 '12 at 12:30
0

If you do it after (with AVAssetExportSession) , you will problem with the sync. and short delay (time...) between the video and the audio...didn't find better solution

Devin Zhao
  • 159
  • 12
Josh
  • 1