Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce hls.js for m3u8 support #245

Merged
merged 2 commits into from
Feb 6, 2024
Merged

Introduce hls.js for m3u8 support #245

merged 2 commits into from
Feb 6, 2024

Conversation

4627488
Copy link
Contributor

@4627488 4627488 commented Feb 6, 2024

This PR introduces hls.js to provide support for m3u8 video.

Changes include:

  • Added hls.js library to the project.
  • Implemented usage of hls.js in src/components/video-player/index.tsx to enable m3u8 video playback, and fallback to html5 video if the browser doesn't support it or the video is not m3u8.

@trim21
Copy link
Member

trim21 commented Feb 6, 2024

有哪个字幕组是m3u8的吗?

@4627488
Copy link
Contributor Author

4627488 commented Feb 6, 2024

没有,只不过后端把视频分片之后,前端播放性能会好很多,尤其是在公网部署的时候,不然 B-Global 和 Netflix 这种4k片源会加载会非常慢。

@trim21
Copy link
Member

trim21 commented Feb 6, 2024

所以这个pr不仅仅是支持m3u8?

@4627488
Copy link
Contributor Author

4627488 commented Feb 6, 2024

我的意思是,如果后端能提供m3u8/ts格式的分片文件,比如对象存储这类云服务,那么就使用m3u8这种分片格式来加快流媒体速度,如果不能,比如nas下载的原始mp4文件,就正常地用h5 video播放mp4。

在nas上也能用ffmpeg进行切片生成m3u8索引文件,这时候如果前端能够支持m3u8就能加快点播速度。

@trim21 trim21 merged commit 084624b into BGmi:master Feb 6, 2024
1 check passed
@kahosan
Copy link
Collaborator

kahosan commented Apr 24, 2024

@4627488 这里除 hls 类型的文件不能全用 customHls 处理,比如 mp4 会在 hls.loadSource(playUrl); 这里被阻塞住,把整个文件都下载完了才往下

可以先根据文件扩展名判断下文件类型,再传给 type:

type: fileType === 'm3u8' ? 'customHls' : 'auto'

@kahosan
Copy link
Collaborator

kahosan commented Apr 28, 2024

@4627488 可以请你有空时测试一下这个 分支 吗?

@4627488
Copy link
Contributor Author

4627488 commented Apr 28, 2024

@4627488 可以请你有空时测试一下这个 分支 吗?

没有问题,这个修复很合理

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants