ios – Does anybody have a repair for this error code: “[SceneKit] Error: Couldn’t get pixel buffer (CVPixelBufferRef)”?


I’m at the moment making an attempt to construct an app that may show a 360 video in vr format. The video performs effective when I’ve it saved as a file within the Xcode undertaking. Nonetheless, the error happens when I attempt to play the video from a hyperlink to the file saved in dropbox. I’m having to play it from a hyperlink relatively than a file in-built to the app because the video is 30mins lengthy so takes up numerous storage. When I attempt to play the video I’m met with a white display screen the place the video must be and this error code within the title is repeatedly repeated within the output field. I’ve seen different posts on right here a couple of comparable concern, however none have discovered a solution so far as I can inform, so I assume different individuals are searching for solutions too. Right here is my code to stream the video from Dropbox and generate the AV participant:

func addARTV() {
        let dropboxVideoURL = URL(string: "VIDEO LINK IN DROPBOX")!
        getVideoDataFromDropbox(url: dropboxVideoURL) { knowledge in
            if let videoData = knowledge {
                let fileURL = self.writeVideoDataToTemporaryFile(videoData: videoData)
                
                DispatchQueue.predominant.async {
                    self.setupPlayerAndNode(fileURL: fileURL)
                }
            }
        }
    }

    func getVideoDataFromDropbox(url: URL, completion: @escaping (Information?) -> Void) {
        URLSession.shared.dataTask(with: url) { knowledge, response, error in
            if let knowledge = knowledge {
                completion(knowledge)
            } else {
                print("Error downloading video knowledge: (error?.localizedDescription ?? "Unknown error")")
                completion(nil)
            }
        }.resume()
    }

    func writeVideoDataToTemporaryFile(videoData: Information) -> URL {
        let tempURL = FileManager.default.temporaryDirectory.appendingPathComponent("video.mp4")
        
        do {
            strive videoData.write(to: tempURL)
            return tempURL
        } catch {
            print("Error writing video knowledge: (error.localizedDescription)")
            return tempURL
        }
    }

    func setupPlayerAndNode(fileURL: URL) {
        participant = AVPlayer(url: fileURL)
        
        let tvGeo = SCNSphere(radius:  10)
        tvGeo.firstMaterial?.diffuse.contents = participant
        tvGeo.firstMaterial?.isDoubleSided = true
        
        tvNode = SCNNode(geometry: tvGeo)
        
        tvGeo.firstMaterial?.diffuse.contentsTransform = SCNMatrix4Translate(SCNMatrix4MakeScale(-1, 1, 1), 1, 0, 0)
        
        sceneView.scene.rootNode.addChildNode(tvNode)
        sceneView2.scene.rootNode.addChildNode(tvNode)
        
        participant.play()
        isPlaying = true
    }

I’ve tried utilizing the hyperlink to obtain the video into a neighborhood file on the app because the video performs effective once I manually add it to my Xcode undertaking however this offers me the identical error. I’ve tried a number of variations of the code to stream the video however no success. The one info I’ve discovered is that it might be an encoding concern however I’m comparatively new to this and do not know easy methods to repair this.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles