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.72k stars 2.57k forks source link

使用hls.js播放hls时,视频出现了花屏 #6515

Closed xht closed 1 month ago

xht commented 3 months ago

What version of Hls.js are you using?

v1.5.11

What browser (including version) are you using?

Microsoft Edge(125.0.2535.92)

What OS (including version) are you using?

windows10

Test stream

No response

Configuration

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

Additional player setup steps

No response

Checklist

Steps to reproduce

  1. 输入http://127.0.0.1:8000/record/Center1@1@文件1/_20240619/test/index.m3u8 2.点击Apply。
  2. 播放出来的视频是花屏
  3. 可以提供m3u8相关的视频文件,联系方式: 592294266@qq.com

Expected behaviour

能正常解决解码视频

What actually happened?

不太清楚,用ffplay播放m3u8能正常播放

Console output

317.419 | Media element detached
317.422 | Loading http://127.0.0.1:8000/record/Center1@1@文件1/_20240619/test/index.m3u8
317.424 | Loading manifest and attaching video element...
317.428 | Media element attached
317.454 | 1 quality levels found
317.455 | Manifest successfully loaded

Chrome media internals output

No response

robwalch commented 3 months ago

可以提供m3u8相关的视频文件,联系方式: 592294266@qq.com

We will not reach out via email or messaging app to follow up.

You can connect with us on Video-Dev Slack in the #hlsjs channel to share samples: https://www.video-dev.org/

xht commented 3 months ago

收到,已经发到了Video-Dev Slack

robwalch commented 3 months ago

Looks like an issue transcoding the https://github.com/video-dev/hls.js/labels/Transport%20Stream segments.

https://github.com/video-dev/hls.js/blob/v1.5.11/src/demux/tsdemuxer.ts

xht commented 3 months ago

那这个需要怎么修改喽

xht commented 3 months ago

https://github.com/video-dev/hls.js/blob/v1.5.11/src/demux/tsdemuxer.ts,这个代码的加了点日志分析,能解析出SPS PPS I P等帧

robwalch commented 3 months ago

It may be related to deficiencies found in NAL Unit overflow parsing. We had to rollback a change that introduced regressions in #6492.

xht commented 3 months ago

刚才我测试了一下其它版本,hls.js-1.4.5和hls.js-1.5.8也有该现象

xht commented 3 months ago

这个有没有方法把ts解析出的264,保存成文件不。这样可以进一步确认解析的264是不是正常

robwalch commented 3 months ago

这个有没有方法把ts解析出的264,保存成文件不。这样可以进一步确认解析的264是不是正常 Is there any way to save the 264 parsed by ts into a file? This can further confirm whether the parsed 264 is normal.

On the HLS.js demo page, check "Dump transmuxed fMP4 data", then click "Create video-fmp4" under "Playback" controls. All appended segments are concatenated into a single byte array.

xht commented 3 months ago

您好,这个问题有进展了没,我尝试修改了部分代码,按照上面的方法下载了fmp4,用vlc播放,已经不花屏了。但网页上还是花屏。

robwalch commented 1 month ago

@xht I've found the root cause to be unexpected AVC NAL Access unit delimiters between the SPS, PPS and frame units. A fix has been pushed to #6617 (test link https://bugfix-avc-nal-aud-samples.hls-js-4zn.pages.dev/demo/).

xht commented 1 month ago

意思是,SPS PPS I这之间当成一帧,只需要1个aud,是这个意思不?

xht commented 1 month ago

刚才测试了一下v1.5.14这个版本,还是花屏。 但https://bugfix-avc-nal-aud-samples.hls-js-4zn.pages.dev/demo/这个版本可以

robwalch commented 1 month ago

The fix will be released in v1.6. Version 1.5 will not get a patch with this change.

xht commented 1 month ago

I've found the root cause to be unexpected AVC NAL Access unit delimiters between the SPS, PPS and frame units 意思是,SPS PPS I这之间当成一帧,只需要1个aud,是这个意思不?

robwalch commented 1 month ago

The NAL units comprising the first frame of the asset that produces this issue (mapped using VideoSample.units.map(u => ({1: 'NDR', 5: 'IDR', 6: 'SEI', 7: 'SPS', 8: 'PPS', 9: 'AUD', 12: 'filler', })[u.type]||u.type).join(',') at a debugger break point in parsePES > pushAccessUnit after changes in #6617):

Typical first frame of TS video (SEI is not required):

Prior to #6617 the TSDemuxer would only have pushed the data in the last 'AUD,IDR' units into the tranmuxed mp4 mdat. The earlier data was not after encountering unexpected AUD NAL units.

xht commented 1 month ago

明白了,谢谢