Neanderthal
Neanderthal

Reputation: 947

HLS adaptive streaming in android changes streams only after 10 secs?

I have developed a small app that can record and play small videos (upto 10 secs). The app captures video at 6 Mbps. To ensure faster video playback, I'm trying to implement HLS (http live streaming). But I have noticed that the app always picks up the stream with lowest bitrate first and only switches to the best available stream (based on network bandwidth) only after 10 secs.

I have tested different media players like android media player, exoplayer etc., but the behaviour is consistent. The video changes streams only after exactly 10 seconds. Is this the default implementation of hls in android? or Am I missing something? The m3u8 I used to test is http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8

        localUrl = "http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8";
        vidView.setVideoPath(localUrl);
        Log.i("GenericRequest", "VideoUrl " + localUrl);
        vidView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
            @Override
            public void onPrepared(MediaPlayer mp) {
             vidView.start();
            }
        });

Upvotes: 2

Views: 893

Answers (1)

Simon
Simon

Reputation: 1274

If you look at the contents of the playlists listed in bipbopall.m3u8, you'll see that the segment duration is 10 seconds. This probably explains why you are seeing the switch after 10 seconds.

The player will download the first playlist listed in bipbopall.m3u8, which in this instance is the stream with the lowest bitrate, and starts playing the first segment. It subsequently calculates that there is additional bandwidth available so switches to a stream with a higher bitrate.

If the segment duration were different, you'd likely see the switch occur at a different time.

Upvotes: 6

Related Questions