iosaudiovideoavassetwriteravassetreader

iOS Capture Video from Camera and Mixing with audio file in real time


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.


Solution

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