pedroSG94 / RootEncoder

RootEncoder for Android (rtmp-rtsp-stream-client-java) is a stream encoder to push video/audio to media servers using protocols RTMP, RTSP, SRT and UDP with all code written in Java/Kotlin
Apache License 2.0
2.45k stars 761 forks source link

SRT Streaming issue #1330

Closed apdofficial closed 4 months ago

apdofficial commented 8 months ago

Hello Pedro,

I have a question about the SRT client. Which version does the current implementation support?

I am trying to setup a connection to a OvenMediaEngine. The situation is as follows:

However, on the player side, there is no video coming. When I test the server with OBS studio as explained in this link (srt://ip:port?streamid=srt%3A%2F%2F{domain or IP address}[%3APort]%2F{App name}%2F{Stream name}) the stream is coming through. I noticed that in your library you expect the URL to be in the following form: srt://ip:port/streamid. Thus, I supply the link as follows: srt://ip:port/srt%3A%2F%2F{domain or IP address}[%3APort]%2F{App name}%2F{Stream name}.

My hypothesis is that the SRT socket connects successfully but the streamid is perhaps incorrectly supplied.

Any idea what could be the issue here?

Thank you for your response in advanced.

Regrads, Andrej

pedroSG94 commented 8 months ago

Hello,

SRT is using version 1.4.4: https://github.com/pedroSG94/RootEncoder/blob/master/srt/src/main/java/com/pedro/srt/srt/packets/control/handshake/extension/HandshakeExtension.kt#L28

I will test it and report you back

apdofficial commented 8 months ago

Thanks for your quick reply! Awesome.

pedroSG94 commented 8 months ago

How are you doing to reproduce the stream using a player? I'm using ffmpeg as encoder to test (it is used by OBS so it should be the same)

It is not working for me using docker from quick start guide: https://airensoft.gitbook.io/ovenmediaengine/quick-start#playback And player provided on github page: http://demo.ovenplayer.com/ I also tried using VLC or ffplay

robinwesterik commented 8 months ago

We deployed OvenMediaEngine on a Ubuntu 22.04 VPS running docker and using their OME Docker Launcher:

After deployment one has to manually enable SRT in the OME config file (located at /opt/ovenmediaengine/bin/origin_conf/Server.xml)

The input stream URL that works by default after enabling SRT is: srt://example.com:9999?streamid=srt%3A%2F%2Fexample.com%3A9999%2Fapp%2Fstream

The playback URL that works by default is: ws://example.com:3333/app/stream

Using OBS, we found no problem using both H265 and H264 over SRT. We we're able to view the output stream via OME's demo player (be sure to use HTTP, not HTTPS, when visiting the website)

pedroSG94 commented 8 months ago

Thank you, I will try that way

robinwesterik commented 8 months ago

Using RootEncoder, we intermittently get adaptation header parsing errors on our OME logs:

[2023-11-08 11:18:22.591] I [SPSRT-s9999:21] SrtProvider | srt_provider.cpp:203  | The SRT client has connected : <ClientSocket: 0x7f7c362be010, #844379157, Connected, SRT, Nonblocking, 85.146.106.188:38443> [844379157] [srt%3A%2F%2Fexample.com%3A9999%2Fapp%2Fstream]
[2023-11-08 11:18:22.592] I [SPSRT-s9999:21] Provider | stream.cpp:49   | Unknown/stream(332) has been started stream
[2023-11-08 11:18:25.302] E [SPSRT-s9999:21] MPEGTS_PACKET | mpegts_packet.cpp:145  | Could not parse adaptation header
[2023-11-08 11:18:28.431] E [SPSRT-s9999:21] MPEGTS_DEPACKETIZER | mpegts_depacketizer.cpp:288  | Could not find section(PID: 0) for depacketizing
[2023-11-08 11:18:28.465] E [SPSRT-s9999:21] MPEGTS_DEPACKETIZER | mpegts_depacketizer.cpp:288  | Could not find section(PID: 0) for depacketizing
[2023-11-08 11:18:28.833] E [SPSRT-s9999:21] MPEGTS_PACKET | mpegts_packet.cpp:145  | Could not parse adaptation header
[2023-11-08 11:18:32.901] E [SPSRT-s9999:21] MPEGTS_PACKET | mpegts_packet.cpp:145  | Could not parse adaptation header
[2023-11-08 11:18:36.880] E [SPSRT-s9999:21] MPEGTS_PACKET | mpegts_packet.cpp:145  | Could not parse adaptation header
[2023-11-08 11:18:41.382] E [SPSRT-s9999:21] MPEGTS_PACKET | mpegts_packet.cpp:145  | Could not parse adaptation header
[2023-11-08 11:18:42.652] E [SPSRT-s9999:21] MPEGTS_PACKET | mpegts_packet.cpp:145  | Could not parse adaptation header
[2023-11-08 11:18:43.185] E [SPSRT-s9999:21] MPEGTS_PACKET | mpegts_packet.cpp:145  | Could not parse adaptation header
[2023-11-08 11:18:48.778] E [SPSRT-s9999:21] MPEGTS_PACKET | mpegts_packet.cpp:145  | Could not parse adaptation header
[2023-11-08 11:18:50.380] E [SPSRT-s9999:21] MPEGTS_PACKET | mpegts_packet.cpp:145  | Could not parse adaptation header
[2023-11-08 11:18:53.319] E [SPSRT-s9999:21] MPEGTS_PACKET | mpegts_packet.cpp:145  | Could not parse adaptation header
[2023-11-08 11:19:03.885] E [SPSRT-s9999:21] MPEGTS_DEPACKETIZER | mpegts_depacketizer.cpp:288  | Could not find section(PID: 0) for depacketizing
[2023-11-08 11:19:09.974] E [SPSRT-s9999:21] MPEGTS_PACKET | mpegts_packet.cpp:145  | Could not parse adaptation header
...

RootEncoder doesn't seem to give any errors, but the stream can not be played on OME.

pedroSG94 commented 8 months ago

For now, I can reproduce the case and I'm working to find the reason.

pedroSG94 commented 8 months ago

After investigate it and some changes I was able to stream only audio. Video track is still bugged and I'm working to find the reason. You can follow this changes in this PR: https://github.com/pedroSG94/RootEncoder/pull/1336 I hardcoded my url test in OpenGl SRT example for testing. You can replace it and test if you want

pedroSG94 commented 7 months ago

Hello,

Finally it is working using the code in the branch: https://github.com/pedroSG94/RootEncoder/pull/1336

But only H264 is working. Using H265 you will have a black screen. I can't see that H265 is supported. Can you confirm me that it is supported?

I will fix tests and merge changes

robinwesterik commented 7 months ago

Thanks for the quick fixes, they are much appreciated. As stated in the documentation, OME should support H265. I have confirmed this by streaming an H265 video feed via OBS.

pedroSG94 commented 7 months ago

I see,

I will try to fix it. For now, you can use this gradle to test using H264 (this is the last commit of the fix branch):

implementation 'com.github.pedroSG94:RootEncoder:2981a93caf'
pedroSG94 commented 7 months ago

Thanks for the quick fixes, they are much appreciated. As stated in the documentation, OME should support H265. I have confirmed this by streaming an H265 video feed via OBS.

Which version of OBS and SO did you use to test? It is not available on Linux version: imagen

apdofficial commented 7 months ago

Thanks for the fixes, Pedro!

The H.264 SRT stream works; I just tested the fix branch. The H.265 still does not work, the bytes are sent but nothing is shown on the player side. The encoding depends on your hardware, whether you have an encoder which supports H.265, I think unless it can do CPU encoding. I've used a Macbook Pro with the ARM M1 Pro chip, which supports H.265 encoding.

FYI, maybe this will be useful: https://obsproject.com/forum/threads/obs-28-no-hevc-streaming-encoder-option.160539/

image
pedroSG94 commented 7 months ago

Hello,

Thank you, I will try with my mac mini with M1 chip and OBS.

apdofficial commented 7 months ago

Hello Pedro,

@robinwesterik and me, we did some more testing. It turns out, to avoid the black screen on OME with H.265 you have to use LLHLS as the decoder. We tested SRT H.265 with OBS and LLHLS on the player side and it worked. (You have to use HTTP instead of HTTPS).

When streaming using the RootEncoder library with SRT and H.265, the OME logs are as follows:

[2023-11-14 10:13:14.419] I [SPSRT-s9999:21] Transcoder | transcoder_stream.cpp:46   | [#default#app/stream(492)] Transcoder stream has been started
[2023-11-14 10:13:14.421] I [SPSRT-s9999:21] Provider | stream.cpp:364  | [PTS] Wrap around detected. track:32
[2023-11-14 10:13:14.421] I [SPSRT-s9999:21] Provider | stream.cpp:385  | [DTS] Wrap around detected. track:32
[2023-11-14 10:13:14.423] I [SPSRT-s9999:21] SrtProvider | srt_provider.cpp:342  | SrtProvider::OnDisonnected : <ClientSocket: 0x7f7c36273010, #844379132, Error, SRT, Nonblocking, 85.146.106.188:46079> [srt%3A%2F%2Fomeh265.iotrobor.nl%3A9999%2Fapp%2Fstream]

Let us know in case of any questions.

pedroSG94 commented 7 months ago

Hello,

I was testing with OBS with my MacMini M1 and I have exactly the same problem that with my library. Black screen video but audio working using wss source and never load using HLS LL source. I let you a video here:

https://github.com/pedroSG94/RootEncoder/assets/17556876/b98d7527-1e35-4cbb-a2fb-7bf64ed96132

As you can see in the video you have wireshark to make sure that streaming is working where you can see the server IP in destination that is the same that the used in OBS and player.

I also tested using SRT url encoded as suggested in the tutorial but with the same result. I tested using H264 and it is working fine:

Captura de pantalla 2023-11-15 a las 22 09 15

Tested using: Mac mini M1 2020, 8GB ram, macOS Sonoma 14.0 OBS Studio 30.0 (apple silicon arm version) with H264 and HEVC apple hardware encoder OvenMediaEngine 16.0 (using docker provided in quick start guide) Player without TLS provided in github readme (you can check in the video that it is not secure connection in the browser url bar)

pedroSG94 commented 4 months ago

Closing as inactive.