I am using UIImagePickerController
to record a video. and am using AVPlayer
to play a video. and adding AVPlayerLayer
to UIImagePickerController's
cameraOverlayView
so that i can see video while recording.
My requirement is
- I need to watch video while recording video using
UIImagePickerController
- using headset i need to listen audio from playing video
- need to record my voice to recording video
- only my voice should be recorded but not playing video's audio.
every thing working but 4. audio from playing video also mix with my voice. how to handle this case? My final goal is
- Out put for the playing video is headset
- Input for the recording is headset's mic
Please help me to get this done.
Your requirement is interesting. So you need to play and record at the same time, right? So that, you will need to initialize audio session with the category
AVAudioSessionCategoryPlayAndRecord
.Because you are using
UIImagePickerController
to record so you don't have much control to your speaker and your mic. So test and see if it works.In case you still have problem, I suggest you to use
AVCaptureSession
to record video without audio. Look at this example how to use it record-video-with-avcapturesession-2.UPDATE: In my VOIP application, I use
AVAudioUnit
to record while playing back. So I think the only way is record video and audio separately and then useAVComposition
to compose its to a single movie. UsingAVCaptureSession
to record video only and use EZAudio to record audio. TheEZAudio
useAVAudioUnit
to record so that it should work. You can test it by record audio while playing a movie and see if it works. I hope it will helpUPDATE: I tested and it only work if you use headphone or select microphone back. Here is the tested code:
Take a look at PBJVision library. It allows you to record video while you are watching the preview, and at the end, you can do whatever you want with audio and video footage.