相关疑难解决方法(0)

可以同时使用AVCaptureVideoDataOutput和AVCaptureMovieFileOutput吗?

我想用我的代码同时录制视频和抓取帧.

AVCaptureVideoDataOutput用于抓取框架和AVCaptureMovieFileOutput视频录制.但无法工作,并在同时工作但个人工作时得到错误代码-12780.

我搜索了这个问题,但没有得到答案.有没有人有同样的经历或解释?一段时间我真的很烦.

谢谢.

iphone video-capture image-processing avfoundation

32
推荐指数
1
解决办法
2万
查看次数

同时AVCaptureVideoDataOutput和AVCaptureMovieFileOutput

我需要能够同时拥有AVCaptureVideoDataOutputAVCaptureMovieFileOutput工作.以下代码有效,但视频录制没有.在didFinishRecordingToOutputFileAtURL直接后调用委托startRecordingToOutputFileURL被调用.现在,如果我AVCaptureVideoDataOutputAVCaptureSession简单的评论中删除该行:

[captureSession addOutput:captureDataOutput];

视频录制工作,但然后不调用SampleBufferDelegate(我需要).

我怎样才能兼顾AVCaptureVideoDataOutputAVCaptureMovieFileOutput同时工作.

- (void)initCapture {
 AVCaptureDeviceInput *captureInput = [AVCaptureDeviceInput deviceInputWithDevice:[AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo] error:NULL]; 

 captureDataOutput = [[AVCaptureVideoDataOutput alloc] init]; 
 [captureDataOutput setSampleBufferDelegate:self queue:dispatch_get_main_queue()]; 

 m_captureFileOutput = [[AVCaptureMovieFileOutput alloc] init];

 NSString* key = (NSString*)kCVPixelBufferPixelFormatTypeKey; 
 NSNumber* value = [NSNumber numberWithUnsignedInt:kCVPixelFormatType_32BGRA]; 
 NSDictionary* videoSettings = [NSDictionary dictionaryWithObject:value forKey:key]; 

 [captureDataOutput setVideoSettings:videoSettings]; 

 captureSession = [[AVCaptureSession alloc] init]; 

 [captureSession addInput:captureInput];
 [captureSession addOutput:m_captureFileOutput]; 
 [captureSession addOutput:captureDataOutput]; 

 [captureSession beginConfiguration]; 
 [captureSession setSessionPreset:AVCaptureSessionPresetLow]; 
 [captureSession commitConfiguration]; 

 [self performSelector:@selector(startRecording) …
Run Code Online (Sandbox Code Playgroud)

iphone camera record video-capture ios

22
推荐指数
1
解决办法
1万
查看次数

具有多个输出的AVCaptureSession?

我目前正在开发一个iOS应用程序,它将CoreImage应用于相机提要以拍摄照片和视频,而且我遇到了一些障碍.

到目前为止,我一直在使用AVCaptureVideoDataOutput获取样本缓冲区并使用CoreImage对其进行操作,然后显示简单的预览,并使用它来捕获照片并保存它们.

当我尝试实现视频录制时,通过在从AVCaptureVideoDataOutput接收视频时将SampleBuffers写入视频,它的帧速率非常慢(可能是因为正在进行的其他图像相关处理).

所以我想知道,AVCaptureVideoDataOutput和AVCaptureMoveFileOutput可以同时在同一个AVCaptureSession上运行吗?

我快速给了它,发现当我添加额外输出时,我的AVCaptureVideoDataOutput停止接收信息.

如果我能让它工作,我希望这意味着我可以简单地使用第二个输出以高帧率录制视频,并在用户停止录制后对视频进行后期处理.

任何帮助将不胜感激.

avfoundation ios avcapturesession

22
推荐指数
1
解决办法
5134
查看次数

不使用setSampleBufferDelegate调用captureOutput函数

我开始开发iOS应用程序,这是我的第一篇SO帖子.我正在尝试实现一个UI视图,它可以显示后置摄像头的预览视频并处理捕获的帧.我的预览图层效果很好,我可以在UI视图中看到图片显示.但是,永远不会调用captureOutput函数.

我已经在网上搜索了一段时间的silimar问题和解决方案,并试图调整不同的东西,包括输出,连接和调度队列设置,但没有一个工作.任何人都可以帮助我或分享一些见解和方向吗?非常感谢提前!

这里是我的代码,我使用的是Xcode 11 betaiOS 10作为构建目标.

class ThreeDScanningViewController: UIViewController, 
AVCaptureVideoDataOutputSampleBufferDelegate {

    @IBOutlet weak var imageView: UIImageView!

    var session : AVCaptureSession!
    var device : AVCaptureDevice!
    var output : AVCaptureVideoDataOutput!
    var previewLayer : AVCaptureVideoPreviewLayer!

    override func viewDidLoad() {
        super.viewDidLoad()
                //NotificationCenter.default.addObserver(self, selector: #selector(self.startedNotif), name: NSNotification.name.CaptureSessionDidStartRunningNotification, object: nil)

    func initCamera() -> Bool {
        session = AVCaptureSession()
        session.sessionPreset = AVCaptureSession.Preset.medium

        let devices = AVCaptureDevice.devices()

        for d in devices { 
            if ((d as AnyObject).position == AVCaptureDevice.Position.back) {
                device = d as! AVCaptureDevice …
Run Code Online (Sandbox Code Playgroud)

swift

14
推荐指数
3
解决办法
5682
查看次数

AVCaptureSession只为iPhone 3gs获得一帧

我有一段代码,用于设置摄像头的捕获会话以使用OpenCV处理帧,然后使用生成的UIImage从帧中设置UIImageView的image属性.当应用程序启动时,图像视图的图像为零,并且在我按下堆栈上的另一个视图控制器然后将其弹出之前不显示任何帧.然后图像保持不变,直到我再次这样做.NSLog语句显示以大约正确的帧速率调用回调.任何想法为什么它不显示?我将帧速率一直降低到每秒2帧.它的处理速度不够快吗?

这是代码:

- (void)setupCaptureSession {
    NSError *error = nil;

    // Create the session
    AVCaptureSession *session = [[AVCaptureSession alloc] init];

    // Configure the session to produce lower resolution video frames, if your 
    // processing algorithm can cope. We'll specify medium quality for the
    // chosen device.
    session.sessionPreset = AVCaptureSessionPresetLow;

    // Find a suitable AVCaptureDevice
    AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];

    // Create a device input with the device and add it to the session.
    AVCaptureDeviceInput *input = [AVCaptureDeviceInput deviceInputWithDevice:device 
                                                                        error:&error];
    if (!input) …
Run Code Online (Sandbox Code Playgroud)

iphone avcapturesession

6
推荐指数
1
解决办法
4336
查看次数