Spaces:
Running
Running
Fix restream giât: ffmpeg relay (1 connection, real segments, rolling playlist)
#63
by bep40 - opened
Vấn đề
Kênh restream (.ts/.mp2t) giật hơn sau bản fix pump:
- Manifest tĩnh byte-offset, MEDIA-SEQUENCE không nhích → hls.js phát lại cửa sổ cũ (replay loop)
- Segment fetch rỗng (off vượt pump buffer) → stall
Giải pháp (triệt để)
Thay pump thủ công bằng ffmpeg restream relay (ffmpeg_relay.py):
- 1 kênh = 1 ffmpeg process, 1 connection upstream duy nhất
- Segment thật theo keyframe, duration thật
- Rolling playlist MEDIA-SEQUENCE tăng real-time → hls.js chạy đúng live
-reconnect 1 -reconnect_streamed 1+ watchdog restart 0.5s- Theo redirect (Stalker token) trước khi feed ffmpeg
Đo đạc A/B (hls_probe.py)
| Metric | Pump cũ | ffmpeg |
|---|---|---|
| MEDIA-SEQUENCE nhích | 0 (tĩnh) | 190 in 60s |
| Segment fetch | 1.5-1.8s + rỗng | 0.01s (local disk) |
| HTTP errors | 2/7 | 0 |
Frontend
- hls.js:
liveSyncDurationCount: 5 → 1,maxBufferLength 60 → 15(bám live edge sát hơn)
Files
main.py: proxy_m3u_hls raw branch → 302/api/restream/m3u8+ 2 endpoint restreamffmpeg_relay.py(mới)static/app_v2.js: 3 hls config sites
bep40 changed pull request status to open
bep40 changed pull request status to merged