大佬教程收集整理的这篇文章主要介绍了ios – 在播放其他视频时录制视频,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
>我需要在使用UIImagePickerController录制视频时观看视频
>使用耳机我需要通过播放视频来收听音频
>需要将我的声音录制到录制视频
>只录制我的声音但不播放视频的音频.
每一件事都在工作,但4.播放视频的音频也与我的声音混合在一起.如何处理这种情况?我的最终目标是
>播放视频的输出是耳机
>录音输入是耳机麦克风
请帮我完成这件事.
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord error:&error];
因为您正在使用UIImagePickerController进行录制,所以您无法控制扬声器和麦克风.所以测试看它是否有效.
如果您仍有问题,我建议您使用AVCaptureSession录制没有音频的视频.看看这个例子如何使用它record-video-with-avcapturesession-2.
更新:在我的VOIP应用程序中,我在播放时使用AVAudioUnit进行录制.所以我认为唯一的方法是分别录制视频和音频,然后使用AVComposition将其组合成一部电影.使用AVCaptureSession仅录制视频并使用EZAudio录制音频. EZAudio使用AVAudioUnit进行记录,以便它可以正常工作.您可以在播放电影时通过录制音频对其进行测试,看看它是否有效.我希望它会有所帮助
更新:我测试过,只有你使用耳机或选择麦克风后它才有效.
这是经过测试的代码:
NSString *moviePath = [[NSBundle mainBundle] pathForresource:@"videoviewdemo" ofType:@"mp4"]; NSURL *url = [NSURL fileURLWithPath:moviePath]; // You may find a test stream at <http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8>. AVPlayerItem *playerItem = [AVPlayerItem playerItemWithURL:url]; AVPlayer *player = [AVPlayer playerWithPlayerItem:playerItem]; AVPlayerLayer *layer = [[AVPlayerLayer alloc] init]; [layer setPlayer:player]; [layer setFrame:CGRectMake(0,100,100)]; [self.view.layer addSublayer:layer]; [player play]; dispatch_after(dispatch_time(DISPATCH_TIME_Now,(int64_t)(1 * NSEC_PER_SEC)),dispatch_get_main_queue(),^{ // // Setup the AVAudioSession. EZMicrophone will not work properly on iOS // if you don't do this! // AVAudioSession *session = [AVAudioSession sharedInstance]; NSError *error; [session setCategory:AVAudioSessionCategoryPlayAndRecord error:&error]; if (error) { NSLog(@"Error setTing up audio session category: %@",error.localizedDescription); } [session setActive:YES error:&error]; if (error) { NSLog(@"Error setTing up audio session active: %@",error.localizedDescription); } // // Customizing the audio plot's look // // BACkground color self.audioPlot.BACkgroundColor = [UIColor colorWithRed:0.984 green:0.471 blue:0.525 alpha:1.0]; // Waveform color self.audioPlot.color = [UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1.0]; // Plot type self.audioPlot.plotType = EZPlotTypeBuffer; // // Create the microphone // self.microphone = [EZMicrophone microphoneWithDelegate:self]; // // Set up the microphone input UIPickerView items to SELEct // between different microphone inputs. Here what we're doing behind the hood // is enumerating the available inputs provided by the AVAudioSession. // self.inputs = [EZAudioDevice inputDevices]; self.microphoneInputPickerView.datasource = self; self.microphoneInputPickerView.delegate = self; // // Start the microphone // [self.microphone startFetchingAudio]; self.microphoneTextLabel.text = @"Microphone On"; [[AVAudioSession sharedInstance] overrideOutputAudioPort:AVAudioSessionPortOverrideSpeaker error:nil]; });
以上是大佬教程为你收集整理的ios – 在播放其他视频时录制视频全部内容,希望文章能够帮你解决ios – 在播放其他视频时录制视频所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。