mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-06-12 19:24:22 +08:00
支持配置 fmp4 HLS 切片文件扩展名 (.mp4/.m4s) (#4746)
## 背景 / 问题 fmp4 模式下,HLS 切片文件名被硬编码为 `.mp4`(见 `HlsMakerImp::onOpenSegment`),无法改用 fmp4 媒体段更规范、更常见的 `.m4s` 扩展名(`init` 段用 `init.mp4`、媒体段用 `.m4s` 是 CMAF/DASH 的通行约定)。 ## 改动 - 新增配置项 `hls.fmp4SegExt`,默认 `.mp4`,**完全向后兼容**;用户可设为 `.m4s`。 - `init` 段仍固定为 `init.mp4`,mpegts 切片仍为 `.ts`,相关行为不变。 - 切片文件名同时用作 m3u8 中的分片 URI,因此扩展名变更后 playlist 自动保持一致,无需额外同步。 - 在 HTTP MIME 表中注册 `.m4s` -> `video/mp4`;否则会以 `text/plain` 返回,导致 Safari 等播放器无法播放 HLS-fmp4。 - 配置值不带前导点(如 `m4s`)时自动规范化为 `.m4s`。 ## 涉及文件 `src/Common/config.h`、`src/Common/config.cpp`、`src/Record/HlsRecorder.h`、`src/Record/HlsMakerImp.h`、`src/Record/HlsMakerImp.cpp`、`src/Http/HttpConst.cpp`、`conf/config.ini` ## 测试 - **默认(未配置)**:切片仍为 `*.mp4`,`init` 为 `init.mp4`,行为与改动前一致(回归正常)。 - **`hls.fmp4SegExt=.m4s`**:切片文件为 `*_N.m4s`,m3u8 中 `#EXTINF` 的 URI 指向 `.m4s`,`#EXT-X-MAP` 仍为 `init.mp4`;HTTP 拉取切片返回 `Content-Type: video/mp4`;hls.js 与 Safari 播放正常。 - **`hls.fmp4SegExt=m4s`(无前导点)**:自动规范化,仍生成 `*.m4s`。 Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -284,6 +284,11 @@ segKeep=0
|
||||
# If set to 1, the length of the first segment is forcibly set to exactly 1 GOP.
|
||||
# When the GOP is smaller than `segDur`, this can improve the initial startup (instant playback) speed.
|
||||
fastRegister=0
|
||||
|
||||
# fmp4 HLS切片文件的扩展名,例如 .mp4 或 .m4s(fmp4媒体段的标准扩展名);init段始终为init.mp4,mpegts切片始终为.ts
|
||||
# File extension for fMP4 HLS segment files, e.g. .mp4 or .m4s (the standard extension for fMP4 media segments).
|
||||
# The init segment is always init.mp4, and mpegts segments are always .ts.
|
||||
fmp4SegExt=.mp4
|
||||
[hook]
|
||||
# 是否启用hook事件,启用后,推拉流都将进行鉴权
|
||||
# Whether to enable webhook events. When enabled, pushing and pulling streams requires authentication.
|
||||
|
||||
Reference in New Issue
Block a user