videojs / http-streaming

HLS, DASH, and future HTTP streaming protocols library for video.js
https://videojs-http-streaming.netlify.app/
Other
2.5k stars 424 forks source link

Changing codecs causes playback to stop #1546

Open daveisfera opened 1 week ago

daveisfera commented 1 week ago

Description

Safari and HLS.js will playback video when the codec switches, but Video.js shows an error.

Reduced test case

https://raw.githubusercontent.com/daveisfera/hls_switch/1e04cd07f7fc3077912418584ae3e7b495b224d6/primary_codec_up.m3u8

Steps to reproduce

  1. Load https://raw.githubusercontent.com/daveisfera/hls_switch/1e04cd07f7fc3077912418584ae3e7b495b224d6/primary_codec_up.m3u8
  2. Press play
  3. Observe error

Another example with switching from H.265 to H.264: https://raw.githubusercontent.com/daveisfera/hls_switch/1e04cd07f7fc3077912418584ae3e7b495b224d6/primary_codec_down.m3u8

NOTE: Safari won't play directly from GitHub because it loads the actual file contents, but if you serve the files in that repo from a web server, then it will show that Safari handles this without issue

Errors

VIDEOJS: ERROR: (CODE:3 MEDIA_ERR_DECODE) Playback cannot continue. No available working or supported playlists.
VIDEOJS: ERROR: (CODE:3 MEDIA_ERR_DECODE) video append of 483435b failed for segment videojs/video.js#5 in playlist 0-video_codec_up.m3u8
VIDEOJS: ERROR: (CODE:3 MEDIA_ERR_DECODE) The media playback was aborted due to a corruption problem or because the media used features your browser did not support.

What version of Video.js are you using?

8.17.4

Video.js plugins used.

N/A

What browser(s) including version(s) does this occur with?

Chrome 129.0.6668.72 and Safari 18.0

What OS(es) and version(s) does this occur with?

macOS 15.0

adrums86 commented 2 days ago

Hi @daveisfera it looks like a codec and container switch is happening without specifying all the codecs within the CODECS attribute of the EXT-X-STREAM-INF tag, without this the player doesn't know it needs to call changeType on the source buffer. See the HLS spec:

   any EXT-X-STREAM-INF tag ([Section 4.3.4.2](https://datatracker.ietf.org/doc/html/rfc8216#section-4.3.4.2)) or EXT-X-I-FRAME-STREAM-
   INF tag ([Section 4.3.4.3](https://datatracker.ietf.org/doc/html/rfc8216#section-4.3.4.3)) that references such a Group MUST have a
   CODECS attribute that lists every sample format present in any
   Rendition in the Group, or client playback failures can occur.

I think a next step would be to put both codecs in that attribute and see if that allows for a successful change.

adrums86 commented 2 days ago

Moved this to VHS as there seems to be some room for improvement on codec detection, as this media works in Safari and hls.js