我正在尝试使用此问题中的方法捕获音频; 使用AVCaptureSession和AVCaptureAudioDataOutput.这似乎工作得很好1带来的不便:它在模拟器中不起作用.AVAudioRecorder和古老的SpeakHere演示应用程序在我的MacBook Pro上使用内置麦克风在模拟器中运行良好.
问题是在模拟器中[AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeAudio]给出null,因此后续代码失败并显示消息(当它尝试添加null为AVCaptureSession的输入时):
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** Can't add <AVCaptureDeviceInput: 0x9138b40 [(null)]> because the device does not support AVCaptureSessionPresetHigh. Use -[AVCaptureDevice supportsAVCaptureSessionPreset:].'
Run Code Online (Sandbox Code Playgroud)
有没有一种简单的方法可以让它在模拟器中工作?
我正在使用AVCaptureSession会话预设录制视频AVCaptureSessionPreset640x480.我正在使用AVCaptureVideoPreviewLayer非标准尺寸(300 x 300),在录制时将重力设置为纵横填充.它的设置如下:
self.previewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:_captureSession];
_previewLayer.videoGravity = AVLayerVideoGravityResizeAspectFill;
_previewLayer.frame = _previewView.bounds; // 300 x 300
[_previewView.layer addSublayer:_previewLayer];
Run Code Online (Sandbox Code Playgroud)
录制视频后,我想以快速格式将其写入文件.在播放过程中,我再次以300 x 300非标准尺寸的图层播放视频.由于这些视频最终将通过网络连接传输,因此保留完整的640x480视频似乎很浪费.
导出视频以匹配300 x 300预览图层的最佳方法是什么?我是一个AVFoundation菜鸟,所以如果我以错误的方式解决这个问题,请告诉我.我只是希望录制期间在预览图层中显示的录制视频与磁盘上导出的视频相匹配.
avfoundation ios avcapture avcapturesession avvideocomposition
有没有方便的方法在iOS 6或iOS 7中使用HDR照片捕捉时使用AVCaptureSession?我搜索了StackOverflow并找不到任何东西.
NSInvalidArgumentException当我开始在一个视频viewController控制器中拍摄照片时开始录制视频时,我偶尔会遇到异常.我已经尝试了Google和So的一些建议,但仍然在startRecordingToOutputFileURL:fileURL通话时收到此错误.
如果我没有访问另一个拍摄照片的视图控制器,我就不会收到错误 - 只有当我拍照时才会出现错误,然后切换到进行视频录制的新视图控制器.
我认为拍照留下了一些遗留问题,但是当我初始化我的录像机视图控制器时,我没有错误设置会话和诸如此类的东西.有什么想法或如何从中恢复?为什么这是一个NSInvalidArgumentException例外?谢谢!
这是我的代码:
dispatch_async(dispatch_get_main_queue(), ^{
// Try to Fix bug:
// http://stackoverflow.com/questions/5979962/error-while-recording-video-on-iphone-using-avfoundation
[self.captureSession beginConfiguration];
// Ensure session is running
if ( [self.captureSession isRunning] == NO ) {
NSLog(@"Capture session is NOT running... Starting it now!");
[self.captureSession startRunning];
}
else {
NSLog(@"Capture session is ALREADY running...");
}
NSLog(@"File URL is: %@",fileURL);
NSLog(@"FileOutput is: %@",self.fileOutput);
[self.fileOutput startRecordingToOutputFileURL:fileURL recordingDelegate:self];
// Try to Fix bug:
// http://stackoverflow.com/questions/5979962/error-while-recording-video-on-iphone-using-avfoundation
[self.captureSession commitConfiguration];
});
Run Code Online (Sandbox Code Playgroud)
这是错误回溯:
2014-05-18 16:01:38.818 app[1699:60b] …Run Code Online (Sandbox Code Playgroud) 在我正在开发的应用程序中,我想让用户选择视频录制的分辨率.由于规范,我不能使用AVCaptureSessionPreset常量.
获取格式列表的分辨率高于3000px,当然不能用于视频抓取,但仅适用于照片拍摄.
AVCaptureDeviceFormat:0x17020c830'vide'/'420f'3264x2448,{2- 30 fps},HRSI:3264x2448,fov:58.040,max zoom:153.00(upscales @ 1.00),AF系统:2,ISO:29.0-1856.0,SS: 0.000013-0.500000
我找不到一种方法来查看特定格式是否适合视频录制.
问题是,如果我尝试抓取视频,使用这种解决方案应用程序会生成一个异常,表示没有活动或启用的连接.
- [AVCaptureMovieFileOutput startRecordingToOutputFileURL:recordingDelegate:] - 没有活动/启用的连接.
我也不想对每种设备进行硬编码限制.
我也不能试图限制上限,AVCaptureSessionPresetHigh因为Apple注释中所述的不是实际的最大格式.
有没有办法了解AVCaptureDeviceFormat是否适合抓取视频?
我创建了一个AVCaptureSession来捕获视频输出并通过UIView将其显示给用户.现在我希望能够单击按钮(takePhoto方法)并在UIImageView中显示会话中的图像.我试图迭代每个设备连接并尝试保存输出但是没有用.我的代码如下
let captureSession = AVCaptureSession()
var stillImageOutput: AVCaptureStillImageOutput!
@IBOutlet var imageView: UIImageView!
@IBOutlet var cameraView: UIView!
// If we find a device we'll store it here for later use
var captureDevice : AVCaptureDevice?
override func viewDidLoad() {
// Do any additional setup after loading the view, typically from a nib.
super.viewDidLoad()
println("I AM AT THE CAMERA")
captureSession.sessionPreset = AVCaptureSessionPresetLow
self.captureDevice = AVCaptureDevice.defaultDeviceWithMediaType(AVMediaTypeVideo)
if(captureDevice != nil){
beginSession()
}
}
func beginSession() {
self.stillImageOutput = AVCaptureStillImageOutput()
self.captureSession.addOutput(self.stillImageOutput)
var err : NSError? = …Run Code Online (Sandbox Code Playgroud) 这是Swift 2.我似乎无法找到任何相关内容.我收到了错误
Cannot invoke 'lockForConfiguration' with an argument list of type '(() -> ())'
Run Code Online (Sandbox Code Playgroud)
在这里的第二行.
if let device = captureDevice {
device.lockForConfiguration() {
device.videoZoomFactor = 1.0 + CGFloat(ratioValue)
device.unlockForConfiguration()
}
print(ratioValue)
}
Run Code Online (Sandbox Code Playgroud) 我有一个应用程序直接打开基于此WWDC示例的相机:https://developer.apple.com/library/ios/samplecode/AVCam/Introduction/Intro.html
一些用户遇到了相机无法开启但不允许他们捕捉内容的错误.
我昨晚刚遇到同样的问题,这就是我观察到的:
我正在调试一个单独的问题,相机工作100%正常,然后突然,它停止工作.
每当我打开应用程序或导航回相机时,它都会显示当前指向的任何黑暗视图,但图像被冻结.它就像它工作了1秒钟,然后捕获预览会冻结.
我试着强行关闭并重新打开,同样的问题.
我尝试卸载并重新安装,同样的问题.
然后我重新启动手机,问题就解决了.
如何在单独的安装之间存在此错误?
有谁知道可能导致相机失败的原因?
如果只是在使用它几个月后发生一次,我该如何进行调试呢?我不知道触发它的原因是什么?
用物镜C编写的iOS相机应用程序在从锁定屏幕返回/解锁手机时冻结其预览图层.
正在调用所有摄像机配置设置viewWillAppear.到目前为止,我已经成功了,除了唯一的问题,即从锁定屏幕返回时相机预览图层冻结或卡住.我的代码的相机部分如下所示.
任何帮助深表感谢.谢谢.ps:请随意指出我的代码中的任何错误,因为我只是一个新手.
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
dispatch_async(dispatch_get_main_queue(), ^{
[self setGUIBasedOnMode];
});
}
-(void) setGUIBasedOnMode
{
if (![self isStreamStarted]) {
if (shutterActionMode == SnapCamSelectionModeLiveStream)
{
_flashButton.hidden = true;
_cameraButton.hidden = true;
_liveSteamSession = [[VCSimpleSession alloc] initWithVideoSize:[[UIScreen mainScreen]bounds].size frameRate:30 bitrate:1000000 useInterfaceOrientation:YES];
[_liveSteamSession.previewView removeFromSuperview];
AVCaptureVideoPreviewLayer *ptr;
[_liveSteamSession getCameraPreviewLayer:(&ptr)];
_liveSteamSession.previewView.frame = self.view.bounds;
_liveSteamSession.delegate = self;
}
else{
[_liveSteamSession.previewView removeFromSuperview];
_liveSteamSession.delegate = nil;
_cameraButton.hidden = false;
if(flashFlag == 0){
_flashButton.hidden = false;
}
else if(flashFlag == 1){
_flashButton.hidden = true;
} …Run Code Online (Sandbox Code Playgroud) 我正在使用WebRTC及其使用AVCaptureSession。它可以正常工作几次,但有时会因此异常而崩溃。
断言失败:(_ internal-> figCaptureSession == NULL),功能-[AVCaptureVideoPreviewLayer attachToFigCaptureSession:],文件/BuildRoot/Library/Caches/com.apple.xbs/Sources/EmbeddedAVAVation/EmbeddedAVFoundation-1187.37.2.1/Aspen/AVCaptureVideoPreviewLayer
avcapturesession ×10
ios ×8
avfoundation ×6
avcapture ×2
objective-c ×2
swift ×2
camera ×1
cocoa ×1
cocoa-touch ×1
ios6 ×1
ios7 ×1
uikit ×1
webrtc ×1