CESNET / UltraGrid

UltraGrid low-latency audio and video network transmission system
http://www.ultragrid.cz
Other
492 stars 53 forks source link

NDI Sender issues #250

Closed maybites closed 1 year ago

maybites commented 1 year ago

Hi

I am observing issues on creating NDI sender on Windows 10:

uv.exe -P11052 -t ndi:name="Existing NDI Source" -d ndi:name=testNDI

uv.exe -P11052 -t spout:name="Spout Demo Sender":fps=60 -d ndi:name=testNDI

Not working means: it creates a NDI source but its content is black.

uv.exe -P11073 -t testcard:80:60:1:UYVY -d ndi:name=testNDI url.zhdk.ch

uv.exe -P11073 -t testcard:80:60:1:UYVY -d gl:spout="UltragridChannel_5" url.zhdk.ch

cheers

martin

MartinPulec commented 1 year ago

Hi,

I am afraid that I cannot reproduce the problem, I've tried uv -t spout -d ndi:name=test, also with the sample Spout Demo Source. NDI stream was normally produced (called "hostname (test)").

Would it be possible to create minimal working example(s) of the problem? Eg. avoiding -P parameter and using testcard to test NDI display and GL display to test Spout capture over localhost, if the problem still persist? Eg. works?

uv -t spout:name="Spout Demo Sender":fps=60 -d gl
uv -t testcard:size=640x480 -d ndi:name=testNDI

Thanks, Martin

maybites commented 1 year ago
C:\Users\IAAdmin>D:/00_core/UltraGrid/app/uv.exe -t spout -d ndi:name=testNDI

UltraGrid 1.7.2 (tags/v1.7.2 rev a06d459a built Jan 18 2022 11:49:29)

Display device   : ndi
Capture device   : spout
Audio capture    : none
Audio playback   : none
MTU              : 9000 B
Video compression: none
Audio codec      : PCM
Network protocol : UltraGrid RTP
Audio FEC        : none
Video FEC        : none

This application uses NDI® available from http://ndi.tv/
NDI® is a registered trademark of NewTek, Inc.

Display initialized-ndi
[SPOUT] Initialized successfully - server name: ARRAKIS (testNDI), width: 1920, height: 1080, fps: 60, codec: Red Green Blue 24bit
Video capture initialized-spout
Created new RTP session with SSRC 0x4660965f.
SSRC 4660965f: 128/128 packets received (100%), 0 lost, max loss 0.
[video dec.] New incoming video format detected: 1920x1080 @60.00p, codec RGB
[video dec.] Successfully reconfigured display to 1920x1080 @60.00p, codec RGBA
[SPOUT capture] 260 frames in 5.00128 seconds = 51.9867 FPS
SSRC 4660965f: 187924/210688 packets received (89.2%), 22764 lost, max loss 64.
[SPOUT capture] 229 frames in 5.0013 seconds = 45.7881 FPS
SSRC 4660965f: 145955/160512 packets received (90.93%), 14557 lost, max loss 64.

looks good on the console but the NDI stream is black.

uv -t spout:name="Spout Demo Sender":fps=60 -d gl

works as expected and...

C:\Users\IAAdmin>D:/00_core/UltraGrid/app/uv.exe -t testcard:80:60:1:UYVY -d ndi:name=testNDI
UltraGrid 1.7.2 (tags/v1.7.2 rev a06d459a built Jan 18 2022 11:49:29)

Display device   : ndi
Capture device   : testcard
Audio capture    : none
Audio playback   : none
MTU              : 9000 B
Video compression: none
Audio codec      : PCM
Network protocol : UltraGrid RTP
Audio FEC        : none
Video FEC        : none

This application uses NDI® available from http://ndi.tv/
NDI® is a registered trademark of NewTek, Inc.

