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

Latency playing RTSP video #11221

Open
stratosk opened this issue Jun 20, 2023 · 9 comments
Open

Latency playing RTSP video #11221

stratosk opened this issue Jun 20, 2023 · 9 comments
Assignees
Labels

Comments

@stratosk
Copy link

stratosk commented Jun 20, 2023

I'm using ExoPlayer for RTSP streaming video.
When I initially set the mediaSource and prepare the player, the video starts to play after ~10sec.
So, the video is already 10 sec behind the edge of the stream.

I use a listener like this:

override fun onPlaybackStateChanged(state: Int) {
                super.onPlaybackStateChanged(state)
                if (state == Player.STATE_READY) {
                    val bufferedPosition = exoPlayer.bufferedPosition
                    exoPlayer.seekTo(bufferedPosition)
                }
            }

in order to seek to the end of the stream once the video starts to play.
This cause a delay of another 10 seconds that the video freezes (due to buffering) but at the end the player almost is synced to the end of the stream.

I use this configuration for load control and livePlaybackSpeedControl:

        val loadControl = DefaultLoadControl.Builder()
            .setBufferDurationsMs(
                400,
                3000,
                400,
                400
            )
            .build()
        val livePlaybackSpeedControl = DefaultLivePlaybackSpeedControl.Builder()
            .setFallbackMinPlaybackSpeed(0.5f)
            .setFallbackMaxPlaybackSpeed(1.5f)
            .build()

Is there anything I can do to minimize these 10 seconds delays?

Thanks in advance!

@microkatz
Copy link
Contributor

@stratosk

I don't advise that seekTo method call after onPlaybackStateChanged as that will cause buffering. ExoPlayer is not setup to play an RTSP stream as a live stream. You can adjust the DefaultLoadControl settings as you have done to lessen the amount of samples needed to buffer before playing.

10 seconds seems like a long time to start playing though. Do you know if you are using TCP or UDP with your rtsp source? If you are using UDP then that might be quicker with the less overhead. I could check if you were to send logs. To enable logging, use RtspMediaSource.Factory.setDebugLoggingEnabled().

@stratosk
Copy link
Author

stratosk commented Jul 26, 2023

@microkatz thanks for your response!

I'm using UDP. I enabled the logs. Please find attached the section of the logcat until I see the video playing.

@stratosk
Copy link
Author

exoplayer.log

@SFocus
Copy link

SFocus commented Sep 18, 2023

@stratosk did you manage to solve the problem? I have the same problem as you. I need the stream to go almost without delay, low latency as possible.

@stratosk
Copy link
Author

@stratosk did you manage to solve the problem? I have the same problem as you. I need the stream to go almost without delay, low latency as possible.

@SFocus no I didn't. I tried with VLC. I have again some seconds delay, but at least when it starts playing, there is < 1sec delay from the edge of the video.
But, I still prefer ExoPlayer because of it's small size.

@SFocus
Copy link

SFocus commented Sep 19, 2023

@stratosk thank you for your response. You can take a look at the GStreamer library. With it I have achieved a delay in milliseconds, but I have other problems somewhere there is a crash.

@Vane101
Copy link

Vane101 commented Sep 22, 2023

@stratosk thank you for your response. You can take a look at the GStreamer library. With it I have achieved a delay in milliseconds, but I have other problems somewhere there is a crash.

Hi what type of problems are you encountering, checking if its worth going down that path.

@microkatz
Copy link
Contributor

exoplayer.log

Hi @stratosk, sorry for the delay. I looked at your file but did not see any ExoPlayer logs as well. You'll need to make sure you also add the EventLogger as an Analytics Listener to your player. Here is some documentation on how to do that. https://developer.android.com/guide/topics/media/exoplayer/debug-logging.

Also here are some directions about how to take a bug report.

Please again update this bug when you have done so! Thank you!

@stratosk
Copy link
Author

stratosk commented Sep 25, 2023

Hi @microkatz . No worries. Thank you for your response. Below the log after enabling the EventLogger.
eventloger.txt

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

No branches or pull requests

4 participants