Streampunk / grandiose

Node.JS native bindings to Newtek NDI(tm).
Apache License 2.0
184 stars 47 forks source link

NDI Receiving #11

Closed NijsJonas closed 4 years ago

NijsJonas commented 4 years ago

Hi all, i try to receive an ndi stream to later convert it to jpg images to show on a webpage. but when i run my code the receiver stays undefined, code and error in attachment error 1 error 2

jensstigaard commented 4 years ago

Hi @yyy898 Are you are beginner JS programmer? The code is very cluttered even though it does very little. As I read your code, you have no return statement in your main-method, and therefore the then() returns undefined no matter what. I see the output shows an error code '4040' which means the receiver or data were not found. You could try to change your code such that the try/catch is "inside" the for-loop, meaning that every iteration of fetching of a video frame can fail or succeed, and will not stop running when experiencing an error. Something like this:


        for (let x = 0; x < 10; x++) {
            try {
                const videoFrame = await receiver.video(timeout)
                console.log(videoFrame)
            } catch (e) { console.error(e) }
        }