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

HEVC Decoding in Xbox Edge

Open zemlanin opened this issue 8 months ago • 6 comments

What version of Hls.js are you using?

v1.6.5

What browser (including version) are you using?

Microsoft Edge 134.0.3124.54 (Official build) (64-bit)

What OS (including version) are you using?

Xbox OS 10.0.26100.4855

Test stream

https://hlsjs.video-dev.org/demo/?src=https%3A%2F%2Fstarlight.nebula.tv%2Funauthenticated%2Fvideos%2Fcf19ef9c-f7d5-48d9-92f7-d8419fdac086%2Fvideo_upload%3Add0165d4-07f1-44fa-ad35-5a4819cdb33d%2Fall.31d3ecfd653e.m3u8&demoConfig=eyJlbmFibGVTdHJlYW1pbmciOnRydWUsImF1dG9SZWNvdmVyRXJyb3IiOnRydWUsInN0b3BPblN0YWxsIjpmYWxzZSwiZHVtcGZNUDQiOmZhbHNlLCJsZXZlbENhcHBpbmciOi0xLCJsaW1pdE1ldHJpY3MiOi0xfQ==

Configuration

{
  "debug": true,
  "enableWorker": true,
  "lowLatencyMode": true,
  "backBufferLength": 90
}

Additional player setup steps

Edge on Xbox Series S|X reports hvc1 as supported when using MediaSource.isTypeSupported, but the playback fails with DECODER_ERROR_NOT_SUPPORTED: video decoder initialization failed with DecoderStatus::Codes::kUnsupportedConfig

FWIW, VideoElement.canPlayType accurately reports that the codec isn't supported: https://lf-tk-sg.ibytedtos.com/obj/tcs-client-sg/resources/video_demo_hevc.html

Image

Checklist

  • [x] The issue observed is not already reported by searching on Github under https://github.com/video-dev/hls.js/issues
  • [x] The issue occurs in the stable client (latest release) on https://hlsjs.video-dev.org/demo and not just on my page
  • [x] The issue occurs in the latest client (main branch) on https://hlsjs-dev.video-dev.org/demo and not just on my page
  • [x] The stream has correct Access-Control-Allow-Origin headers (CORS)
  • [x] There are no network errors such as 404s in the browser console when trying to play the stream

Steps to reproduce

  1. Load https://hlsjs.video-dev.org/demo/?src=https%3A%2F%2Fstarlight.nebula.tv%2Funauthenticated%2Fvideos%2Fcf19ef9c-f7d5-48d9-92f7-d8419fdac086%2Fvideo_upload%3Add0165d4-07f1-44fa-ad35-5a4819cdb33d%2Fall.31d3ecfd653e.m3u8&demoConfig=eyJlbmFibGVTdHJlYW1pbmciOnRydWUsImF1dG9SZWNvdmVyRXJyb3IiOnRydWUsInN0b3BPblN0YWxsIjpmYWxzZSwiZHVtcGZNUDQiOmZhbHNlLCJsZXZlbENhcHBpbmciOi0xLCJsaW1pdE1ldHJpY3MiOi0xfQ== in Edge on Xbox Series S|X

Expected behaviour

HLS.js detects that HEVC can't be played and plays AVC stream

What actually happened?

HLS.js tries to decode HEVC and fails the playback

Console output

Unable to access browser console on my Xbox

Chrome media internals output


zemlanin avatar Jun 23 '25 11:06 zemlanin

Hi @zemlanin,

I'm sorry that there is a bug on Xbox Edge that is impacting your use of HLS.js.

HLS.js does not use canPlayType. There are no plans to either. I would avoid using it as it could introduce conflicts with support checks for other types on other platforms.

From my perspective, this is 100% a bug in Edge.

robwalch avatar Jul 11 '25 18:07 robwalch

If you'd like to add custom variant filtering to your integration as a workaround, you can do so by calling removeLevel for any variants you want removed on MANIFEST_PARSED:

// probably a good idea to limit this to when "Xbox" or `/Edge?/` appears in `navigator.userAgent`
hls.on(Hls.Events.MANIFEST_PARSED, (n, event) => {
  for (let i = event.levels.length; --i;) {
    if (hls.media.canPlayType(`video/mp4;codecs="${hls.levels[i].videoCodec}"`) !== 'probably') {
      hls.removeLevel(i);
    }
  }
});

robwalch avatar Jul 11 '25 19:07 robwalch

sigh…

Okay. Thank you for expanding the comment

I’ve already started using canPlayType for AVC and HEVC checks, so might come back and update this comment if/when it’ll go wrong 🫣

zemlanin avatar Jul 11 '25 19:07 zemlanin

Is it all HEVC or just certain levels and profiles, like the 8k@60 "....6.L180.90" example above?

I’ve already started using canPlayType for AVC and HEVC checks, so might come back and update this comment if/when it’ll go wrong 🫣

As in the workaround suggested or in a fork?

robwalch avatar Jul 11 '25 19:07 robwalch

Can't answer about the levels right now, will try to check/list next week

As in the workaround suggested or in a fork?

Neither?.. When initializing the player, in the app-level code, I check both canPlayType and isTypeSupported plus play a two frame test files in an in-memory <video> elements, and load an AVC-only manifest we already had

It's probably an overkill and I'm probably missing something, but it seemingly deals with Edge on Xbox (which doesn't seem to signify that it's on Xbox in the User-Agent) and with Firefox (which would happily play HEVC video with broken visuals)

zemlanin avatar Jul 11 '25 19:07 zemlanin

On Xbox Series S/X Edge, samples on https://lf-tk-sg.ibytedtos.com/obj/tcs-client-sg/resources/video_demo_hevc.html:

  • DV Profile 5, DV Profile 8.1, and every HEVC Rext Profile have all three checks falsey
  • everything else has falsey canPlayType but truthy isTypeSupported and mediaCapabilities

zemlanin avatar Jul 14 '25 08:07 zemlanin