fix(ffmpeg): improve HLS probing for disguised streams - #10
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
说明
用于兼容一类使用非标准扩展名、且分片带有 PNG/GIF 伪装头的 HLS 视频源。
Kazumi 当前使用的 HLS patch 已经包含 PNG/GIF 分片兼容处理。本修改在现有逻辑上调整 probe 行为:
没有强制指定 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