创build一个应用程序,从iPhone屏幕创build一个video,并添加来自耳机/audioinput的audio
我试图从这个应用程序(ShowME)完成从iPad屏幕创build教程video使用AVAssetWriter我能够捕捉屏幕的video。
我尝试使用AVCaptureDevice,但它不工作。 我不知道什么是错的。 我从这个链接学习了从iPhone屏幕捕捉video- 一个非常好的turorial。 但它不会捕获任何audio以及屏幕video。 所以我给了这样一个尝试:
-(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的video和audio的目的,所以可能是一个新手问题。 我读其他职位有关这一点,发现正在合并audio与video。 我想我们可以通过这种方式。 请告诉我,如果这是不可能的。
提前致谢 :)
我最终将audio录制为不同的文件,然后合并它们以创build具有audio和video的video。 我用AVMutableComposition来创build最终的video。 如果有人知道如何使用AVAssetWriter创buildvideo时使用资产进行录制,请帮助我。 我可能会改变我的代码:)
- UIImagePickerController:从video获取图像
- AVPlayer失败,AVPlayerItemStatusFailed(OSStatus错误-12983)
- 如何使用AVURLAssetstream式传输video并将caching的数据保存到磁盘
- 使用MPMovieController或AVFoundation可以使用NSURLProtocol的子类播放video?
- 无法使用AVAssetExportSession修剪video
- AVFoundation覆盖另一个video上的alpha通道video?
- 是否有可能在捕获的图像中添加自己的元数据在Swift中
- iOS AVFoundation:如何从mp3文件中获取作品?
- iPhone可以一次快速拍摄2张照片多快?