# DeepARDelegate frameAvailable: The sampleBuffer is transparent

**URL:** <https://forum.deepar.ai/t/deepardelegate-frameavailable-the-samplebuffer-is-transparent/201>\
**Category:** Help & Questions\
**Created:** [February 11, 2023, 9:19am UTC](https://forum.deepar.ai/t/deepardelegate-frameavailable-the-samplebuffer-is-transparent/201 "2023-02-11T09:19:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![thanhbpc](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.deepar.ai/thanhbpc/32/300_2.png) [@thanhbpc](https://forum.deepar.ai/u/thanhbpc)\
**Post date:** [February 11, 2023, 9:19am UTC](https://forum.deepar.ai/t/deepardelegate-frameavailable-the-samplebuffer-is-transparent/201/1 "2023-02-11T09:19:13Z")

</div>

I want to use the DeepAR effect with a custom camera. I’m also using an ARView to display the camera on the screen. Everything is working well.  
But when I want to get the sampleBuffer (with effect applied) to publish the stream to RTMP from the DeepARDelegate frameAvailable(\_ sampleBuffer: CMSampleBuffer!). Previously, I called the deepAR.startCapture function.  
When I debugged to check, I found that the sampleBuffer is transparent.

in CustomCameraController:

```auto
func captureOutput(_ captureOutput: AVCaptureOutput, didOutput sampleBuffer: CMSampleBuffer, from connection: AVCaptureConnection) {
        if let deepAR = _deepAR {
            if connection == _videoConnection {
                deepAR.enqueueCameraFrame(sampleBuffer, mirror: _mirrorCamera)
            } else {
                deepAR.enqueueAudioSample(sampleBuffer)
            }
        } else if let arview = _arview {
            if (connection == _videoConnection) {
                arview.enqueueCameraFrame(sampleBuffer, mirror: _mirrorCamera)
            } else {
                arview.enqueueAudioSample(sampleBuffer)
            }
        }
    }

```

In DeepARDelegate:

```auto
func didInitialize() {
        print("\ndidInitialize")
        self.deepar.startCapture(withOutputWidthAndFormat: 640, outputHeight: 480, subframe: CGRect(x: 0,y: 0,width: 640,height: 480), outputImageFormat: OutputFormat(rawValue: kCVPixelFormatType_32BGRA))
        setupStream()
    }

```

```auto
func frameAvailable(_ sampleBuffer: CMSampleBuffer!) {
        if (streaming) {
            if let pixelBuffer: CVPixelBuffer = CMSampleBufferGetImageBuffer(sampleBuffer) {
                let width: Int = CVPixelBufferGetWidth(pixelBuffer)
                let height: Int = CVPixelBufferGetHeight(pixelBuffer)
                print("Width: \(width) pixels, Height: \(height) pixels")
            }
            let imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer)
            let formatDescription = CMSampleBufferGetFormatDescription(sampleBuffer)
            let mediaType = CMFormatDescriptionGetMediaType(formatDescription!)
            
            let format = CVPixelBufferGetPixelFormatType(imageBuffer!)
            
            let transparent = isFullTransparent(sampleBuffer)
            print("Is Fully transparent \(transparent)")
            
            if format == kCVPixelFormatType_32BGRA {
                print("Sample buffer includes an alpha channel")
            } else {
                print("Sample buffer does not include an alpha channel")
            }
            
            rtmpStream.appendSampleBuffer(sampleBuffer, withType: mediaType == kCMMediaType_Video ? .video : .audio)
            DispatchQueue.main.async {
                self.setPreviewImage(sampleBuffer)
            }
        }
    }

```

If I send the sampleBuffer from the captureOutput method in the CustomCameraController, the stream will work. However, when using the frameAvailable(\_ sampleBuffer: CMSampleBuffer!) method, it’s working with transparent frame.

Please help me fix it ☹

---

<div class="post-metadata">

**Author:** ![jelena](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.deepar.ai/jelena/32/14_2.png) [@jelena](https://forum.deepar.ai/u/jelena)\
**Post date:** [February 13, 2023, 12:09pm UTC](https://forum.deepar.ai/t/deepardelegate-frameavailable-the-samplebuffer-is-transparent/201/2 "2023-02-13T12:09:08Z")

</div>

HI, the startCapture subframe uses [0-1] range. Here is a snippet from one of our video call examples

```
    self.deepAr.startCapture(withOutputWidth: 720, outputHeight: 1280, subframe: CGRect(x: 0.0, y: 0.0, width: 1.0, height: 1.0))

```

Hope this helps with your issue.
