Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lag in screen mirroring #1450

Open
Mahdi-RH opened this issue Apr 2, 2024 · 5 comments
Open

Lag in screen mirroring #1450

Mahdi-RH opened this issue Apr 2, 2024 · 5 comments

Comments

@Mahdi-RH
Copy link

Mahdi-RH commented Apr 2, 2024

Hi dear,
I am using RtspServerDisplay class for mirroring the surface of my Android device. when I start mirroring it, there is a lag (usually 3 seconds or more) showing my device's surface on Tv. I use Exoplayer for playing the stream. is there any way to fix it?

@pedroSG94
Copy link
Owner

Hello,

Do you mean delay?
Media projection class has a bit of delay. Also, the player could add delay to the stream. You can try reduce delay in exoplayer like this:
https://stackoverflow.com/questions/69748951/how-to-get-low-latency-in-exoplayer-rtsp-live-streaming-on-android#:~:text=ExoPlayer%20uses%20a%20DefaultLoadControl%20in,reduce%20the%20LoadControl%20buffer%20values.

@Mahdi-RH
Copy link
Author

Mahdi-RH commented Apr 3, 2024

Yes, I mean delay. Thank you for helping me. Is there any way to reduce the delay of the Media Projection class?

@pedroSG94
Copy link
Owner

pedroSG94 commented Apr 3, 2024

Hello,

No, but the delay is less than 1 second. I tested using this command instead of Exoplayer:

ffplay -fflags nobuffer rtsp://192.168.0.158:1935/

With this command the delay is around 1s. I started a chronometer at same time in my PC and the phone and this is the delay result:
imagen
As you can see the delay is around 460ms

@Mahdi-RH
Copy link
Author

Mahdi-RH commented Apr 7, 2024

Thank you. I reduced the delay in Exoplayer by the link you gave me. At first, it works well, but after a few minutes, the time of delay goes up again. Do you have any idea about it? Do you think Exoplayer is a good tool for screen mirroring ?

@pedroSG94
Copy link
Owner

pedroSG94 commented Apr 7, 2024

Hello,

Do you have any idea about it?

I'm not sure about it, You can try use UDP instead of TCP to reduce the delay and check if this solve the problem. You should do it in player side because if you use UDP or TCP is player decision. You can try both cases (TCP and UDP):
google/ExoPlayer#9151 (comment)
Anyway, I recommend you ask in Exoplayer project about it. Maybe, they can guide you more.

Do you think Exoplayer is a good tool for screen mirroring ?

No, exoplayer no aim to be a low delay player. You can check that one of the contributor said that:
google/ExoPlayer#10694 (comment)
But I don't know a RTSP player designed for low delay. Usually all players add buffering.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants