video.js icon indicating copy to clipboard operation
video.js copied to clipboard

m3u8 stream playback issue on Chrome (Windows and macOS)

Open turshija opened this issue 7 years ago • 23 comments

When trying to playback video stream with VideoJS in Chrome on Mac, first 6 seconds are choppy and laggy. That issue doesn't happen on Firefox or Safari, only Chrome.

Stream URL: https://spotteu01tstmedia01.streaming.mediaservices.windows.net/faa5c3f5-d198-40df-aeb8-7ccfb4edf5a2//20190228095812-af71f790-7f3d-488.ism/manifest(format=m3u8-aapl-v3)

When I paste that stream url here, its working correctly: https://videojs.github.io/videojs-contrib-hls/ But when I try to play it here, first 6 seconds are choppy: https://videojs.github.io/http-streaming/

Video example: https://d.pr/v/kFgXsI

I'm running VideoJS 7.4.1 without videojs-contrib-hls because as far as I know its already included in VideoJS 7 or I'm wrong ?

turshija avatar May 08 '19 16:05 turshija

I have an update on this. Same issue happens with dash format as well.

Steps to reproduce: visit page: https://videojs.github.io/http-streaming/ paste video url: https://spotteu01tstmedia01.streaming.mediaservices.windows.net/faa5c3f5-d198-40df-aeb8-7ccfb4edf5a2//20190228095812-af71f790-7f3d-488.ism/manifest(format=mpd-time-csf) change mime type to application/dash+xml

Any ideas?

turshija avatar May 10 '19 10:05 turshija

After giving it thorough investigation, I've managed to find the reason why this stuttering happens. I have reproduced it on Chrome on Windows as well, so this issue is not isolated to macOS only.

If preload is 'auto' or 'metadata' to be more precise (and autoplay is false), when video is loaded it loads first few frames by loading the first fragment with video=0 (timestamp). When you click play, the same fragment (with video=0) gets downloaded, and for some reason it crashes the playback on Chrome until next fragment is played (in my case video=60000000, which is equivalent to 6 seconds).

One workaround is to set preload to 'none', but then I loose ability to display first frame (poster) on videos that aren't played automatically.

Can anyone please confirm whether this is a correct behavior and can if it be fixed easily? I don't understand the codebase in order to make fix myself.

Steps to reproduce:

  1. Click here using Chrome to open videojs.github.io/http-streaming/
  2. Open dev tools with network tab
  3. Paste this url
  4. click "Load" and then play video afterwards, video=0 is loaded twice where second loading crashes the playback

Screenshot: image

turshija avatar May 13 '19 17:05 turshija

For some reason I found that this hack fixes this issue, I don't know why, and I don't know what am I breaking with it, but it works:

player.on('ready', function() {
  player.vhs = null;
});

It can be reproduced on https://videojs.github.io/http-streaming/ as well by typing player.vhs = null in console AFTER loading a video (but before clicking play).

turshija avatar May 14 '19 10:05 turshija

Huh, that's weird. I wonder if VHS isn't getting cleaned up properly during source changes and that's causing some issues.

gkatsev avatar May 14 '19 15:05 gkatsev

Interesting thing I noticed is that if you wait a bit after loading the stream, it plays back fine. It only has issues if you play back immediately.

gkatsev avatar May 14 '19 16:05 gkatsev

yeah you are right, if I wait like a minute and then click play - it plays it fine ... strange ...

turshija avatar May 14 '19 16:05 turshija

Running into the same issue on Linux with Chrome and VideoJS 7.4.1

benweidig avatar May 15 '19 12:05 benweidig

@benweidig might be totally unrelated, but are you hosting your streams on Azure as well or somewhere else ?

turshija avatar May 17 '19 14:05 turshija

@turshija no, we're hosting it on bare-metal machines from Hetzner with https://github.com/kaltura/nginx-vod-module for generating the streams.

benweidig avatar May 17 '19 14:05 benweidig

We've got a few other similar reports, we'll need to investigate.

gkatsev avatar May 17 '19 19:05 gkatsev

I am getting the same issue - for me, I get no video (or maybe one frame?) for 5-6 seconds and then playback works fine on Chrome. On IE11, I get only the first 5-6 seconds of video and then it freezes.

The 'vhs=null' fix does work for Chrome, but not IE11. I currently have this issue worked around by using a poster and preload=none, which seems to work perfectly.

My videos are being hosted in Azure Media Services, and I am using them for encoding as well.

CyberBill avatar May 18 '19 05:05 CyberBill

Just to add to this we are seeing the same issue on all our videos in Chrome and we are hosting on AWS.

preload: none

Works but not sure what impact it will have other setups like progressive streaming

samueleastdev avatar Jun 06 '19 14:06 samueleastdev

I've tested preload: none, using a high res poster image, and have experienced no add-on issues. I implemented a bunch of formats, including progressive mp4 streams, and haven't run into any users that can't stream.

BillCarlson avatar Jun 06 '19 22:06 BillCarlson

Thanks @BillCarlson

samueleastdev avatar Jun 08 '19 20:06 samueleastdev

Just to add to this we are seeing the same issue on all our videos in Chrome and we are hosting on AWS.

preload: none

Works but not sure what impact it will have other setups like progressive streaming

Thank you~

feawesome avatar Jun 10 '19 08:06 feawesome

+1 having same issue on Chrome using videojs 7.5.4.

preload=none works for the first time but if video is in the loop, we get the same issue on second run.

gitamj avatar Jun 10 '19 23:06 gitamj

I was able to fix the issue like this :

Rename <video> tag with <video-js> and initialize videojs like this : var player = videojs('my-video', { html5: { hls: { overrideNative: true } } });

Example :

 <video-js id='my-video' class='video-js' controls preload='preload' width='640' height='360' data-setup='{}'>
    <source src="master.m3u8" type="application/x-mpegURL" />
  </video-js>
var player = videojs('my-video', {
  html5: {
    hls: {
      overrideNative: true
    }
  }
});

It works for me and it fixed other issue where videos were not playing (or juste a few frames) on Android device. You can replace overrideNative: true by overrideNative: !videojs.browser.IS_SAFARI

Initialize the player like this doesn't work :

player.src({
    src: 'master.m3u8',
    type: 'application/x-mpegURL',
    overrideNative: true
});

koreus avatar Jun 16 '19 22:06 koreus

I've now had my site in production for about a month, and I've had at least 2 people who are get a similar enough issue that I believe it's related. It only happens on Macs, and definitely doesn't happen on all of them, so I haven't been able to determine any additional information. What they see is that the first 5-6 seconds of the video play, and then it freezes and won't continue. I've implemented a system to save the playback position, so hitting Refresh on the page unlocks it and it continues, but it's not an ideal situation.

BillCarlson avatar Jul 02 '19 17:07 BillCarlson

For some reason I found that this hack fixes this issue, I don't know why, and I don't know what am I breaking with it, but it works:

player.on('ready', function() {
  player.vhs = null;
});

It can be reproduced on https://videojs.github.io/http-streaming/ as well by typing player.vhs = null in console AFTER loading a video (but before clicking play).

This solution did not work for me quite well. Seek back did not work at all, but this hack helped me solved it (not that dirty).

 this.player.on("play", () => {
      if(this.player.currentTime() ===0){
        this.player.currentTime(0);
      }
    });

norbertdurcansk avatar Jul 03 '19 20:07 norbertdurcansk

A zip file of the stutter video just in case stutter-first-6-seconds.zip

brandonocasey avatar Jul 17 '19 19:07 brandonocasey