shaka-project / shaka-player

JavaScript player library / DASH & HLS client / MSE-EME player
Apache License 2.0
7.14k stars 1.34k forks source link

Video freezes and stops downloading when seeking using HLS manifest #3935

Closed aifeipeng closed 2 years ago

aifeipeng commented 2 years ago

Have you read the FAQ and checked for duplicate open issues? Couldn't find any duplicate at least

What link can we use to reproduce this? https://shaka-player-demo.appspot.com/demo/#audiolang=sv-SE;textlang=sv-SE;uilang=sv-SE;asset=https://atg-eu.akamaized.net/atgse/prod/2022-01-22/Lopp_2022-01-22_15_6_20220122164543_500_20220122044543534.m3u8;panel=CUSTOM%20CONTENT;build=uncompiled

What version of Shaka Player are you using? v3.3.1-uncompiled

What browser and OS are you using? Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.80 Safari/537.36

What did you do?

Seek within buffered space. Could be backwards or forwards in time. Doesn't happen exactly every time

What did you expect to happen? Should jump to correct place in time without hiccups

What actually happened? Player freezes, it also seems like it stops downloading fragments

avelad commented 2 years ago

Can you check with 4.0.0 if you reproduce the problem? I checked in 4.0.0 with the stream and I cannot reproduce the issue.

aifeipeng commented 2 years ago

Can you check with 4.0.0 if you reproduce the problem?

It doesn't freeze and stop downloading but it I get Jumping forward 5.977694 seconds because of gap starting at 66.010667 and ending at 71.989333 every third second or so

avelad commented 2 years ago

Have you checked that the stream does not have jumps with other players? Is the playback smooth?

aifeipeng commented 2 years ago

Pretty smooth with hls.js at least, example: https://hls-js.netlify.app/demo/?src=https%3A%2F%2Fatg-eu.akamaized.net%2Fatgse%2Fprod%2F2022-01-22%2FLopp_2022-01-22_15_6_20220122164543_500_20220122044543534.m3u8&demoConfig=eyJlbmFibGVTdHJlYW1pbmciOnRydWUsImF1dG9SZWNvdmVyRXJyb3IiOnRydWUsInN0b3BPblN0YWxsIjpmYWxzZSwiZHVtcGZNUDQiOmZhbHNlLCJsZXZlbENhcHBpbmciOi0xLCJsaW1pdE1ldHJpY3MiOi0xfQ==

aifeipeng commented 2 years ago

Just some information regarding this, perhaps it helps 🤷 . The stream(s) I use are working pretty well with an older version of hls.js (and of course with apples built in on safari, ios etc) but they do have some "bugs" on hls.js new version as well. I've been trying to get an answer why and I finally got this answer:

When the logs include lines like [mp4-remuxer]: Dropped X out of Y video samples due to a missing keyframe, your HLS streams MPEG-TS segments contain video samples before the first IDR frame. The samples preceding the IDR are dropped on a seek or level switch because they cannot be decoded without the IDR from an earlier segment of the same variant in the MSE buffer. This can leave a gap where media was not buffered for the current segment's range. To overcome this, HLS.js performs what we've been calling "backtracking", where the player attempts to load earlier segments to find an IDR starting point that meets with or overlaps the end of the buffer. In rare cases like this one, that fails and results in loop loading. It is a bug in HLS.js that is only produced when you have a MPEG-TS HLS stream whose video is not segmented on IDR frame boundaries.

I'm just guessing that this is why I have problem with shaka as well?

joeyparrish commented 2 years ago

Yes, it sounds like a content/decoder issue. Segments should begin with a key frame, and this is not something the player controls at the JS level. Parsing and decoding happens in the browser.