Display initialized-ndi
Fill rect at 0,0
Fill rect at 14,0
Fill rect at 28,0
Fill rect at 42,0
Fill rect at 56,0
Fill rect at 70,0
Fill rect at 0,14
Fill rect at 14,14
Fill rect at 28,14
Fill rect at 42,14
Fill rect at 56,14
Fill rect at 70,14
Fill rect at 0,28
Fill rect at 14,28
Fill rect at 28,28
Fill rect at 42,28
Fill rect at 56,28
Fill rect at 70,28
Fill rect at 0,42
Fill rect at 14,42
Fill rect at 28,42
Fill rect at 42,42
Fill rect at 56,42
Fill rect at 70,42
Fill rect at 0,56
Fill rect at 14,56
Fill rect at 28,56
Fill rect at 42,56
Fill rect at 56,56
Fill rect at 70,56
Testcard capture set to 80x60, bpp 2.000000
Video capture initialized-testcard
Created new RTP session with SSRC 0x4827938b.
[video dec.] New incoming video format detected: 80x60 @1.00p, codec UYVY
[video dec.] Successfully reconfigured display to 80x60 @1.00p, codec UYVY
[testcard] 6 frames in 5.98864 seconds = 1.0019 FPS

works fine.

maybites commented 1 year ago

However, note:

C:\Users\IAAdmin>D:/00_core/UltraGrid/app/uv.exe -t testcard:80:60:1:UYVY -d ndi:name=testNDI

is not the same as

C:\Users\IAAdmin>D:/00_core/UltraGrid/app/uv.exe -P11073 -t testcard:80:60:1:UYVY -d ndi:name=testNDI url.zhdk.ch

where I expect to receive an ultragrid stream from our server... -t testcard:80:60:1:UYVY is only there to keep the proxies data flowing...

MartinPulec commented 1 year ago

I've updated UltraGrid to Spout 2.007 and made couple of related changes in code. It is here as a continuous build. Would it be possible to try it out?

looks good on the console but the NDI stream is black.

