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

player.getCurrentLiveOffset() keep changing #10170

Closed
1 task
fgl27 opened this issue Apr 10, 2022 · 12 comments
Closed
1 task

player.getCurrentLiveOffset() keep changing #10170

fgl27 opened this issue Apr 10, 2022 · 12 comments
Assignees
Labels

Comments

@fgl27
Copy link

fgl27 commented Apr 10, 2022

ExoPlayer Version

2.17.0

Devices that reproduce the issue

Any device tested has this issues

Devices that do not reproduce the issue

No response

Reproducible in the demo app?

Not tested

Reproduction steps

Play a live stream and check the value of player.getCurrentLiveOffset() changing

Expected result

the value not chaging

Actual result

the value changes

Media

Any live streams seems to cause this issue

Bug Report

@fgl27
Copy link
Author

fgl27 commented Apr 10, 2022

I'm using player.getCurrentLiveOffset() to get the playback value for live streams and I have found a issue.

The initial values show a values that is the correct one or almos (+- a few ms), but the value doesn't stays constant it keeps changing for a log time, it 5min of playback the value will change 3 to 5 seconds, but this is a live stream that is playing just fine no rebuffer no slows down notting.

I did some check on how the getCurrentLiveOffset() fun works, and the issue seems to be on the value of getContentPosition() that keeps changing up or down.

Yes I know this is a live stream and the value of getContentPosition() will change as segments are be used and download, but this change is not the expected behavior.

The value of getContentPosition() start at around 5000, the it changes to 4000, 5000 or 6000 the segment size is 2000ms and I change exoplayer to update the playlist it 1000ms, but after 5min of playback the values are 9000, 10000 or 11000, it keeps like this until it settles eventually on a value of LiveOffset that is wrong.

Another test that I did was using player.seekTo(position_ms) to change the position, and when I do this problem will not happen, the value of player.getCurrentLiveOffset() will be close to the position_ms I use and the value of getContentPosition() will not change as before, on this case the value of player.getCurrentLiveOffset() it will change a little (500ms at most) for about 10 to 30s and then will stop changing and will keep the same value for as long as the stream is live and no internet issue causes a rebuffer.

I tested this on the dev branch when the head was https://github.com/google/ExoPlayer/commits/bd52b19a851cc215b2abfcfd6339bbddad6325a5

I also tested when the head was https://github.com/google/ExoPlayer/commits/bf462aca69dbd4760c39ca2910188d91610f3a16

on both cases the issues is there, I don't know when this was introduce, but I do remember not having this problem

@fgl27
Copy link
Author

fgl27 commented Apr 10, 2022

I made a video do demonstrate the issue

https://www.youtube.com/watch?v=3yXGcv8Rjkw

Latency to broadcaster on top right is player.getCurrentLiveOffset()

  • At 27s I change the playback speed to 0.25X, at 37s I change it back to 1X.
  • The latency changes from 3.5 to 10s as expected but will not stay there.
  • After 4 min the value is at 3.2s and the buffer size (player.getTotalBufferedDuration()) also is lower by similar amount.

There is an Exoplayer functionality that changes the playback speed, for some reason without user interaction?

Because from what I see there the latency is been lowered 0.02s to 0.03s it second of playback for no reason. Making one believed that the playback speed isn’t 1X, but 1.03X or close to it.

Second test same video

  • At 5 min I use the progress bar (player.seekTo(position_ms)) to change the position of the video.
  • The latency changes to 13.1s.
  • After 20 seconds the latency stables at 12.8s.

Here for some reason using player.seekTo(position_ms) no issue.

@icbaker
Copy link
Collaborator

icbaker commented Apr 11, 2022

Are you playing low latency live streams? If so, this is expected:

ExoPlayer adjusts the live offset by slightly changing the playback speed. The player will try to match user and media preferences, but will also try to react to changing network conditions.

https://exoplayer.dev/live-streaming.html#customizing-the-playback-speed-adjustment-algorithm

