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

Should hls.js be able to play corrupt streams?

Open SebastianSchoeps opened this issue 1 year ago • 3 comments

We use a Reolink Duo 3 PoE to record soccer games. To play the camera's HEVC stream hls.js is a great option with the upcoming support for this video format. However, the source seems to be corrupt from time to time and we didn't manage to get this fixed on FFmpeg recording level yet.

Should hls.js be able to ignore/manage corrupt data? E.g. the following stream has this issue after 9 seconds: Demo

After 9 seconds the player totally crashes and the player needs to be reloaded. VLC "survives" the corrupt data; reencoding with FFmpeg also creates a valid stream. It would be great if playing would just continue instead of the crash! Anything we can do here?

Thanks, Sebastian

SebastianSchoeps avatar Dec 13 '24 17:12 SebastianSchoeps

HEVC in M2TS is a community contributed feature made up of these PRs (CC @devoldemar):

  • #5847
  • #6268
  • #6724

Provide more information about the asset encoding and packaging, including any identifiable out-of-spec features. There are warnings that segments have overlapping samples, but is the issue related to that, or a specific segment?

Configuring HLS.js to only buffer "sn: 3" reproduces the issue with no warnings or error from hls.js directly. The decode error comes from the browser. Consider adding a GAP tag to that segment to skip it.

  "maxMaxBufferLength": 1,
  "startPosition": 10

robwalch avatar Dec 15 '24 16:12 robwalch

Thank you!

The segment in question (and the error) is:

% ffplay https://cdn4.taggy.cam/videos/VR94dbf0100aedd7f1a5b2da4dd138ebfba158786272636865/F5uz/video-00113.ts
[...]
[hevc @ 0x13e21b3b0] Could not find ref with POC 2sq=    0B 
[hevc @ 0x13e2644a0] Ignoring POC change between slices: 2 -> 1
    Last message repeated 1 times

Adding a gap tag in deed works and would be a good workaround! HLS.js with gap

a) it would be nicer if we don't have to check every single segment if it works (hls.js just skips segments with errors) b) shouldn't the placeholder image be shown? Currently hls.js just skips the segment.

#EXTINF:3.009844,
video-00112.ts
#EXT-X-GAP
#EXTINF:3.010133,
placeholder-reolink-duo-3.png
#EXTINF:2.939889,
video-00114.ts

SebastianSchoeps avatar Dec 15 '24 18:12 SebastianSchoeps

b) shouldn't the placeholder image be shown? Currently hls.js just skips the segment.

Initial support for #EXT-X-GAP tags was added in v1.4 which involved skipping loading of segments marked as gaps (required by the HLS spec). Patching audio/video source-buffers or trick-playing over the gaps is more involved and will have to wait for a future release (v1.7 is a good candidate as that aligns with I-FRAME segment support which has similar requirements).

Work on GAP tags:

  • #2940
    • #5257

Issue tracking this as a feature request:

  • #6518

robwalch avatar Dec 15 '24 19:12 robwalch