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

Optimize in-buffer seeking for HLS #551

Closed
brinliu opened this issue Jun 16, 2015 · 10 comments
Closed

Optimize in-buffer seeking for HLS #551

brinliu opened this issue Jun 16, 2015 · 10 comments

Comments

@brinliu
Copy link

brinliu commented Jun 16, 2015

When playing media files, I seek to a position, the buffered data will be cleaned and buffer again from the new position seeked to.

@Arqu
Copy link

Arqu commented Jun 16, 2015

There are a couple reasons why it is currently like that, for one it is currently not implemented in that way, two if the stream variant has changed and you seek back it was not in memory in the first place and so it fails. Also when seeking the decoder has to find the first iframe before that moment so it attempts to load that chunk to find it.

However you can make seeking work more suited to your case by enabling cache support like I did therefore chunks will be cached and when requested will be more or less instantly loaded from the disk and the playback starts without a hit on the bandwidth. However I still haven't managed to select the cached variant to play until a better segment is loaded but that can be done too.

@ojw28
Copy link
Contributor

ojw28 commented Jun 16, 2015

Seeking forward into the buffer will retain the buffered data where possible in the DASH, SmoothStreaming and ExtractorSampleSource cases (the only case where it's not possible is if you're seeking less than one key-frame forward in one or more of the enabled tracks).

For HLS this optimisation is harder to pull off correctly due to additional complexity around having to splice overlapping sample queues when switching variants. This is a result of a shortcoming in the HLS specification. Hence we haven't tried to do this yet (there's a TODO in HlsSampleSource, but it's relatively low priority for us).

@brinliu
Copy link
Author

brinliu commented Jun 17, 2015

@ojw28 Thanks a lot for your reply. Though you mentioned it's low priority, I still want to know if any schedule about this. This is very important on android for the origin MediaPlayer doesn't support buffering when playing HLS.

@ojw28
Copy link
Contributor

ojw28 commented Jun 17, 2015

Why is this very important? The player can just build up a buffer by requesting the data again? Or are you talking about something different (e.g. the ability to seek in live streams)?

@brinliu
Copy link
Author

brinliu commented Jun 18, 2015

I mean that, the ExoPlayer maybe is the best player for HLS on Android. For origin MediaPlayer, we can't get the buffer progress. So the developers maybe choice the Exoplayer for playing HLS. But ,when the users want to seek to some position, the buffered data will be lost.

@ojw28 ojw28 added the question label Jun 18, 2015
@ojw28 ojw28 changed the title Buffer is cleaned when seek Optimize in-buffer seeking for HLS Aug 19, 2015
@siavashabdoli
Copy link

I still have this problem when seek backward or forward. both Dash and hls. I use demo V 1.5.2

@ojw28
Copy link
Contributor

ojw28 commented Apr 20, 2016

Note: We will be optimizing forward seeking for HLS so that it matches what we're able to do for DASH and SmoothStreaming in 2.x.

ojw28 added a commit that referenced this issue Jun 15, 2016
I think the concept of a sparse track might need formalizing
in Format at some point. We should probably do a similar thing
with sparse tracks in ExtractorSampleSource as well. WDYT?

Issue: #551
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=120530195
ojw28 added a commit that referenced this issue Jun 15, 2016
Pull more logic up to HlsSampleSource. Somewhat regretfully,
this also backs out the optimization work done toward the
ref'd issue. I think that's one for another time perhaps...

Issue: #551
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=123417413
@zhuyifan2013
Copy link

How about this issue? @ojw28

@ojw28
Copy link
Contributor

ojw28 commented Oct 13, 2016

We abandoned plans to optimize this for now. It turned out to be pretty non-trivial. If you're concerned with optimal playback behavior then you should really be using DASH rather than HLS.

ojw28 added a commit that referenced this issue Jul 15, 2017
Also move to using an array to hold the SampleQueues,
as we've moved to doing in ExtractorMediaPeriod.

Issue: #551

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

ojw28 commented Jul 15, 2017

In-buffer seeking is now optimized to the same extent as DASH.

@ojw28 ojw28 closed this as completed Jul 15, 2017
@google google locked and limited conversation to collaborators Nov 13, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants