September 27, 2018 at 6:30 am #4014eric720Participant
I have been using Spout to NDI sending frame over the network for a while. It all works out very well. The only thing I would like to change is the compression setting in NDI protocol. I notice the images do get quite a bit blurry compressed artifacts when sending 4k and higher resolution.
So is it possible to access the source code of “Spout to NDI”? I would like to contribute in it.
EricSeptember 28, 2018 at 12:57 am #4016
Reply sent by email with source code for the latest version.November 8, 2019 at 4:37 pm #4423
Is it possible to upload the source code on github?
I am interested by this code in order to develop my own video recorder.
I can’t use https://www.lightjams.com/spout-recorder.html since it doesn’t export the alpha layer and produces stuttering videos in 4k.
Also, I can not use a “spout receiver” from the examples since it transfers the texture to opengl which is not required for my use case and will slow things down.
ThanksNovember 9, 2019 at 12:38 am #4427
The Spout to NDI programs are now built with Openframeworks using ofxNDI (https://github.com/leadedge/ofxNDI), and extend the basic examples with a menu, dialog, settings etc. To begin with, you might benefit by examining the examples. You don’t have to transfer to OpenGL texture. A pixel buffer can be used directly.
As it happens, I am working on revising this for NDI 4.0, so the code is all over the place at the moment. I am waiting on a reply from the NDI forum before I can finalise it, so it’s not the best time to make up a package for you.
NDI 4.0 features a recording option that might work for you. There is a command line tool, so you can record from any NDI source straight away. It produces quicktime “.mov” videos. In fact a recording option is also built into the Studio Monitor application. I have not explored this myself. The NDI 4.0 SDK documentation is updated for it.
I am not sure how you will get on with 4K video. It’s a matter of trying it. I have attempted recording using FFmpeg with some success, but my experience is that at 4K it would struggle and drop frames.
Anyway have a look at these things and let us know how you get on.November 11, 2019 at 9:15 pm #4488
Thanks for all your recent help.
Would you tell me which process you use to copy the Spout texture to main memory in the Spout to NDI program?
I have been trying to use
glGetTexImage()but it’s slow, around 50ms, I need something below 16ms.
ThanksNovember 11, 2019 at 10:50 pm #4489
I tried using Spout ReceiveImage which uses glReadPixels.
It takes around 50 ms also.
I wanted to set SetBufferMode(true) to try with a PBO but https://github.com/leadedge/SpoutProcessing/blob/master/src/spout/JNISpout.java does not expose this methodNovember 11, 2019 at 11:24 pm #4490
void spoutCopy::memcpy_sse2(void* dst, void* src, size_t Size)looks like just what I need
Would someone point to a documentation on how one can update the https://github.com/leadedge/SpoutProcessing/blob/master/src/spout/JNISpout.java so I can set
I tried downloading the latest Spout.dll but it fails right at the beginning with
protected static native long init();
I am guessing that those libs https://github.com/leadedge/SpoutProcessing/tree/master/lib are a different beast.
November 12, 2019 at 1:31 am #4495
- This reply was modified 3 months, 2 weeks ago by Julien.
Have a look at spoutGLDXinterop::ReadGLDXpixels and you will see how the PBO buffering method is selected. There is no need to use SetBufferMode(true). Simply use SpoutSettings and check “Buffer” on. When this is done, the pbo read or write will be activated and that function uses spoutcopy.CopyPixels and then “memcpy_sse2” to transfer to or from the pbo memory. The JNI library source is not on GitHub I am sorry.
Spout to NDI uses exactly the same functions as you see on the ofxNDI examples. Both sender and receiver use ofTexture. If you look at the example receiver code you will see “ndiReceiver.ReceiveImage(ndiTexture)”. Then you can trace that back to an Openframeworks function to update the texture “texture.loadData” which ultimately uses “glTexSubImage2D”. The Spout SDK is not used in this case.November 12, 2019 at 4:31 pm #4498
Thanks a bunch, I will try this during the week.
I would also like to disable VerticalSync. Unfortunately SpoutJNI does not expose SetVerticalSync and looking at the source code I can see that it’s not possible to disable it via Windows Registry.
Is there anyway you would share the code and the process to build SpoutJNI?
Thanks in advance
November 12, 2019 at 4:41 pm #4500
- This reply was modified 3 months, 2 weeks ago by Julien.
I’d be curious also what happened so that it was decided that VerticalSync was set to 1 by default.
Openframeworks and other opengl libs don’t set it by default.November 12, 2019 at 7:23 pm #4501
Using PBO/glMapBuffer/”Improved memcpy with SSE2″ improved the texture downloading time from 85ms to 55ms which is a good start.
I downloaded the app cuda-z to verify how much bandwidth I could theoretically have. As described here https://sourceforge.net/p/cuda-z/discussion/837185/thread/7e6ff0ec0f/ it’s 2.5 GiB/s.
At 2.5 GiB/s I should be able to transfer the data in less than 15 ms which is what I need at 60 fps.
Right now it transfers at 650 MiB/s.
Would anyone have an idea what could explain the difference in transfer speed between what I’m achieving and the figure shown in cuda-z?
Thanks!November 13, 2019 at 12:56 am #4502
The JNISpout library is set up with paths locked to my own machine and I change it as required, so I have not made a repository and keep that updated. It is also tied in with the Processing library for Eclipse and it’s now using Spout 2.007, so it’s not immediately useable on another system. It’s easier if I look at what is necessary to add the vertical sync function if you need it.
The function uses wglSwapIntervalEXT, so this could be useful information.
Why not in the meantime use the NVIDIA control panel or equivalent to set vsync on or off to see how that affects your application.
For CUDA I assume you would need to use CUDA specific functions. I have no experience with that.November 13, 2019 at 8:16 am #4503
I will try using the Nvidia panel thanks.
- You must be logged in to reply to this topic.