Reputation: 6954
I m trying to create a tutorial video from ipad screen as done in this application (ShowME) Using AVAssetWriter I am able to capture a video of the screen.
I tried using AVCaptureDevice, but Its not working. I dont know what is going wrong. I learned capturing video from iphone screen from this link - A very nice turorial. But it does not captures any audio along with screen video. So I gave a try 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 the delegate method
- (void)captureOutput:(AVCaptureOutput *)captureOutput
didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
fromConnection:(AVCaptureConnection *)connection
This is never called. Hope any one can help me around for this. I have never used AVFoundation for video and audio purpose, So may be a newbie Question. I read other posts relating this and found that the are merging audio with video. I think we can go through this way. Please inform me if this is not possible.
Thanks in advance :)
Upvotes: 4
Views: 2160
Reputation: 6954
I finally recorder audio as different file and then merged them to create a video with audio and video. I used AVMutableComposition to create a final video. If any one know how to record it with assets as you are creating video with AVAssetWriter, then please help me out. I might change my code :)
Upvotes: 2