ZLMediaKit/conf
Caner Ateş 64ae6e43c5
Some checks failed
Android / build (push) Has been cancelled
CodeQL / Analyze (cpp) (push) Has been cancelled
CodeQL / Analyze (javascript) (push) Has been cancelled
Docker / build (push) Has been cancelled
DockerPy / build (push) Has been cancelled
Linux / build (push) Has been cancelled
Linux_Python / build (push) Has been cancelled
macOS / build (push) Has been cancelled
macOS_Python / build (push) Has been cancelled
Windows / build (push) Has been cancelled
Windows_Python / build (push) Has been cancelled
支持配置 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>
2026-06-08 21:25:25 +08:00
..
config.ini 支持配置 fmp4 HLS 切片文件扩展名 (.mp4/.m4s) (#4746) 2026-06-08 21:25:25 +08:00
novideo.yuv feat: VideoStack (#3373) 2024-03-16 22:56:32 +08:00
readme_en.md add translate for config (#4678) 2026-03-15 15:10:51 +08:00
readme.md release 8.0 2023-12-09 16:23:51 +08:00

Key parameters that affect performance in the configuration file

1. Protocol enable flags (e.g., protocol.enable_hls, protocol.enable_rtsp)

Controls the protocol conversion flags. Disabling unnecessary protocols will save CPU and memory resources.

2. On-demand protocol flags (e.g., protocol.hls_demand, protocol.rtsp_demand)

Controls on-demand protocol generation. When both this and the specific protocol are enabled, it saves CPU and memory when there are no active viewers. However, the first viewer will lose the instant playback capability, impacting the initial experience.

3. protocol.paced_sender_ms

The interval for the smooth sending timer. This helps address playback stuttering caused by irregular data transmission from the source. When enabled, the timer uses data timestamps to pace the transmission, improving the viewing experience. However, this increases CPU and memory consumption. A shorter timer interval results in higher CPU usage but better smoothness. The recommended interval is between 30 and 100 milliseconds. For optimal results, use this feature in conjunction with setting protocol.modify_stamp to 2 (which suppresses timestamp jumps).

4. general.mergeWriteMS

Enables write coalescing, which reduces the number of system calls and the frequency of data sharing between threads during transmission. This significantly boosts forwarding performance but comes at the cost of increased playback latency and reduced transmission smoothness.

5. rtp_proxy.gop_cache

Enables the GOP (Group of Pictures) caching feature for the startSendRtp cascaded interface, designed to allow instant playback for cascading setups (e.g., GB28181). Note that this setting does not affect the instant playback capability of ZLMediaKit's external live streaming services. Enabling this option increases memory usage but has a minimal impact on the CPU. We recommend disabling it if you don't use the startSendRtp interface.

6. hls.fileBufSize

Tuning this parameter can improve the disk I/O performance when writing HLS streams.

7. record.fileBufSize

Tuning this parameter can improve the disk I/O performance when recording MP4 files.