videojs / videojs-contrib-hls

HLS library for video.js
http://videojs.github.io/videojs-contrib-hls/
Other
2.84k stars 793 forks source link

Updating from 0.17.2 to 0.17.3 causes issues with live playback #337

Closed ntadej closed 9 years ago

ntadej commented 9 years ago

Updating from 0.17.2 to 0.17.3 causes issues with live playback. Sometimes (can not determine in which situations) playback does not start. The picture remains black, but playlists and chunks seem to be downloaded properly in the background. There are no errors in console.

Llorx commented 9 years ago

This is happening to me too.

Also, I noticed this only with autoplay enabled. Without autoplay it loads a few ts files, shows them and then hangs without loading any more files. (With autoplay I mean adding player.play() to the code)

And one more thing. I disabled condition that starts in line 912 in videojs-hls.js (if (typeof offset === 'number') {) because it was returning this error on startup: Uncaught TypeError: Cannot read property 'pts' of undefined. This was the line while (tags[i].pts < ptsTime) { around line number 915.

ntadej commented 9 years ago

I use autoplay in player configuration (so I don't have to call play command after initialising player).

I don't have any problems with line 912.

Llorx commented 9 years ago

I've modified it a bit and seems to work:

ptsTime = offset - segmentOffset + tags[0].pts;
while (tags[i] && tags[i].pts < ptsTime) {
  i++;
}
while (!tags[i] && i > 0) {
    i--;
}
// tell the SWF where we will be seeking to

But now I have the problem that it don't plays in Android, but I think that is something with my stream, because also with another player don't works (don't remember it).

MarcusOhman91 commented 9 years ago

Android 5.0 introduced an issue where you cannot play hls livestreams if the URL contain any underscores (native issue), might be why its not working for you.

Llorx commented 9 years ago

Not using android 5.0, but good to know because my streams have underscores.

Thank you!

dmlap commented 9 years ago

@Llorx I believe the issue you are seeing is fixed by https://github.com/videojs/videojs-contrib-hls/pull/279 which we're testing to pull in right now. On the Android front, contrib-hls falls back to native playback on any platform that has native HLS support. The issue you're seeing is a problem with Android's built-in HLS support and not something we can fix in this project at this time.

@ntadej any chance you were able to narrow down why this was occurring? Sometimes you can get issues like this to reproduce by capturing the segments that were being requested at the time of the failure and creating a fake VOD stream from them.

Llorx commented 9 years ago

@dmlap I see. Thank you for your reply.

So I'm going to add Flowplayer fallback with Andoird then. Thank you for your work here!

Llorx commented 9 years ago

@dmlap Now I thought. Can you push an option to force your playback instead of using the native one? So I can try contrib-hls in Android, because Android one seems glitchy. Also, if your option fails for wahtever reason, then fallback to native one (just in case some devices can run it).

Thank you.

dmlap commented 9 years ago

@Llorx Flowplayer falls back to native the HLS implementation on Android too so I don't think adding it will change the situation much. Unfortunately, there aren't many good options to improve HLS on Android until Google fixes it. contrib-hls and Flowplayer use Flash to play HLS on devices that don't have any native support but Flash isn't an option on mobile. You could swap to MP4s on Android as long as you don't have to do any actual live streaming.

Llorx commented 9 years ago

@dmlap I said that because Flowplayer works on Android. Don't know exactly why but it works. Tried contrib-hls and another player that I don't remember (medialement I think) and both gave exactly the same result on Android until I checked Flowplayer. I have to say that on Android Flowplayer shows its own player and not the default one that "comes" with Android like the other two players.

I thought that contrib-hls was pure Javascript without Flash fallback. The bad thing is that my site is about live events and I cannot add a direct mp4 video. I can use HLS and RTMP links (that act like direct mp4 video) but I can't find any Javascript player that switches between RTMP links with different bitrate hls-adaptive-like when detect bandwith problems.

If you want to check, I can leave my computer on with a loop stream and I can give you a link with both players, contrib-hls and Flowplayer, so you can check the differences. I checked the mobile console with the PC when tried it and returned no errors so If all players fall to the same thing, I don't get a clue on what's happening.

ntadej commented 9 years ago

This seems to be fixed with combination of latest stable video.js and videojs-hls.