`uv -t spout:name="Spout Demo Sender":fps=60 -d gl

works as expected and...

But in the above command, the source is "ARRAKIS (testNDI)", not "Spout Demo Sender". Can you confirm that it is also reproducible with the sample sender?

I've just updated Spout to latest version (2.007h) and NDI as well. And yet I am still not able to reproduce the issue – using simply -t spout -d ndi and capturing on another computer, I am able to see the Spout Demo correctly.

C:\Users\IAAdmin>D:/00_core/UltraGrid/app/uv.exe -t testcard:80:60:1:UYVY -d ndi:name=testNDI

is not the same as

C:\Users\IAAdmin>D:/00_core/UltraGrid/app/uv.exe -P11073 -t testcard:80:60:1:UYVY -d ndi:name=testNDI url.zhdk.ch

I am aware of that, but the point is that -P11073 -t testcard:80:60:1:UYVY is unneeded to reproduce the issue. On the other hand, it doesn't say anything what is the problematic signal, while the first command does. That's why I think something like the first should be preferred because it removes the uncertainty about signal (of course if the issue isn't network related, which doesn't seem to be the case).

maybites commented 1 year ago

I just downloaded the latest and

-t spout -d ndi

is not working: the NDI stream is black.

C:\Users\IAAdmin>"C:\Program Files\UltraGrid\uv.exe" -t spout -d ndi
UltraGrid 1.7+ (tags/continuous rev 0660117a built Sep 23 2022 09:28:20)

Display device   : ndi
Capture device   : spout
Audio capture    : none
Audio playback   : none
MTU              : 9000 B
Video compression: none
Audio codec      : PCM
Network protocol : UltraGrid RTP
Audio FEC        : none
Video FEC        : none

This application uses NDI® available from http://ndi.tv/
NDI® is a registered trademark of NewTek, Inc.

Display initialized-ndi
Video capture initialized-spout
Created new RTP session with SSRC 0x08a620c1.
[Spout] Connection updated - server name: ARRAKIS (uv), width: 640, height: 360, fps: 60, codec: Red Green Blue 24bit
SSRC 0x08a620c1: 128/128 packets received (100.0000%), 0 lost, max loss 0
[video dec.] New incoming video format detected: 640x360 @60.00p, codec RGB
[video dec.] Successfully reconfigured display to 640x360 @60.00p, codec RGBA
[ndi] 272 frames in 5.01125 seconds = 54.2779 FPS
[spout] 290 frames in 5.00381 seconds = 57.9559 FPS
SSRC 0x08a620c1: 26880/26880 packets received (100.0000%), 0 lost, max loss 0
[ndi] 301 frames in 5.01664 seconds = 60.0003 FPS
[spout] 300 frames in 5.00001 seconds = 59.9999 FPS
SSRC 0x08a620c1: 27008/27008 packets received (100.0000%), 0 lost, max loss 0
Video dec stats (cumulative): 674 total / 674 disp / 0 drop / 0 corr / 0 missing.
Pbuf: total 5875200/5875200 packets received (100.00000%).
Exit

what is working though is

-t testcard:80:60:1:UYVY -d ndi:name='Telemersive_channel_0' -P11026 telemersion.zhdk.ch

where I receive an ultragrid stream from my proxy script and turn it directly into an NDI stream.

current status of my test system:

Edition Windows 10 Pro Version 21H2 Installed on ‎07/‎09/‎2022 OS build 19044.2006 Experience Windows Feature Experience Pack 120.2212.4180.0

maybites commented 1 year ago

When I try the same thing on OSX I am unsuccessful, too:

 ~ % /Applications/_Video/uv-qt.app/Contents/MacOS/uv -t syphon -d ndi
MasterPortDestroyer is armed
UltraGrid 1.7+ (tags/continuous rev 9cb6ffca built Jan 14 2022 15:12:33)

Display device   : ndi
Capture device   : syphon
Audio capture    : none
Audio playback   : none
MTU              : 9000 B
Video compression: none
Audio codec      : PCM
Network protocol : UltraGrid RTP
Audio FEC        : none
Video FEC        : none

This application uses NDI® available from http://ndi.tv/
NDI® is a registered trademark of NewTek, Inc.

Display initialized-ndi
Video capture initialized-syphon
Created new RTP session with SSRC 0x4f64fe83.
Cannot run display when another mainloop registered!

Exit
MasterPortDestroyer triggered

I can't make sense of the error 'Cannot run display when another mainloop registered!'. There is no other ultragrid instance running on this machine.

MartinPulec commented 1 year ago

I just downloaded the latest and

-t spout -d ndi

is not working: the NDI stream is black.

The problem I have is that I still do not understand where the problem lies because there are 2 possibilities – either Spout captures black and NDI works fine or Spout capures correct signal and NDI produces black. That's why I wanted to know how does it look with GL.

So assuming -t spout -d ndi is not working, does -t spout -d gl display the correct output? If so, does -t spout:name="Spout Demo Sender":fps=60 -d ndi?

MartinPulec commented 1 year ago

I can't make sense of the error 'Cannot run display when another mainloop registered!'. There is no other ultragrid instance running on this machine.

This is a temporary limitation of UltraGrid. Because of some architectural specific of macOS, one UltraGrid currently cannot run both Syphon capture and NDI display. However you can split the command and it will work:

uv -t syphon -m 9000        # '-m 9000' is optional but recommended
uv -d ndi

If you wish, you can open a separate ticket for that because this is an independent issue.

UPDATE: In this particular case this is now fixed in continuous builds (NDI display doesn't actually need the mainloop).

maybites commented 1 year ago

So assuming -t spout -d ndi is not working, does -t spout -d gl display the correct output? If so, does -t spout:name="Spout Demo Sender":fps=60 -d ndi?

  1. -t spout -d ndi gives just a black output (it shows framerates, so my ndi receiver receives frames, but they are all black)

  2. -t spout -d gl works fine.

  3. -t spout:name="Spout Demo Sender":fps=60 -d ndi same result as -t spout -d ndi.

tested with UltraGrid 1.7+ (tags/continuous rev 0660117a built Sep 23 2022 09:28:20)

maybites commented 1 year ago

UPDATE: In this particular case this is now fixed in continuous builds (NDI display doesn't actually need the mainloop).

nice one. It works like a charm!

MartinPulec commented 1 year ago

Thanks for the tests. I've also done some testing and actually I hit some similar problem on one computer. But it actually indicated problem with Spout, not NDI.

It seems to have been caused by presence of older Spout installation while running the (new) Spout Demo. Running SpoutSettings version 2.007 fixed the problem (because running the SpoutSettings does some pseudo-installation - it overrides particular registry keys). Anyways, I noticed that in that Spout settings there is also option to select "CPU share". Is it possible to try to check this option on (if the former doesn't help)?

maybites commented 1 year ago

Finally I got around to test your suggestion with SpoutSettings.

-t spout -d ndi

Its not still working. Output is black. I tested it on two different machines.

When I enable CPU share, it doesnt keep the setting, though. When I reopen the settings, the CPU share is disabled again..

Using SpoutSettings Vers 1.043 for Spout 2.007

MartinPulec commented 1 year ago

unfortunately I am afraid that I really cannot reproduce the issue, see the following video that I am not fooling you:

https://owncloud.cesnet.cz/index.php/s/FOHqi4wRM2eelsa

I've also disabled "Auto share" (so that it always uses GPU) and it still works. Tested with NVIDIA GeForce 1080 Ti. I am afraid that I got nothing here. I even don't know if the problem is related to Spout or NDI, in the end.

Update: it is also possible that it is HW-dependent but without more information I cannot tell.

maybites commented 1 year ago

thanks for the video.

We are on the same page.

I figured out my problem: There is a service on my machine (which I haven't identified yet) that starts an ndi-server called

(Remote Connection 1)

and

-t ndi -d gl

picks that one up, instead of the one I just created with:

-t spout -d ndi

when properly named, everything works flawlessly:

-t spout -d ndi:name="Spout"

-t ndi:name="ARRAKIS (Spout)" -d gl

(ARRAKIS is the name of my machine)

maybites commented 1 year ago

Please accept my apoligies that I have sent you on this unnecessary chase and wasted your time.

maybites commented 1 year ago

Strange, while ultragrid has no issues to open the NDI stream and pass it black into a spout stream, when I try to open it with OBS its black..

and the same experience with NDI to Spout

MartinPulec commented 1 year ago

I am afraid that I am not sure if I understood your post correctly – you mean that the UG NDI->Spout stream is correct while doing the same, in OBS and NDI to Spout it is black? Or the Spout stream generated by UltraGrid is black when displayed by NDI to Spout or OBS? I understood it in the first way but then I am not sure what is the question.

thanks, M.

maybites commented 1 year ago

sorry:

you mean that the UG NDI->Spout stream is correct while doing the same, in OBS and NDI to Spout it is black?

exactly: UG Spout -> NDI works for UG NDI -> Spout, but if I want to show the same NDI inside OBS or use NDI2Spout, it shows black.

MartinPulec commented 1 year ago

Could you please simplify your setup? I understand it in a way, that an usual UltraGrid's NDI output (server in terms of NDI) is not correctly displayed with OBS or NDI2Spout. So sufficient generator of the problematic stream would be: uv -t testcard -d ndi, right? (I mean no need to tackle with Spout.)

If so, cannot confirm this, neither. Please see the attached picture showing that testcard over NDI with Studio Monitor from NDI Tools: ug-ndi-screenshot

I've could not find NDI2Spout and for OBS I've only found the obs-ndi plugin which is obsolete – it uses NDI 4 and it it doesn't seem to work with current OBS (v28.0.3).

maybites commented 1 year ago

NDI2Spout is inside that zip (eventough it is called Spout2NDI)

using NDI Studio Monitor:

uv -t testcard -d ndi

works on my machine, too.

uv -t spout -d ndi

is black.

-t spout:name="Spout Demo Sender" -d ndi

is black, too.

MartinPulec commented 1 year ago

I don't necessarily think that this is a problem in UltraGrid. If UltraGrid displays it correctly while the others not, the problem may be in the other tools, I guess.

Anyways, I've added an option :norgb to NDI display to force passing YCbCr codecs to NDI and NDI Monitor displays the output correctly after that. So I assume that it doesn't process RGB, which is natively produced by Spout, only YCbCr codecs. I cannot confirm that, however, since the NDI Monitor isn't OSS. obs-ndi [https://github.com/Palakis/obs-ndi/blob/b900630fb0712a1163abb69f07489348023fef0c/src/obs-ndi-source.cpp#L360](may support RGB) but it cannot be run and I haven't found source for NDI2Spout.

Anyways, the RGB->YCbCr conversion is slow, so it may not work real-time for bigger streams.

maybites commented 1 year ago

I don't necessarily think that this is a problem in UltraGrid. If UltraGrid displays it correctly while the others not, the problem may be in the other tools, I guess.

I disagree. NDI Studio Monitor should be considered the standard for the NDI protocol. If ultragrid is unable to deliver an NDI stream that the standard app cannot show, then there is something wrong with ultragrid's implementation.

haven't found source for NDI2Spout.

It seems not to be open sourced. If you are interested I can directly ask the developer.

MartinPulec commented 1 year ago

I believe it may be alpha color related, I've partially updated some occurrences. If it don't help, did you tried the :nopbo option?

maybites commented 1 year ago

uv -t spout -d ndi

is working now. no need for :nopbo

thank you for keeping on it!