创建一个从 iphone 屏幕创建视频并从耳机/音频输入添加音频的应用程序 [英] Create an application that creates a video from iphone screen and add audio from headphones / audio input

查看:22
本文介绍了创建一个从 iphone 屏幕创建视频并从耳机/音频输入添加音频的应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