创建一个从iphone屏幕创建视频并从耳机/音频输入添加音频的应用程序 [英] Create an application that creates a video from iphone screen and add audio from headphones / audio input
问题描述
我正在尝试从ipad屏幕创建教程视频在此应用程序中完成(ShowME)使用AVAssetWriter我能够捕获屏幕的视频。
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.
我尝试过使用AVCaptureDevice,但它没有用。我不知道出了什么问题。
我学习了从这个链接 - 从iphone屏幕捕获视频 - 一个非常好的媒体。
但它不会随屏幕视频一起捕获任何音频。所以我尝试了这样的尝试:
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);
}
我添加了委托方法
- (void)captureOutput:(AVCaptureOutput *)captureOutput
didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
fromConnection:(AVCaptureConnection *)connection
永远不会调用它。希望任何人都能帮助我解决这个问题。
我从来没有将AVFoundation用于视频和音频用途,所以可能是一个新手问题。
我读了与此相关的其他帖子,发现它们正在将音频与视频合并。我想我们可以通过这种方式。如果不可能,请通知我。
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.
提前致谢:)
推荐答案
我终于录制音频为不同的文件然后合并它们以创建带有音频和视频的视频。我使用AVMutableComposition创建了一个最终视频。如果您在使用AVAssetWriter创建视频时知道如何使用资源记录,那么请帮助我。我可能会更改我的代码:)
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 :)
这篇关于创建一个从iphone屏幕创建视频并从耳机/音频输入添加音频的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!