video-dev / hls.js

HLS.js is a JavaScript library that plays HLS in browsers with support for MSE.
https://hlsjs.video-dev.org/demo
Other
14.41k stars 2.55k forks source link

How to fix Hls.ErrorTypes.MEDIA_ERROR #5904

Open konogousanda opened 8 months ago

konogousanda commented 8 months ago

What do you want to do with Hls.js?

Hls.js does not request any data when gets Hls.ErrorTypes.MEDIA_ERROR, then the screen went black. The message is "Playhead still not moving while enough data buffered @37.961094 after 3 nudges". I don't kown the reason and can't find a solution. version: 1.4.6

code

image

error

{
  "type": "mediaError",
  "details": "bufferStalledError",
  "error":
    {
      "message": "Playhead still not moving while enough data buffered @37.961094 after 3 nudges",
      stack:"Error: Playhead still not moving while enough data buffered @37.961094 after 3 nudges at GapController._tryNudgeBuffer (http://localhost:3100/node_modules/.vite/deps/hls__js.js?v=ef946d71:13099:21) at GapController._tryFixBufferStall (http://localhost:3100/node_modules/.vite/deps/hls__js.js?v=ef946d71:12984:12) at GapController.poll (http://localhost:3100/node_modules/.vite/deps/hls__js.js?v=ef946d71:12962:10) at StreamController.checkBuffer (http://localhost:3100/node_modules/.vite/deps/hls__js.js?v=ef946d71:13737:21) at StreamController.onTickEnd (http://localhost:3100/node_modules/.vite/deps/hls__js.js?v=ef946d71:13249:10) at StreamController.doTick (http://localhost:3100/node_modules/.vite/deps/hls__js.js?v=ef946d71:13245:10) at StreamController.tick (http://localhost:3100/node_modules/.vite/deps/hls__js.js?v=ef946d71:6497:12) at StreamController.fragBufferedComplete (http://localhost:3100/node_modules/.vite/deps/hls__js.js?v=ef946d71:7503:10) at StreamController.onFragBuffered (http://localhost:3100/node_modules/.vite/deps/hls__js.js?v=ef946d71:13689:10) at EventEmitter2.emit (http://localhost:3100/node_modules/.vite/deps/hls__js.js?v=ef946d71:12512:29)",
    },
  "fatal": true,
}

What have you tried so far?

No response

robwalch commented 8 months ago

Please include console logs so that we can determine the reason for the stall.

Stalls generally are related to network conditions or an issue with the HLS asset. The player should recover on its own when network condition are adequate.

Calling recoverMediaError is usually not the best action to take for "bufferStalledError" events.

robwalch commented 8 months ago

Hi @konogousanda,

The message is "Playhead still not moving while enough data buffered @37.961094 after 3 nudges".

I think that you are experiencing the same problem described in #5873:

Increase nudgeMaxRetry to a large value so the player does not escalate stall nudges to fatal. This will be fixed in v1.5.0 with #5879: