Tag: avcapturesession

iPhone按下音量键时如何隐藏音量叠加

我有很多解决它,像添加MPVolumeView,有人说,系统卷HUD将隐藏,如果您添加MPVolumeView的实例在当前,但没有工作 我添加观察者观察音量的变化,并拍照 但现在我失去了如何隐藏卷HUD 我曾尝试添加MPVolumeView实例的解决scheme,但不会工作请给我另一种方式来解决它 任何build议,将不胜感激。

录制video/audio时播放系统声音

当我开始录制video时,我正尝试播放苹果所需的“哔哔”声。 我已经通过SO和其他来源发现,当audioinput没有进行某些configuration时,您将无法播放声音。 这是我的configuration方法的尝试: private void SetupAudio() { beepSound = AssetBank.GetSystemSoundWav("video_record", "video_beep"); AudioSession.Initialize(); AudioSession.Interrupted += delegate { Console.WriteLine("Interrupted handler"); }; AudioSession.Category = AudioSessionCategory.PlayAndRecord; AudioSession.OverrideCategoryMixWithOthers = true; NSError err; AVAudioSession.SharedInstance().SetActive(true, out err); } 这里是我设置logging会话的代码: public void SetupVideoCaptureSession(AVCaptureDevicePosition position) { // Setup devices foreach (var device in AVCaptureDevice.Devices) { if (device.HasMediaType(AVMediaType.Video)) { if (device.Position == AVCaptureDevicePosition.Front) { frontCam […]

以与预览图层相匹配的大小导出AVCaptureSessionvideo

我使用AVCaptureSession录制video,会话预设为AVCaptureSessionPreset640x480 。 我正在使用非标准尺寸(300 x 300)的AVCaptureVideoPreviewLayer ,并在录制时将重力设置为方向填充。 它的设置是这样的: self.previewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:_captureSession]; _previewLayer.videoGravity = AVLayerVideoGravityResizeAspectFill; _previewLayer.frame = _previewView.bounds; // 300 x 300 [_previewView.layer addSublayer:_previewLayer]; 录制video后,我想以快速格式将其写入文件。 在播放过程中,我再次以300 x 300的非标准尺寸图层播放video。 由于这些video最终将通过networking连接进行传输,因此保留完整的640x480video看起来很浪费。 导出video以匹配我的300 x 300预览图层的最佳方式是什么? 我是一个AVFoundation noob,所以如果我正在做这个错误的方式,请让我知道。 我只想在logging期间预览层中显示的录制video与磁盘上导出的video相匹配。

相机冻结时打开的应用程序,而电话正在运行

我用AVCaptureSession创build了一个相机 。 我已经configuration了照片和录像模式 。 相机和应用程序运行良好。 此外,我允许背景音乐播放 (如果用户使用iPhone中的音乐应用程序播放歌曲),而打开相机或录制video。 它也工作正常。 (附图2) 我允许背景音乐播放与此代码的帮助 AVAudioSession *session1 = [AVAudioSession sharedInstance]; [session1 setCategory:AVAudioSessionCategoryPlayAndRecord withOptions:AVAudioSessionCategoryOptionMixWithOthers|AVAudioSessionCategoryOptionDefaultToSpeaker|AVAudioSessionCategoryOptionAllowBluetooth error:nil]; [session1 setActive:YES error:nil]; [[UIApplication sharedApplication] beginReceivingRemoteControlEvents]; 现在,如果我接到电话 ,请点击主页button并打开应用程序,以最小化电话呼叫屏幕,并打开相机屏幕捕捉图像/录制video,打开但冻结图像(附图(1))。 现在我的要求是,我想要通过电话拍摄图像/录制video。 我寻找另一个应用程序,和Snapchat是一样的 ,我可以录制video,而我在电话。 请帮助我,我怎么能做到这一点。

如何loggingvideo并保持音乐在后台播放?

对不起,如果这是重复的,但我找不到类似这样的问题。 我有一个自定义的AVFoundation制作的摄像机/录像机,我想知道如何在录制video的时候保持audio从其他应用程序运行,因为现在它会停止audio(甚至不会暂停),然后录制video 如果我正确思考,可以通过添加类似的东西来解决这个问题: [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryAmbient error:nil];

iOS设备快速旋转180°会导致相机颠倒

我已经实现了下面的代码来改变基于AVCaptureVideoSession的方向: – (AVCaptureVideoOrientation)interfaceOrientationToVideoOrientation:(UIInterfaceOrientation)orientation { switch (orientation) { case UIInterfaceOrientationPortrait: return AVCaptureVideoOrientationPortrait; case UIInterfaceOrientationPortraitUpsideDown: return AVCaptureVideoOrientationPortraitUpsideDown; case UIInterfaceOrientationLandscapeLeft: return AVCaptureVideoOrientationLandscapeLeft; case UIInterfaceOrientationLandscapeRight: return AVCaptureVideoOrientationLandscapeRight; default: break; } NSLog(@"Warning – Didn't recognise interface orientation (%ld)",(long)orientation); return AVCaptureVideoOrientationPortrait; } 这个代码几乎完美的工作。 但是,发生的一个问题是,如果您快速旋转iOS设备180度,相机将显示颠倒。 以下是相机视图在旋转之前的样子: 轮换之后的样子如下所示: 另外,这里是我的viewDidLayoutSubviews实现: – (void)viewDidLayoutSubviews { [super viewDidLayoutSubviews]; previewLayer.frame = self.view.bounds; self.view.translatesAutoresizingMaskIntoConstraints = NO; previewLayer.videoGravity = AVLayerVideoGravityResizeAspectFill; […]

video保存方向错误AVCaptureSession

我试图录制video(不显示相机)并保存。 但是保存的video并没有保存在正确的方向。 我试过迫使UIViewController是一个确定的方向,但是没有帮助。 所有video都以纵向录制。 我的代码如下: session = [[AVCaptureSession alloc] init]; [session beginConfiguration]; session.sessionPreset = AVCaptureSessionPresetHigh; AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo]; for (AVCaptureDevice *cam in [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo]) { if (cam.position == AVCaptureDevicePositionFront) device = cam; } NSError *error = nil; AVCaptureDeviceInput *input = [AVCaptureDeviceInput deviceInputWithDevice:device error:&error]; if (!input) { // Handle the error appropriately. NSLog(@"ERROR: trying […]

防止AVCaptureVideoPreviewLayer旋转,但允许UI层以方向旋转

我有两个视图控制器。 一个是根VC,包含录制button等UI界面。 在这个视图控制器上,我还显示另一个VC在索引0的视图。此视图包含一个AVCaptureVideoPreviewLayer。 我想我的摄像机模仿苹果video摄像头的应用程序,其中界面布局与旋转调整,但video预览层没有。 您可以看到股票video应用程序中的录制计时器(UILabel)如何消失,并根据方向重新显示在顶部。 任何想法如何做到这一点? 我发现一个build议,build议将预览添加到应用程序委托的窗口,因为它不符合导航控制器的旋转,但它不适用于我。 谢谢!

将BGRA转换为ARGB

我正在阅读本教程获取iPhone相机的像素数据。 虽然我没有运行和使用这个代码的问题,我需要把摄像头数据(它来自BGRA)的输出,并将其转换为ARGB,以便我可以使用它与外部库。 我该怎么做呢?

用AVCaptureSession和播放audio同时录制audio/video?

我试图创build一个iOS应用程序,可以录制audio和video,同时向扬声器输出audio。 要进行录制和预览,我使用了AVCaptureSession , AVCaptureConnection分别用于video和audio, AVAssetWriterInput用于video和audio。 我基本上是通过遵循RosyWriter示例代码来实现的。 在以这种方式设置录制之前,我使用AVAudioPlayer播放audio。 现在,如果我正在捕获(甚至不logging,只是捕获预览),并试图使用AVAudioPlayer ,我的AVCaptureAudioDataOutputSampleBufferDelegate类的captureOutputcallback停止调用captureOutput 。 有没有解决方法? 是否有另一个低级的服务,我应该用来播放audio,不会停止我的捕获? MC。