【发布时间】:2012-01-12 03:42:45
【问题描述】:
我正在尝试从 ipad 屏幕as done in this application (ShowME) 创建一个教程视频,使用 AVAssetWriter 我能够捕获屏幕的视频。
我尝试使用 AVCaptureDevice,但它不起作用。我不知道出了什么问题。 我从这个link - A very nice turorial. 学会了从 iPhone 屏幕捕捉视频 但它不会捕获任何音频以及屏幕视频。所以我试了一下:
-(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);
}
我添加了委托方法
- (void)captureOutput:(AVCaptureOutput *)captureOutput
didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
fromConnection:(AVCaptureConnection *)connection
这永远不会被调用。希望任何人都可以帮助我解决这个问题。 我从未将 AVFoundation 用于视频和音频目的,所以可能是一个新手问题。 我阅读了与此相关的其他帖子,发现它们正在将音频与视频合并。我认为我们可以通过这种方式。如果这是不可能的,请通知我。
提前致谢:)
【问题讨论】:
标签: iphone ios ios4 avfoundation