This used to be done for all live streams, but since b09b8dc (included in 2.17.0) it's only applied to low latency live streams (I'll re-word the live-streaming.html page to make this distinction more clear).

@icbaker
Copy link
Collaborator

icbaker commented Apr 11, 2022

From lower down that page:

If automatic playback speed adjustment is not desired, it can be disabled by setting minPlaybackSpeed and maxPlaybackSpeed to 1.0f.

@fgl27
Copy link
Author

fgl27 commented Apr 11, 2022

I expected that the default would always be 1.0x Speed, most important it be 1.0 right after I manually set the speed.

No this is just a regular live stream, but maybe I'm wrong How Exo determinates if it is a low latency stream?

I will set the default speed I never did, as I expected the default be 1.0, and I don’t know the behavior of it after the user changes the speed manually, I’ll check all that and report.

@fgl27
Copy link
Author

fgl27 commented Apr 17, 2022

Setting

.setLivePlaybackSpeedControl(
                            new DefaultLivePlaybackSpeedControl.Builder()
                                    .setFallbackMaxPlaybackSpeed(1.0f)
                                    .build())

Fix the issue.

Thanks.

@fgl27
Copy link
Author

fgl27 commented Apr 18, 2022

Another test was done and I have a doubt.

When the internet connection speed is very close to the stream minimum necessary bandwidth, the player will show down the playback until the latency is 30s.

Is this expected behavior?
There is a way to prevent this?

Even with setLivePlaybackSpeedControl we have this issue on this case.

@icbaker
Copy link
Collaborator

icbaker commented Apr 19, 2022

You've only set a max speed and not a min speed, so it seems expected that the player will still slow down. From the linked guide:

For example, if rebuffers occur during playback, the player will move further away from the live edge.

Note that you don't need to set the LivePlaybackSpeedControl to implement my suggestion from #10170 (comment). As described in the linked guide, you can set the min and max speeds directly on either of:

  • DefaultMediaSourceFactory (to affect all media being played)
  • The specific MediaItem

Customizing the LivePlaybackSpeedControl is arguably more 'niche' because it's designed to control how the player speeds up and slows down, but if you're trying to disable speed changing completely (by setting both min and max to 1.0) then this is irrelevant.

@fgl27
Copy link
Author

fgl27 commented Apr 20, 2022

Sory a little busy didn't not get that there was two speed option, will set both.

thanks

icbaker added a commit that referenced this issue Apr 26, 2022
ExoPlayer's default behaviour changed in b12918d.

Issue: #10170
#minor-release
PiperOrigin-RevId: 443611196
@dev-platong
Copy link

@fgl27

Maybe It's too late to answer this question, but I think these lines are logic of determination (In case of HLS).

    boolean disableSpeedAdjustment =
        mediaItem.liveConfiguration.minPlaybackSpeed == C.RATE_UNSET
            && mediaItem.liveConfiguration.maxPlaybackSpeed == C.RATE_UNSET
            && playlist.serverControl.holdBackUs == C.TIME_UNSET
            && playlist.serverControl.partHoldBackUs == C.TIME_UNSET;

androidx/media@b12918d#diff-5dc6db1044707e738c63d3d43bd22bf0951fc34af6dbfbd8b1798b6e42002a74R571-R575

Media Playlist has EXT-X-SERVER-CONTROL tag and its property is HOLD-BACK or PART-HOLD-BACK .

https://datatracker.ietf.org/doc/html/draft-pantos-hls-rfc8216bis#section-4.4.3.8

@icbaker
Copy link
Collaborator

icbaker commented May 18, 2022

Closing because I think the question has been answered, and I've updated the live streaming docs page to try and make this behaviour more clear (this will go live with the next library release).

@icbaker icbaker closed this as completed May 18, 2022
@fgl27
Copy link
Author

fgl27 commented May 18, 2022

Thanks all for the help!

@google google locked and limited conversation to collaborators Jul 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants