-
Notifications
You must be signed in to change notification settings - Fork 6k
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
HLS playback issues using integer precision segment durations #2233
Comments
I've attached a video showing the problem using the stream passed at the e-mail [email protected] |
Note: Interestingly, seeking does appear to work up to about 20:15. |
The stream in question does not work correctly on 2.0.4. On 2.0.4 seeking does not cause the player to get stuck, but audio/video sync is completely broken if you seek to the middle of the content. It's a couple of minutes out at least. On 2.1.0 audio/video sync is corrected because we started looking at the ID3 header, as a player is supposed to do, but the knock-on effect is that the player can get stuck buffering. I think the root cause is that the segment durations listed in the audio media playlists are rounded to integer precision. The sum of the durations then drifts over time. Since it's a long piece of media, by the middle the drift very significant. This may not be a technical violation of the HLS spec, but does mean it's impossible for any player to efficiently seek in the media. The best guess for which segment to seek to for this media will result in a player requesting a segment that's multiple minutes off from the requested seek position. A player can then "guess" again based on this information, to eventually find the correct segment, however this is really quite inefficient. We do not do this in ExoPlayer currently, which I think is why the playback then gets stuck. The best solution here would be to correct the media playlists to use floating-point precision segment durations. This will resolve the issue when using ExoPlayer, and also make seeking more efficient when using any other player. Recent versions of the HLS spec say this about segment durations:
We should also think about handling this kind of media better in ExoPlayer, but it's likely to be treated as a low priority issue because the media is quite sub-optimal to start with, and we tend to focus more energy on efficiently supporting well prepared content, rather than on handling all legacy cases where the experience will be sub-optimal no matter how well we handle it. |
According to the latest definition of the HLS standard ( https://tools.ietf.org/html/draft-pantos-http-live-streaming-20#section-4.3.2.1 ):
In the version 5 of the HLS standard (https://tools.ietf.org/html/draft-pantos-http-live-streaming-11#section-3.3.2) the segment duration could use integer precision:
It seems that the integer precision segment durations are mandatory in versions lower than 3, but, valid in versions v3, v4, and v5, the more common ones. |
I'm unsure what your point is, since I didn't say they were invalid. I explicitly stated they weren't a violation of the spec. But the fact they're valid doesn't make them in any way a sensible idea, for the reasons specified above (i.e. it's impossible for any player to perform an efficient seek if the accumulated error grows significant). Note also that versions prior to V4 are not relevant to this issue, since EXT-X-MEDIA wasn't added prior to V4. |
Im sorry, my intention was not to annoy you. My point was that this problem is a very common problem. Well formed assets using the HLS 3, 4 and 5 versions with integer precision EXTINF tags will accumulate errors if they meet this specification requirement:
And, I fully agree with you. This HLS definition will lead in a suboptimal solution in every possible player implementation :( Inmho, the pity is that those standard versions was very popular some time ago, and users not consuming their own generated content, which could not control the hls versions, will find those problems easily. |
Whilst it might be common for older streams to use integer precision EXTINF durations, I doubt it's common at all for streams to use integer precision EXTINF durations and EXT-X-MEDIA tags, which is when this becomes a bigger issue for ExoPlayer. |
As an additional piece of information, it seems like streams affected by this issue violate Apple's HLS authoring specifications for Apple devices:
|
This came up in #9411. As of |
Possible fix/workaround that worked for me: I created a CustomLoadControl with the same code as DefaultLoadControl but updated shouldContinueLoading to keep loading content when the buffer size drops below half full. (see BUGFIX lines) We had ID3 metadata in our AAC files overestimating their duration which we think caused the player to overestimate the amount of content it had buffered, causing shouldContinueLoading to return false while the buffer was empty and produce an infinite STATE_BUFFERING state.
|
Description:
For some HLS streams the player goes to STATE_BUFFERING forever when seeking to a different position than 0. If we seek again to 0 position the stream starts it reproduction
This is happening in streams that needs the ID3 header to be synchronized.
Steps to reproduce at demo app:
This issue is taking place at exoplayer 2.1.0, I can't reproduce it at 2.0.4.
The device I'm using is a Samsung S6 with 6.0.1 as android version
The text was updated successfully, but these errors were encountered: