Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
150 changes: 150 additions & 0 deletions README.en.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
# <img src="./icon.svg" width="24" height="24"> rtp2httpd - IPTV Streaming Relay Server

Language: [中文](README.md) | [English](README.en.md)

rtp2httpd is a multimedia stream relay server. This project is a complete rewrite of [oskar456/rtp2httpd](https://github.com/oskar456/rtp2httpd), adding many new features and tailored for Mainland China IPTV environments.

rtp2httpd converts multicast RTP/UDP and RTSP streams to HTTP unicast, and implements carrier-grade FCC ([Fast Channel Change](https://blog.csdn.net/yangzex/article/details/131328837)) for near-instant channel switching. It can act as a seamless replacement for `udpxy` and `msd_lite`, delivering an experience close to native set-top boxes.

## ✨ Core Features

### 📡 Multi-Protocol Support

- **RTP->HTTP**: Convert multicast RTP/UDP streams to standard HTTP streams
- **RTSP->HTTP**: Convert RTSP to HTTP video streams with a full RTSP/RTP stack and UDP NAT traversal (STUN)
- Enables catchup playback for IPTV RTSP time-shift sources
- **HTTP->HTTP**: Full reverse proxy to relay IPTV intranet HLS sources to LAN/WAN
- **UDPxy Compatibility**: Fully compatible with UDPxy URL formats
- **M3U Playlist Integration**: Supports M3U/M3U8 with automatic URL detection and conversion
- Supports external M3U URLs
- Smart detection for RTP/RTSP URLs and conversion to HTTP proxy format
- Automatic handling of catchup-source time-shift URLs
- Access the converted playlist via `http://<server:port>/playlist.m3u`
- **Loss/Jitter Resilience**: Out-of-order recovery and FEC forward error correction
- Reorders out-of-order RTP packets to reduce artifacts caused by jitter
- Reed-Solomon FEC redundancy for mild packet loss (requires upstream multicast FEC)
- **Channel Snapshots**: Fetch channel snapshots via HTTP to reduce decoder load on clients

### ⚡ FCC Fast Channel Change

- **Carrier FCC Protocol Support**: Works with carrier FCC servers for millisecond-level channel switching
- **Fast Decode**: FCC ensures IDR frames are delivered quickly for instant playback

### 📊 Real-Time Status Monitoring

- **Web Status Page**: Visit `http://<server:port>/status` for live server stats
- **Client Connection Stats**: IP, state, bandwidth usage, and transfer volumes per connection
- **Live Logs**: Real-time log view with dynamic log level control
- **Remote Management**: Force disconnect clients from the web UI

### 🎬 Built-in Player

- **Browser Playback**: Modern embedded web player with responsive desktop/mobile UI
- **Fast Startup**: Works with FCC for fast start and fast channel switching
- **Time-Shift & Catchup**: Supports EPG and catchup playback (requires RTSP catchup source)
- **Zero Overhead**: Pure web frontend, no decoding/transcoding load on rtp2httpd

### 🚀 Performance Optimizations

- **Non-blocking IO**: epoll-based event model for high concurrency
- **Multi-core Scaling**: Multiple worker processes to utilize multi-core CPUs
- **Buffer Pooling**: Pre-allocated pools, dynamic sharing across clients to avoid slow-client stalls
- **Zero-copy**: Supports Linux MSG_ZEROCOPY to avoid user/kernel copies
- **Lightweight**: Pure C with minimal dependencies, runs well on embedded devices
- Binary size is about 340KB (x86_64) with all web assets embedded
- See the **[Performance Benchmark](docs/en/benchmark.md)** (vs msd_lite, udpxy, tvgate)

## 📹 Demos

### Fast Channel Change + Catchup

https://github.com/user-attachments/assets/a8c9c60f-ebc3-49a8-b374-f579f8e34d92

> **Tip**: Fast channel change works best with IPTV-optimized players such as [mytv-android](https://github.com/mytv-android/mytv-android) / [TiviMate](https://tivimate.com) / [Cloud Stream](https://apps.apple.com/us/app/cloud-stream-iptv-player/id1138002135). The demo uses TiviMate.
> General players like PotPlayer / IINA are not optimized for fast start, so FCC benefits are limited.

### Built-in Player

https://github.com/user-attachments/assets/d676b8c1-7017-48a1-814c-caab0054b361

> Configure an M3U playlist and open `http://<server:port>/player` in a browser.
> Browser decoding limits apply (Chrome cannot play AC3 audio for Beijing TV 4K, iOS cannot play MP2 audio for HD/SD channels).

### Real-Time Status Monitoring

<img width="2586" height="1814" alt="Image" src="https://github.com/user-attachments/assets/8838ee26-aa97-4d31-8031-afe8998a7fba" />

### 25 x 1080p Multicast Streams Playing Simultaneously

https://github.com/user-attachments/assets/fedc0c28-f9ac-4675-9b19-a8efdd062506

> Single stream bitrate: 8 Mbps. Total CPU usage is 25% of a single core (i3-N305) with 4MB memory usage.

## 🚀 Quick Start

### One-Command OpenWrt Install/Update

```bash
uclient-fetch -q -O - https://raw.githubusercontent.com/stackia/rtp2httpd/main/scripts/install-openwrt.sh | sh
```

After installation, find "rtp2httpd" under the "Services" menu in the LuCI admin UI to configure it.

If LuCI behaves oddly after an update, **Ctrl+F5 refresh** or **clear browser cache** or **use incognito mode**.

If the LuCI entry does not appear after install, your LuCI version may be too old to support JS-based LuCI apps. Consider updating your firmware. Alternatively, edit `/etc/config/rtp2httpd` manually (set `disabled` to 0) and restart via `/etc/init.d/rtp2httpd restart`.

> Some community members have also developed a Lua version of luci-app-rtp2httpd
>
> - <https://www.right.com.cn/forum/thread-8461513-1-1.html>
> - <https://github.com/jarod360/rtp2httpd/releases>

### Other Platforms

rtp2httpd supports multiple deployment options:

- **Static binary**: Runs on any Linux system
- **Docker container**: Containerized deployment
- **Build from source**: Compile from source, or include as an OpenWrt feed

See the [Installation Guide](docs/en/installation.md).

## 📖 Documentation

- **[Quick Start](docs/en/quick-start.md)**: OpenWrt quick configuration
- **[Installation](docs/en/installation.md)**: Installation options
- **[URL Formats](docs/en/url-formats.md)**: Supported URL formats and protocols
- **[M3U Integration](docs/en/m3u-integration.md)**: M3U configuration and usage
- **[Configuration Reference](docs/en/configuration.md)**: Full configuration options
- **[FCC Setup](docs/en/fcc-setup.md)**: Enable millisecond-level fast channel change
- **[Video Snapshots](docs/en/video-snapshot.md)**: Channel preview configuration

If you are new to IPTV multicast relay services and related network topics (DHCP auth, routing, multicast, firewalls), these guides are also helpful:

- [Zhejiang Hangzhou Telecom IPTV Intranet Integration Guide](https://baiyun.me/zhejiang-hangzhou-telecom-iptv)
- [Auto-fetch IPTV unicast addresses for time-shift playback](https://www.bandwh.com/net/2571.html)
- [K2P OpenWrt IPTV full guide with rtp2httpd](https://www.right.com.cn/forum/thread-8457970-1-1.html)
- [Chongqing Telecom IPTV rtp2httpd capture guide](https://www.right.com.cn/forum/thread-8457356-1-1.html)
- [Zhejiang Telecom IPTV multicast to unicast, rtp2httpd](https://www.right.com.cn/forum/thread-8452510-1-1.html)
- [Rtp2httpd on Cool 9 Zhejiang Telecom IPTV](https://www.right.com.cn/forum/thread-8453715-1-1.html)
- [Hunan Telecom OpenWrt IPTV end-to-end guide](https://mp.weixin.qq.com/s/_hEVbrgHll_qIePXGtATTw)
- [📺 Bypass Router IPTV Plugin Guide](https://www.bilibili.com/video/BV1ioiKBNE8t/)
- [📺 Multicast to unicast series part 2](https://www.bilibili.com/video/BV1Zhr4B3ELy/)

## 📄 License

This project is released under the GNU General Public License v2.0. This means:

- ✅ You can deploy in commercial environments (e.g., internal enterprise use)
- ✅ You can offer paid IPTV relay services based on it
- ✅ You can use it in paid IPTV consulting services
- ✅ You can sell hardware devices that include this software
- ⚠️ If you modify the code, you must publish the modified source code
- ⚠️ If you distribute binaries, you must also provide the source code
- ⚠️ You cannot close-source it and sell it

## 🙏 Acknowledgements

- The developers of the original project [oskar456/rtp2httpd](https://github.com/oskar456/rtp2httpd)
- Professionals who shared FCC protocol details publicly
- All users who tested and provided feedback
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# <img src="./icon.svg" width="24" height="24"> rtp2httpd - IPTV 流媒体转发服务器

Language: [中文](README.md) | [English](README.en.md)

rtp2httpd 是一个多媒体流转发服务器。本项目基于 [oskar456/rtp2httpd](https://github.com/oskar456/rtp2httpd) 做了完全重写,在原项目基础上加入了许多新功能,专为中国大陆 IPTV 环境设计。

rtp2httpd 支持将组播 RTP/UDP 流、RTSP 流转换为 HTTP 单播流,并实现了运营商级的 FCC([Fast Channel Change](https://blog.csdn.net/yangzex/article/details/131328837))快速换台协议,可以作为 `udpxy` 和 `msd_lite` 的无缝替代,为 IPTV 用户提供接近原生机顶盒的观看体验。
Expand Down
2 changes: 2 additions & 0 deletions docs/benchmark.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# 性能测试报告

Language: [中文](benchmark.md) | [English](en/benchmark.md)

**rtp2httpd**、**[msd_lite](https://github.com/rozhuk-im/msd_lite)**、**[udpxy](https://github.com/pcherenkov/udpxy)** 和 **[tvgate](https://github.com/qist/tvgate)** 四款组播转单播程序性能对比。

## 测试环境
Expand Down
2 changes: 2 additions & 0 deletions docs/cn-fcc-collection.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# 各地区 FCC 服务器收集

Language: [中文](cn-fcc-collection.md) | [English](en/cn-fcc-collection.md)

以下是从互联网收集的各地区 FCC 服务器,不保证可用,如有不可用请到 <https://github.com/stackia/rtp2httpd/issues/5> 讨论反馈。

1. 如果没有列出本城市 IP,可以尝试临近城市或省会的 IP。
Expand Down
2 changes: 2 additions & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# 配置参数详解

Language: [中文](configuration.md) | [English](en/configuration.md)

rtp2httpd 支持通过命令行参数和配置文件两种方式进行配置。

## 命令行参数
Expand Down
103 changes: 103 additions & 0 deletions docs/en/benchmark.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# Performance Benchmark Report

Language: [中文](../benchmark.md) | [English](benchmark.md)

Performance comparison of four multicast-to-unicast programs: **rtp2httpd**, **[msd_lite](https://github.com/rozhuk-im/msd_lite)**, **[udpxy](https://github.com/pcherenkov/udpxy)**, and **[tvgate](https://github.com/qist/tvgate)**.

## Test Environment

- **Platform**: Ubuntu 24.04 on Apple M3 Max (Parallels Desktop VM)
- **Architecture**: aarch64 (all programs are native arm64 builds)
- **Kernel**: Linux 6.8.0-90-generic
- **Duration per test**: 10 seconds
- **Measurement method**:
- CPU: sampled with `top -b -n 2`
- Memory: USS (Unique Set Size) read from `/proc/[pid]/smaps_rollup`
- If a process forks, CPU and memory are summed across parent and children
- **Versions**:
- rtp2httpd: v3.8.3
- msd_lite: commit 79a6c62 (2025-05-02)
- udpxy: commit 56fc563 (2026-01-26)
- tvgate: v2.1.8

## Test Scenarios

| Test | Description |
| ---------------- | -------------------------------------------------------------------------- |
| **Multi-stream** | 8 clients, each requesting a different multicast address, ~40 Mbps per stream (4K IPTV bitrate) |
| **Single-stream**| 8 clients, all requesting the same multicast address, ~40 Mbps per stream |
| **High-bandwidth** | 1 client, ~400 Mbps per stream |

## Summary Results

### CPU Usage (%)

| Scenario | rtp2httpd | msd_lite | udpxy | tvgate |
| --------------------- | ------------- | -------- | ------- | ------- |
| Multi-stream (8 unique addresses) | 🏆 **17.00%** | 25.80% | 106.00% | 331.00% |
| Single-stream (8 same address) | 🏆 **14.00%** | 14.20% | 85.00% | 51.45% |
| High-bandwidth (400 Mbps) | 🏆 **26.73%** | 39.50% | 30.85% | 89.53% |

### Memory Usage (MB)

| Scenario | rtp2httpd | msd_lite | udpxy | tvgate |
| --------------------- | ----------- | ----------- | ----- | ------ |
| Multi-stream (8 unique addresses) | 🏆 **4.50** | 10.25 | 12.53 | 182.00 |
| Single-stream (8 same address) | 4.88 | 🏆 **2.62** | 12.53 | 33.25 |
| High-bandwidth (400 Mbps) | 3.88 | 🏆 **2.62** | 3.21 | 47.38 |

## Detailed Results

### Test 1: Multi-stream (8 clients, different addresses, ~40 Mbps)

Each client requests a different multicast address (239.81.0.1-8), testing the server's ability to handle multiple independent streams.

| Metric | rtp2httpd | msd_lite | udpxy | tvgate |
| -------- | -------------- | -------- | -------- | --------- |
| CPU Avg | 🏆 **17.00%** | 25.80% | 106.00% | 331.00% |
| CPU Peak | 🏆 **18.00%** | 30.00% | 116.00% | 332.00% |
| Memory Avg | 🏆 **4.50 MB** | 10.25 MB | 12.53 MB | 182.00 MB |

### Test 2: Single-stream (8 clients, same address, ~40 Mbps)

All 8 clients request the same multicast address, testing multicast reuse efficiency.

| Metric | rtp2httpd | msd_lite | udpxy | tvgate |
| -------- | ------------- | -------------- | -------- | -------- |
| CPU Avg | 🏆 **14.00%** | 14.20% | 85.00% | 51.45% |
| CPU Peak | 18.00% | 🏆 **15.00%** | 108.00% | 52.90% |
| Memory Avg | 4.88 MB | 🏆 **2.62 MB** | 12.53 MB | 33.25 MB |

### Test 3: High-bandwidth (1 client, ~400 Mbps)

Single client receives a high-bandwidth stream (50x playback ≈ 400 Mbps).

| Metric | rtp2httpd | msd_lite | udpxy | tvgate |
| -------- | ------------- | -------------- | ------- | -------- |
| CPU Avg | 🏆 **26.73%** | 39.50% | 30.85% | 89.53% |
| CPU Peak | 🏆 **29.40%** | 40.00% | 46.00% | 96.00% |
| Memory Avg | 3.88 MB | 🏆 **2.62 MB** | 3.21 MB | 47.38 MB |

## Conclusions

**rtp2httpd** shows excellent overall performance:

- **Best CPU efficiency**: Lowest CPU usage in all three scenarios. In multi-stream, only 66% of msd_lite, 16% of udpxy, and 5% of tvgate.
- **Strong multi-stream handling**: With 8 independent 4K multicast streams, both CPU and memory are the lowest, ideal for multi-channel IPTV gateways.
- **Stable at high bandwidth**: Only ~27% CPU at 400 Mbps, leaving ample headroom.
- **Reasonable memory usage**: ~4 MB with default settings, stable across scenarios and suitable for embedded devices.

Compared to udpxy's fork-per-client model, rtp2httpd uses a more efficient event-driven architecture, offering clear advantages under high concurrency. Compared to msd_lite, rtp2httpd is more CPU-efficient, especially in multi-stream scenarios.

## Running the Benchmark

See [tools/README.md](../../tools/README.md) for tools and methodology.

Quick run:

```bash
cd tools
./benchmark.sh
```

Results are saved to `benchmark_results_YYYYMMDD_HHMMSS.txt`.
Loading