0

I am using Red5 iOS code and their CustomVideoSource class. Successfully publish the stream over server but it's shows as Black & White. Not the actual coloured stream. If any one had faced this issue , please help me to find solution for it. Please find the code sample

  let contextImage = McamImage.shared.image
        let image: CGImage? = contextImage.cgImage
        let dataProvider: CGDataProvider? = image?.dataProvider
        let data: CFData? = dataProvider?.data


        if (data != nil) {

        let baseAddress = CFDataGetBytePtr(data!)
        //contextImage = nil

        /*
         * We own the copied CFData which will back the CVPixelBuffer, thus the data's lifetime is bound to the buffer.
         * We will use a CVPixelBufferReleaseBytesCallback callback in order to release the CFData when the buffer dies.
         */
        let unmanagedData = Unmanaged<CFData>.passRetained(data!)
        var pixelBuffer: CVPixelBuffer?
        var result = CVPixelBufferCreateWithBytes(nil,
                                                  (image?.width)!,
                                                  (image?.height)!,
                                                  kCVPixelFormatType_24RGB,
                                                  UnsafeMutableRawPointer( mutating: baseAddress!),
                                                  (image?.bytesPerRow)!,
                                                  { releaseContext, baseAddress in
                                                    let contextData = Unmanaged<CFData>.fromOpaque(releaseContext!)
                                                    contextData.release()
        },
                                                  unmanagedData.toOpaque(),
                                                  nil,
                                                  &pixelBuffer)

Thanks!

Karamjeet Singh
  • 460
  • 1
  • 5
  • 16
  • After changing the kCVPixelFormatType able to get some result but not the actual colour. Can any one let me know what else can be done to read pixel buffer or any other way to read data and send to Red5 for custom video – Karamjeet Singh Oct 05 '17 at 11:08
  • After scaling the image and using kCVPixelFormatType_32BGRA able to send the coloured image on Red5 server. – Karamjeet Singh Oct 06 '17 at 12:02

0 Answers0