Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- this._captureSession = AVCaptureSession.new();
- //Get the camera
- this._captureSession.sessionPreset = AVCaptureSessionPreset640x480;
- let inputDevice = null;
- this._cameraDevice = AVCaptureDevice.defaultDeviceWithMediaType(AVMediaTypeVideo);
- //Get the camera input
- let error: NSError = null;
- this._captureInput = AVCaptureDeviceInput.deviceInputWithDeviceError(this._cameraDevice);
- if(this._captureSession.canAddInput(this._captureInput)){
- this._captureSession.addInput(this._captureInput);
- }
- else{
- console.log("couldn't add input");
- }
- let self = this;
- const VideoDelegate = (NSObject as any).extend({
- captureOutputDidOutputSampleBufferFromConnection(captureOutput: any,sampleBuffer: any, connection:any): void {
- console.log("Captureing Frames");
- if(self.startRecording){
- self._mp4Writer.appendVideoSample(sampleBuffer);
- console.log("Appending Video Samples");
- }
- },
- captureOutputDidDropSampleBufferFromConnection(captureOutput: any,sampleBuffer: any, connection:any): void {
- console.log("Dropping Frames");
- },
- videoCameraStarted(date){
- // console.log("CAMERA STARTED");
- }
- }, {
- protocols: [AVCaptureVideoDataOutputSampleBufferDelegate]
- });
- this._videoDelegate = VideoDelegate.new();
- //setting up camera output for frames
- this._captureOutput = AVCaptureVideoDataOutput.new();
- this._captureQueue = dispatch_queue_create("capture Queue", null);
- this._captureOutput.setSampleBufferDelegateQueue(this._videoDelegate,this._captureQueue);
- this._captureOutput.alwaysDiscardsLateVideoFrames = false;
- this._framePixelFormat = NSNumber.numberWithInt(kCVPixelFormatType_32BGRA);
- this._captureOutput.videoSettings = NSDictionary.dictionaryWithObjectForKey(this._framePixelFormat,kCVPixelBufferPixelFormatTypeKey);
- this._captureSession.addOutput(this._captureOutput);
- this._captureSession.startRunning();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement