google / ExoPlayer

This project is deprecated and stale. The latest ExoPlayer code is available in https://github.com/androidx/media
https://developer.android.com/media/media3/exoplayer
Apache License 2.0
21.71k stars 6.02k forks source link

Google Exoplayer : HLS Redundant stream is not working #9047

Closed SUNYTYAGI closed 3 years ago

SUNYTYAGI commented 3 years ago

Hi Team, I am using Google demo application(https://exoplayer.dev/demo-application.html) to test HLS redundant stream. It is not working as expected(playback failed)

image HLS Redundant Docs: https://bitmovin.com/docs/player/faqs/how-can-i-utilize-the-cdn-fallback-feature-of-the-player

Sample Index manifest: https://raw.githubusercontent.com/SUNYTYAGI/files/master/MobileTesting/index_protectionKeyFailedOneBitRate_withCDN_withFallback.m3u8

IS Google demo application is using old version of exo player? If yes could you please tell me from which version of exo-player started support of HLS redundant stream?

SUNYTYAGI commented 3 years ago

@christosts @claincly , I can see exo player version is 2.14.0 in demo application which seems to be latest. Now question is, does exoplayer support HLS redundant variants stream?

I can confirm, chrome extension and akamai player supports HLS redundant variants stream and working fine for above sample index manifest:

Chrome extension: chrome-extension://emnphkkblegpebimobpbekeedfgemhof/player.html#https://raw.githubusercontent.com/SUNYTYAGI/files/master/MobileTesting/index_protectionKeyFailedOneBitRate_withCDN_withFallback.m3u8

Akamai Player: http://players.akamai.com/players/hlsjs?streamUrl=https%3A%2F%2Fraw.githubusercontent.com%2FSUNYTYAGI%2Ffiles%2Fmaster%2FMobileTesting%2Findex_protectionKeyFailedOneBitRate_withCDN_withFallback.m3u8

image

SUNYTYAGI commented 3 years ago

@christosts @claincly Requesting update on this.

christosts commented 3 years ago

ExoPlayer does not do anything specific to support failover, but it might work indirectly for specific cases:

https://github.com/google/ExoPlayer/blob/92e05bcd6608b48cc4d20974f55e6a9136274c33/library/core/src/main/java/com/google/android/exoplayer2/upstream/DefaultLoadErrorHandlingPolicy.java#L72-L85

So, this might work with ExoPlayer as long as the failed HTTP server returns one of the above errors. At the moment I am writing this, the example playlist always fails with 401 and it does not trigger the behavior I described. Also, the example playlist has two variants that point to the exact same URLs for each segment, and the 401 is returned by the segments, so nothing can be played at the moment. It does not work for the Akamai Player either. I believe if you want to test this, you will need to copy the segments to different servers.

To support this use-case further, you'd probably need to customize the player. For example, if you want to handle HTTP 401 responses, you'd need to pass custom LoadErrorHandlingPolicy, for example

LoadErrorHandlingPolicy loadErrorHandlingPolicy = ... // custom policy ;
      player =
          new SimpleExoPlayer.Builder(/* context= */ this)
              .setMediaSourceFactory(new DefaultMediaSourceFactory(this).setLoadErrorHandlingPolicy(loadErrorHandlingPolicy))
              .build();

I am closing this issue, feel free to re-open if you need further information.

SUNYTYAGI commented 3 years ago

Hi @christosts , I have updated sample manifest file. I can confirm this sample is working fine in AV Player, Akamai Player & Chrome extension but playback is failing in exoplayer.

Sample Index Manifest: https://raw.githubusercontent.com/SUNYTYAGI/files/master/MobileTesting/Mux/index_redundant_stream.m3u8

Akamai Player(Working Link) : http://players.akamai.com/players/hlsjs?streamUrl=https%3A%2F%2Fraw.githubusercontent.com%2FSUNYTYAGI%2Ffiles%2Fmaster%2FMobileTesting%2FMux%2Findex_redundant_stream.m3u8

Chrome Extension (Working Link): chrome-extension://emnphkkblegpebimobpbekeedfgemhof/player.html#https://raw.githubusercontent.com/SUNYTYAGI/files/master/MobileTesting/Mux/index_redundant_stream.m3u8

Please let me know if additional details are required from my end.

Exoplayer Failed: image

ojw28 commented 3 years ago

@christosts @claincly Requesting update on this.

As an aside, please don't ping issues like this. All it does is spam a large number of people. It's particularly unreasonable to ping an issue when you only filed it ~24 hours earlier, and when most of the time that elapsed in-between was during the weekend.

SUNYTYAGI commented 3 years ago

@christosts @ojw28 Could you please update on this ?

christosts commented 3 years ago

@SUNYTYAGI, I have tested with your Sample Index Manifest and this will not work with ExoPlayer because the assumptions I described in my previous comment do not hold. At the moment of writing this comment:

Also, the 2nd variant returns an HTTP 403, so even if the player switched to this variant, it wouldn't be able to play the content.

christosts commented 3 years ago

To further assist, you may be able to customize ExoPlayer to handle this case: you can pass a custom LoadErrorHandlingPolicy to the player so that in method getBlacklistDurationMsFor() you return DEFAULT_TRACK_BLACKLIST_MS for all kinds of error, not only the HTTP errors considered by default.

For example, you may subclass DefaultLoadErrorHandlingPolicy and override its method getBlacklistDurationMsFor(). Here's an example snippet

LoadErrorHandlingPolicy loadErrorHandlingPolicy = new DefaultLoadErrorHandlingPolicy(){
  @Override
  public long getBlacklistDurationMsFor(LoadErrorInfo loadErrorInfo) {
    return DEFAULT_TRACK_BLACKLIST_MS;
  }
 };
DefaultMediaSourceFactory mediaSourceFactory = 
  new DefaultMediaSourceFactory(context).setLoadErrorHandlingPolicy(loadErrorHandlingPolicy);
SimpleExoPlayer player = new SimpleExoPlayer.Builder(context).setMediaSourceFactory(mediaSourceFactory).build()

I tested with your stream and the player attempts to download segments from the first track and then from the second. At the moment, the stream you have provided is not serving content, so I was only able to verify the player attempts to download segments from both tracks.