草庐IT

CaptureSession

全部标签

ios - (Swift) 将视频输出保存到文件

我在一个ViewController中捕获视频、音频和照片,理想情况下是一个捕获session。我目前遇到的问题是录制视频。它可以很好地显示我的预览输出。我启用了AVCaptureFileOutputRecordingDelegate并实现了以下方法。funccaptureOutput(captureOutput:AVCaptureFileOutput!,didFinishRecordingToOutputFileAtURLoutputFileURL:NSURL!,fromConnectionsconnections:[AnyObject]!,error:NSError!)varout

swift - AVFoundation:开始记录由于 "No active/enabled connection"而崩溃

我正在尝试在Swift中创建自定义相机。我发现了很多关于这个的帖子,并设法打开了相机,有一个“开始录制”按钮。但是,当单击“开始录制”按钮时,出现此错误:Terminatingappduetouncaughtexception'NSInvalidArgumentException',reason:'***-[AVCaptureMovieFileOutputstartRecordingToOutputFileURL:recordingDelegate:]Noactive/enabledconnections'查到这个错误,应该是我在beginSession函数中没有设置相机画质导致的:f

iOS 扫描二维码成功后如何关闭相机 Swift 4

扫描二维码成功后如何关闭相机?我的问题是当我从二维码扫描代码时,扫描后相机没有关闭。我怎样才能关闭相机?我的代码:varcaptureSession:AVCaptureSession!varpreviewLayer:AVCaptureVideoPreviewLayer!varqrCode=String()funcfailed(){letac=UIAlertController(title:"Scanningnotsupported",message:"Yourdevicedoesnotsupportscanningacodefromanitem.Pleaseuseadevicewith

ios - CMSampleBufferGetImageBuffer(sampleBuffer) 返回 nil

我使用此代码从相机捕获视频,但CMSampleBufferGetImageBuffer(sampleBuffer)始终返回nil。问题是什么?。这是代码,我修改了此源代码以适应Swift4https://github.com/FlexMonkey/CoreImageHelpers/blob/master/CoreImageHelpers/coreImageHelpers/CameraCaptureHelper.swiftimportAVFoundationimportCoreMediaimportCoreImageimportUIKitclassCameraCaptureHelper:

swift - 禁用相机 View 增长动画

目前,我有一个vieController,它以模态方式呈现一个包含相机的ViewController。但是,每当我转换时,预览层都有一个动画,因此它从左上角循环增长以填充屏幕的其余部分。我试过禁用CALayer隐式动画但没有成功。这是View出现时的代码。overridefuncviewDidAppear(_animated:Bool){super.viewDidAppear(animated)previewLayer?.frame=self.view.frame}overridefuncviewWillAppear(_animated:Bool){super.viewWillAppe

ios - QRCode 扫描仪在 iOS 11 中不起作用,仅显示相机预览

这个问题在这里已经有了答案:Barcodeonswift4(4个答案)关闭5年前。它只显示相机的输出,但没有任何反应。我不知道有什么问题。我的代码是:classQRScannerController:UIViewController,AVCaptureMetadataOutputObjectsDelegate{varcaptureSession:AVCaptureSession?varvideoPreviewLayer:AVCaptureVideoPreviewLayer?varqrCodeFrameView:UIView?letsupportedCodeTypes=[AVMetada

ios - didFinishProcessingPhotoSampleBuffer 未调用

我正在尝试学习如何使用AVFoundation拍摄和保存照片。我目前已经能够使用链接到拍照操作的按钮制作自定义相机View。当我单击按钮时,未调用委托(delegate)方法。这是我的ViewController.swift:classViewController:UIViewController,AVCapturePhotoCaptureDelegate{@IBOutletweakvarcamerView:UIView!@IBOutletweakvarphotoButton:UIButton!varcaptureSession:AVCaptureSession?varsessionO

swift - 在 Swift 中使用按钮切换相机

这似乎可以将相机从背面切换到正面,但我正在尝试提出一个“if”语句,以便我也可以将其切换回来。有什么想法或建议吗?@IBActionfuncdidTouchSwitchButton(sender:UIButton){letcamera=getDevice(.Front)letcameraBack=getDevice(.Back)do{input=tryAVCaptureDeviceInput(device:camera)}catchleterrorasNSError{print(error)input=nil}if(captureSession?.canAddInput(input)=

iOS Swift 2 录制视频 AVCaptureSession

我创建了一个AVCaptureSession并将前置摄像头附加到它do{trycaptureSession.addInput(AVCaptureDeviceInput(device:captureDevice))}catch{print("err")}现在我想开始和停止记录touche事件。我该怎么做?overridefunctouchesBegan(touches:Set,withEventevent:UIEvent?){print("touch")//StartRecording}overridefunctouchesEnded(touches:Set,withEventevent

ios - 如何同时录制视频和播放音频(swift教程)

所以您想录制视频并播放用户音乐库中的音乐同时?别再看了。以下是答案。 最佳答案 对于音频播放,您将使用AVAudioPlayer。您所要做的就是将AVAudioPlayer声明为全局变量(我将其命名为audioPlayer)并实现下面的代码。在用户选择他/她想要播放的歌曲后使用:funcmediaPicker(mediaPicker:MPMediaPickerController,didPickMediaItemsmediaItemCollection:MPMediaItemCollection){letpickerItem:MPM