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

Fix adaptive switching for live playbacks close to the live edge #3017

Closed
DavidMihola opened this issue Jul 3, 2017 · 9 comments
Closed
Assignees
Labels

Comments

@DavidMihola
Copy link

Problem description

This is mainly a question about ExoPlayer's behavior and maybe a request for best practices in handling this case:

In our app we have both "normal" live streams (Live stream with limited availability) and what we are calling "startover streams", which enable you to watch the current program from the beginning (Live stream with indefinite availability). All are streamed with HLS version 3.
Now, with live streams, we are experiencing the following problem:

  • The chunk size on our streaming server was recently reduced to 4 seconds
  • ExoPlayer by default starts playback 3 chunks from the end of the the live window
  • ExoPlayer by default needs a buffer of 10 seconds before switching up at all
  • As a consequence, in more than half the trials, ExoPlayer is starting playback too close to the live edge. It is then never able to reach a buffer size of 10 seconds and will therefore never switch up.

We are fixing this now by explicitly setting an initial seek position to seconds 90 of the 120 second live window.

For the startover streams, however, since we want to allow seeking within the whole available portion of the stream we need to make sure we are not getting too close to the live edge - or else the above problem would arise again. Hardcoding a margin of 30 (or maybe 20 or 15) seconds at the end of the stream - i. e. allow seeking only up to player.getDuration() - 30_000 - would probably work but doesn't seem ideal given that it actually depends on things like chunk size, etc.

Is there a better way to determine the maximum allowed seek position in streams that are still growing at the end?

Version of ExoPlayer being used

2.4.2

Device(s) and version(s) of Android being used

FireTV - multiple hardware versions

@ojw28
Copy link
Contributor

ojw28 commented Jul 3, 2017

It's probably fair to say AdaptiveTrackSelection just isn't well suited for this use case at the moment. It was written for on-demand use cases, and we didn't update it when we started supporting live.

In the short term: It's possible for you to pass your own TrackSelection.Factory through the DefaultTrackSelector interface, that could instantiate AdaptiveTrackSelection instances with the constants set differently so as to allow up-switching in this case. You could also implement your own TrackSelection entirely with different logic that's better suited for this use case, and instantiate instances of that in the factory.

In the longer term: @tonihei - Probably something to look at as we try and come up with better ABR logic!

@ojw28 ojw28 changed the title Can't switch up if getting too close to end of live window Improve adaptive switching for live playbacks close to the live edge Jul 3, 2017
@DavidMihola
Copy link
Author

Thank you very much for your reply!

For now, I think were just going to limit the seek position explicitly - but we might also keep playing with the parameters and see how that works out...

@james12695
Copy link

@tonihei Is there any updates for this enhancement ?

I got the same switching up failed issue for my LIVE HLS with 3s segment
using AdaptiveTrackSelection due to insufficient bufferedDurationUs.
Thanks

@ojw28 ojw28 added bug and removed enhancement labels Aug 31, 2017
@ojw28 ojw28 changed the title Improve adaptive switching for live playbacks close to the live edge Fix adaptive switching for live playbacks close to the live edge Aug 31, 2017
@ojw28
Copy link
Contributor

ojw28 commented Aug 31, 2017

@james12695 - Agree this should be classed as a bug rather than an enhancement. Reclassifying accordingly, and we'll take a look over the next week or two. It's possible for you to work around this issue in application code in the meantime (see my "In the short term" further up this post). Thanks!

@ojw28 ojw28 assigned botaydotcom and unassigned tonihei Aug 31, 2017
@james12695
Copy link

james12695 commented Sep 1, 2017

Thank you for your kind help 😃

ojw28 pushed a commit that referenced this issue Sep 15, 2017
In live streaming, if the playback position is very close to live edge,
the buffered duration will never reach minDurationForQualityIncreaseMs,
which prevents switching from ever happening. So we will provide the
durationToLiveEdgeUs to AdaptiveTrackSelection in live streaming case,
so it can handle this edge case.

GitHub: #3017

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=168535969
@ojw28
Copy link
Contributor

ojw28 commented Sep 18, 2017

We've pushed a change to dev-v2 that should resolve this issue. There's a lot of room for further improvement, but playbacks should now adapt up even if close to the live edge. If you could verify the fix, that would be great.

@ojw28 ojw28 closed this as completed Sep 18, 2017
@DavidMihola
Copy link
Author

Unfortunately, I am currently unable to even reproduce the original undesired behavior (we had, in the meantime, used seekTo to start at 30 seconds before the live edge).

I still get 4 second chunks but for some reason I now always get over 10 seconds of buffer very quickly and the quality is switched up accordingly where it previously stayed low. I suspect there were some subtle changes in the streaming configuration...

In any case, I am afraid I don't have a setup where I could compare the old ExoPlayer behaviour with the one on dev-v2. Sorry!

ojw28 pushed a commit that referenced this issue Sep 19, 2017
In live streaming, if the playback position is very close to live edge,
the buffered duration will never reach minDurationForQualityIncreaseMs,
which prevents switching from ever happening. So we will provide the
durationToLiveEdgeUs to AdaptiveTrackSelection in live streaming case,
so it can handle this edge case.

GitHub: #3017

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=168535969
@ojw28 ojw28 reopened this Sep 19, 2017
@ojw28
Copy link
Contributor

ojw28 commented Sep 19, 2017

I think we need to tweak this a little more to get it working just right.

@ojw28
Copy link
Contributor

ojw28 commented Sep 26, 2017

Further tweaked in 324339b.

@ojw28 ojw28 closed this as completed Sep 26, 2017
@google google locked and limited conversation to collaborators Jan 25, 2018
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

5 participants