Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to get new video frames #3

Open
jessie-young opened this issue Jun 28, 2021 · 1 comment
Open

Unable to get new video frames #3

jessie-young opened this issue Jun 28, 2021 · 1 comment

Comments

@jessie-young
Copy link

I pulled the RxAVFoundation dependency into my Swift project and attempted to use the videoCaptureOutput method to print a new log statement whenever we get a new captureOutput. However, it seems like we never get any .next events. Here's my ViewController.swift

//
//  ViewController.swift
//  RxTest
//
//  Created by Jessie Young on 6/28/21.
//

import UIKit
import AVFoundation
import RxSwift

class ViewController: UIViewController {

    // capture session
    private let session = AVCaptureSession()
    private var videoDevice: AVCaptureDevice!
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        self.videoDevice = AVCaptureDevice.default(.builtInWideAngleCamera, for: .video, position: .back)
    
        session
            .rx
            .configure(captureDevice: videoDevice)
    
        let disposeBag = DisposeBag()
        
        let videoSettings = [(kCVPixelBufferPixelFormatTypeKey as NSString) : NSNumber(value: kCVPixelFormatType_32BGRA)] as [String : Any]
        
        session
            .rx
            .videoCaptureOutput(settings: videoSettings)
            .observeOn(MainScheduler.instance)
            .subscribe { [unowned self] (event) in
                switch event {
                    case .next(let captureOutput):
                        print("got a frame")
                    case .error(let error):
                        print("error: %@", "\(error)")
                    case .completed:
                        break // never happens
                }
            }
            .disposed(by: disposeBag)

        
        session
            .rx
            .startRunning()

        
        // Do any additional setup after loading the view.
    }
}



@jessie-young
Copy link
Author

@maxvol any ideas as to why this sample code is not working?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant