I am trying to create a training video from the ipad screen as it is done in this application (ShowME) Using AVAssetWriter I can capture the screen video.
I tried to use AVCaptureDevice but did not work. I do not know what is going wrong. I learned how to capture iphone screen video from this link - A very beautiful tour. But it does not capture the sound with the video image. So I tried like this:
-(void)setUpMike{ NSError* error = nil; // Setup the audio input AVCaptureDevice *audioDevice = [AVCaptureDevice defaultDeviceWithMediaType: AVMediaTypeAudio]; AVCaptureDeviceInput *audioInput = [AVCaptureDeviceInput deviceInputWithDevice:audioDevice error:&error ]; // Setup the audio output _audioOutput = [[AVCaptureAudioDataOutput alloc] init]; // Create the session _capSession = [[AVCaptureSession alloc] init]; [_capSession addInput:audioInput]; [_capSession addOutput:_audioOutput]; _capSession.sessionPreset = AVCaptureSessionPresetLow; // Setup the queue dispatch_queue_t queue = dispatch_queue_create("MyQueue", NULL); // [_videoOutput setSampleBufferDelegate:self queue:queue]; [_audioOutput setSampleBufferDelegate:self queue:queue]; dispatch_release(queue); }
I added a delegate method
- (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection
It is never called. Hope someone can help me with this. I have never used AVFoundation for video and audio purposes, so this may be a beginner's question. I read other posts regarding this, and found that merging audio with video. I think we can go this way. Please tell me if this is not possible.
Thank you in advance:)
source share