Skip to content

fix(ffmpeg): improve HLS probing for disguised streams - #10

Merged
Predidit merged 1 commit into
Predidit:mainfrom
zhn1100:test-hls
Aug 10, 2026
Merged

fix(ffmpeg): improve HLS probing for disguised streams#10
Predidit merged 1 commit into
Predidit:mainfrom
zhn1100:test-hls

Conversation

@zhn1100

@zhn1100 zhn1100 commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

说明

用于兼容一类使用非标准扩展名、且分片带有 PNG/GIF 伪装头的 HLS 视频源。

Kazumi 当前使用的 HLS patch 已经包含 PNG/GIF 分片兼容处理。本修改在现有逻辑上调整 probe 行为:

  • 直接检测 PNG/GIF signature;
  • 命中后保留原有 probe offset,并避免分片 URL 扩展名继续影响格式探测;
  • 实际分片格式仍由 FFmpeg 的通用 probe 判断;
  • 对内容符合 HLS、但扩展名/MIME 非标准的 playlist 保留较低 probe score;
  • 补充预读和回退的错误处理。

没有强制指定 MPEG-TS,也没有修改 Kazumi 原有的 HLS 广告过滤逻辑。

测试

已按照 Kazumi 当前 Linux 原生链路验证:

libmpv-linux-build → media-kit → Kazumi → flutter build linux → 最终 bundle

实际问题源可以正常播放,标准 HLS/TS、HLS/fMP4、普通 MP4 未发现回归,异常输入可以正常快速失败。

Linux workflow 的 x86_64 和 aarch64 构建均已通过。

为方便测试,已提供本次修改对应的构建产物:
https://github.com/zhn1100/libmpv-linux-build/releases/tag/20260810

release 中已包含 x86_64 / aarch64 的 libmpv 与 header,可直接用于 media-kit 侧替换测试。

Android 使用相同逻辑进行了实际播放测试,也可以正常播放;本 PR 暂时只提交 Linux 修改供确认。

复现/测试规则:Predidit/KazumiRules#189

…obe score

Refine the avbuild-derived HLS fake-image logic currently used by Kazumi
(no avbuild version bump, no FFmpeg/mpv version change):

- hls_read_header: when the first segment starts with png/gif magic,
  re-run the generic probe with (a) an offset (3 png / 10 gif) that
  breaks the image signature and (b) a NULL filename so that .webp-style
  URL extensions no longer boost image demuxer scores. The generic probe
  decides the real format from the payload (mpegts via 0x47 + 188
  alignment); the HLS layer never asserts the format. Malformed
  png/gif-looking garbage therefore fails the probe at header time
  instead of entering the mpegts demuxer / HLS reload path.
- avio_read: propagate non-EOF errors (AVERROR_EXIT/EIO) like
  av_probe_input_buffer2() instead of degrading them into a second
  probe; avio_seek(0) failures abort with the AVIO error.
- hls_probe: non-standard extension/MIME playlists that still match the
  #EXTM3U + HLS tag content checks return AVPROBE_SCORE_MAX/2 (log
  downgraded ERROR->WARNING to match the control flow).
- seg_allow_img: description updated to the new semantics (name, default
  and ABI unchanged). Kazumi ad-filter logic untouched.

Verified in the ffprobe/mpv matrix: ezdmw .webp + png-pretending
segments resolve h264+aac; standard TS/fMP4 HLS unchanged; real image
segments fail under default policy and work with seg_allow_img=1;
malformed inputs fail fast at header time even without EXT-X-ENDLIST;
extension_picky=1 test_segment checks still reject non-standard segment
extensions.
@Predidit
Predidit merged commit ca3a20e into Predidit:main Aug 10, 2026
2 checks passed
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.

2 participants