leadedge / ofxNDI

An Openframeworks addon to allow sending and receiving images over a network using the NewTek Network Device Protocol.
GNU General Public License v3.0
134 stars 48 forks source link

Exceptions thrown at 0x00000 (in ndireceiver_debug.exe): Access conflicts occur at 0xC0000005: execution location 0x00000000. #8

Closed ertertq closed 5 years ago

ertertq commented 5 years ago

Thank you very much for making this addon. I made an error running your examples/example-receiver using the NewTek NDI 3.8 SDK. I found it here in debug.

Bool of xNDIreceive:: Receive Image (unsigned int & width, unsigned int & height)

{

NDIlib_frame_type_e NDI_frame_type;

NDIlib_metadata_frame_t metadata_frame;

M_FrameType = NDIlib_frame_type_none;

If (pNDI_recv){

NDI_frame_type = NDIlib_recv_capture_v2 (pNDI_recv, & video_frame, NULL, & metadata_frame, 0);

NDI_frame_type is always equal to NDIlib_frame_type_none and then the program crashes after several calls to this function. I can't find the reason for this for the moment, because this example-receiver can only work in NewTek NDI 3.5 SDK? Thank you very much

leadedge commented 5 years ago

OK I will have a look at it. It shouldn't crash if returning NDIlib_frame_type_none because it isn't doing anything. I have been using the basic classes (ofxNDIsend and ofxNDIreceive) with 3.8 without any trouble. I am not sure why the receiver should require 3.5. It might take me a few days due to other commitments.

ertertq commented 5 years ago

Thank you very much for your reply.

I saw this label “Update to NDI 3.5 and Openframewoks 10”. I thought the examples/example-receiver code would work only in version 3.5. Thank you very much.

leadedge commented 5 years ago

Yes I have not updated the examples. The rest is updated for 3.8 and is up to date. Let me know whether updating to 3.8 fixes the problem.

Also what sender did you use to get this error? Recent work has indicated that the sender should be clocked or else asynchronous sending will cause problems. If you still get the error, please test with the NDI SDK "C++" sending example "NDIlib_Send_Video.cpp". Also try release as well as debug.

Edit - the examples should still work fine as they are with NDI 3.8 libraries.

ertertq commented 5 years ago

Hello, I use VLC Player to play video and send video data stream. VLC has a plug-in option of NDI to send ( NewTek VLC Media plugin ). And now I found the cause of the program crash, because my Processing. NDI.Lib.x86.DLL file was damaged. After I replaced the new file in SDK, the program work fine.

thank you very much. I would like to ask a question, that is, the frame rate. Through this acquisition of ndiReceiver. GetFps (), how can I keep the frame rate of OfApp the same as that of data acquired through NDI? Thank you

like ofSetFrameRate((int)ndiReceiver.GetFps()); but not work.

leadedge commented 5 years ago

The GetFps function actually calculates the received frame rate so it isn't exactly the fps set for the received sender. Also you will only get a steady value after it has received frames for a few seconds, so it is really no good for adjusting OpenFrameworks framerate.

In fact I intend to remove this function and return the NDI sender frame rate instead. Then you can adjust from that. I will create another function "GetSenderFps" to do this.

The problem remains that you will only get an fps value after the receiver has connected to the sender and received a frame, which then has the fps information. So this has to be done within the addon. I will look into how that can be done.

But I am interested to know why you want to adjust the Openframeworks framerate. Could you explain this for me?

leadedge commented 5 years ago

I have made some changes to include a GetSenderFps function which retrieves the fps that the sender was set up with. The timed function is still there if required.

This will allow you to set the Openframeworks fps to that of the sender. But it depends on the receiver being connected so that the sender fps can be retrieved. A new GetReceiverConnected function allows for this. Some work is needed in Update() to do this. I have not included the code in the receiver example, but can share via email - use the address on the GitHub repositories page.

I will close this now since this can be achieved and the original problem is resolved.

ertertq commented 5 years ago

thanks.

ertertq commented 5 years ago

This is because of network reasons, such as I receive data frame rate of 25 frames per second, but the refresh rate of open frameworks is 60 frames per second, so there will be screen jitter.

So I would like to ask you how you optimize the frame rate settings.

leadedge commented 5 years ago

If you already know the sender fps is 25, what happens if you change the Openframeworks frame rate to 25? That is all that you could do if the sender fps was detected by the receiver.

To detect the rate for different senders you can put this in Update().

```
// "int senderFps" is global and initialized to 0 in Setup
if (ndiReceiver.ReceiverConnected()) {
    // The receiver has received frames from the sender
    int fps = (int)round(ndiReceiver.GetSenderFps());
    if (senderFps != fps) {
        senderFps = fps;
        printf("Change fps to %d\n", senderFps);
        ofSetFrameRate(senderFps);
    }
}
else {
    // Sender has closed or dropped out
    if (senderFps > 0) {
        printf("Reset fps\n");
        senderFps = 0;
        ofSetFrameRate(60);
    }
}
```
ertertq commented 5 years ago

Thank you very much. According to the method you provided, the problem has been solved. Thank you.