创建一个从 iphone 屏幕创建视频并从耳机/音频输入添加音频的应用程序

2023-10-23移动开发问题
3

本文介绍了创建一个从 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 屏幕创建视频并从耳机/音频输入添加音频的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

硬件音量按钮更改应用程序音量
Hardware Volume buttons change in app volume(硬件音量按钮更改应用程序音量)...
2024-08-12 移动开发问题
10

Cocos2d - 如何检查不同层中对象之间的交集
Cocos2d - How to check for Intersection between objects in different layers(Cocos2d - 如何检查不同层中对象之间的交集)...
2024-08-12 移动开发问题
8

恢复游戏 cocos2d
Resume game cocos2d(恢复游戏 cocos2d)...
2024-08-12 移动开发问题
6

突出显示朗读文本(在 iPhone 的故事书类型应用程序中)
Highlight Read-Along Text (in a storybook type app for iPhone)(突出显示朗读文本(在 iPhone 的故事书类型应用程序中))...
2024-08-12 移动开发问题
9

Cocos2D + 仅禁用 Retina iPad 图形
Cocos2D + Disabling only Retina iPad Graphics(Cocos2D + 仅禁用 Retina iPad 图形)...
2024-08-12 移动开发问题
10

正确的 cocos2d 场景重启?
Proper cocos2d scene restart?(正确的 cocos2d 场景重启?)...
2024-08-12 移动开发问题
7