SHARE
TWEET

Untitled

a guest Jul 19th, 2019 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. this._captureSession = AVCaptureSession.new();
  2.         //Get the camera
  3.  
  4.         this._captureSession.sessionPreset = AVCaptureSessionPreset640x480;
  5.  
  6.         let inputDevice = null;
  7.         this._cameraDevice = AVCaptureDevice.defaultDeviceWithMediaType(AVMediaTypeVideo);
  8.  
  9.  
  10.         //Get the camera input
  11.         let error: NSError = null;
  12.         this._captureInput = AVCaptureDeviceInput.deviceInputWithDeviceError(this._cameraDevice);
  13.  
  14.         if(this._captureSession.canAddInput(this._captureInput)){
  15.             this._captureSession.addInput(this._captureInput);
  16.         }
  17.         else{
  18.             console.log("couldn't add input");
  19.         }
  20.         let self = this;
  21.         const VideoDelegate = (NSObject as any).extend({
  22.             captureOutputDidOutputSampleBufferFromConnection(captureOutput: any,sampleBuffer: any, connection:any): void {
  23.                console.log("Captureing Frames");
  24.               if(self.startRecording){
  25.                 self._mp4Writer.appendVideoSample(sampleBuffer);
  26.                 console.log("Appending Video Samples");
  27.               }
  28.             },
  29.             captureOutputDidDropSampleBufferFromConnection(captureOutput: any,sampleBuffer: any, connection:any): void {
  30.               console.log("Dropping Frames");
  31.  
  32.             },
  33.             videoCameraStarted(date){
  34.                // console.log("CAMERA STARTED");
  35.             }
  36.         }, {
  37.             protocols: [AVCaptureVideoDataOutputSampleBufferDelegate]
  38.         });
  39.  
  40.         this._videoDelegate = VideoDelegate.new();
  41.  
  42.         //setting up camera output for frames
  43.         this._captureOutput = AVCaptureVideoDataOutput.new();
  44.         this._captureQueue = dispatch_queue_create("capture Queue", null);
  45.         this._captureOutput.setSampleBufferDelegateQueue(this._videoDelegate,this._captureQueue);
  46.  
  47.  
  48.         this._captureOutput.alwaysDiscardsLateVideoFrames = false;
  49.  
  50.  
  51.     this._framePixelFormat = NSNumber.numberWithInt(kCVPixelFormatType_32BGRA);
  52.     this._captureOutput.videoSettings = NSDictionary.dictionaryWithObjectForKey(this._framePixelFormat,kCVPixelBufferPixelFormatTypeKey);
  53.  
  54.  
  55.  
  56.         this._captureSession.addOutput(this._captureOutput);
  57.  
  58.  
  59.         this._captureSession.startRunning();
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top