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.54k stars 772 forks source link

RTP over UDP streaming #1077

Closed 1goresha closed 7 months ago

1goresha commented 2 years ago

Can i use your library for clear RTP(not RTSP) over UDP streaming? And how? Can you direct me to the answer, please? I want to achieve high speed by sacrificing guaranteed packet delivery. It is very interisting for me. Thank you in advance.

1goresha commented 2 years ago

I can't understand why the p2p network delay is 3 seconds, in your library RTP over UDP(default) is used, is not it?

pedroSG94 commented 2 years ago

Hello,

rtsp module use TCP by default. The delay is normally produced in player side. You have an example that you can reproduce in local network here: https://github.com/pedroSG94/rtmp-rtsp-stream-client-java/issues/1064#issuecomment-1055206908 If you are using RTSP-Server project the case is similar try using ffplay with -fflags nobuffer.

1goresha commented 2 years ago

I tested RTSP-Server in wifi local(wifi hotspot from android device). RTSP-Server is on android device and ffmpeg is on windows(10), i used ffplay and ffplay -fflags nobuffer, difference is 2 seconds, really huge. It means that i need to configure player side for low latency? And, can i change protocol in your library in rtsp module to UDP? Is it possible? I want to have the smallest latency. I don't care about some packets missing.

pedroSG94 commented 2 years ago

Hello,

with rtsp module you can change TCP to UDP using this line: https://github.com/pedroSG94/rtmp-rtsp-stream-client-java/blob/master/app/src/main/java/com/pedro/rtpstreamer/customexample/RtspActivity.java#L235

In case of RTSP-Server the player will decide if use TCP or UDP (I support both). You can read it in logcat: https://github.com/pedroSG94/RTSP-Server/blob/master/rtspserver/src/main/java/com/pedro/rtspserver/ServerClient.kt#L57 Check the logcat and you can know it. It is received in SETUP command from player side: https://github.com/pedroSG94/RTSP-Server/blob/master/rtspserver/src/main/java/com/pedro/rtspserver/ServerCommandManager.kt#L48

You will need find the way to force one protocol in your player.

1goresha commented 2 years ago

Ok, i see. My player uses UDP. Thank you for answer. But anyway, is it possible to use your library for RTP streaming (audio and video) without RTSP. I am a new in streaming protocols and just started to study your library, i apologize in advance for some may be obvious questions.

pedroSG94 commented 2 years ago

No, I haven't a way to use it without RTSP.

1goresha commented 2 years ago

Oh, i see, but is it possible to implement this protocol in your library? May be you have some ideas or recomendations for this?

pedroSG94 commented 2 years ago

This is possible because you can create a new module with that protocol and add it to project without modify encoder module. In this case rtp in ffmpeg is a stream of rtp packets directly without add previous rtsp negotiation with server but I have multiple question about it.

Anyway this protocol is not used normally and you haven't so much players that support it. For that reason, if it require so much time it isn't worth to develop.

1goresha commented 2 years ago

If you could answer these questions and modify it, it would be great! 👍 i think it will be usefull for many!

pedroSG94 commented 2 years ago

I will investigate a bit about it but for now I'm developing other feature so I don't know when I will do it. Also, it isn't really interested since not so much server/players support it

pedroSG94 commented 7 months ago

I have no plan to do it for now. I can change my idea if more users needed it Closing as inactive.