rtp2httpd Documentation

website·Indexed 31 days ago

https://rtp2httpd.com/

Documentation for rtp2httpd, a tool for converting multicast RTP streams to HTTP unicast streams. It features support for Fast Channel Change (FCC) for millisecond-level response, M3U/M3U8 playlist integration, a built-in Web player, and FFmpeg-based video snapshots. The guide covers installation on OpenWrt, configuration parameters, URL formats, and network troubleshooting for firewalls, IGMP, and Docker.

Tokens
17.4K
Snippets
86
Records
120
Agent score
58%

What's inside rtp2httpd

  1. Install rtp2httpd on OpenWrt via one-click script

    The recommended way to install or update rtp2httpd on OpenWrt is using the automated script. This script detects the CPU architecture, fetches the latest version from GitHub Releases, and installs the main program, LuCI interface, and language packs. If a previous version exists, it will be uninstalled before the new version is installed.
    uclient-fetch -q -O - https://raw.githubusercontent.com/stackia/rtp2httpd/main/scripts/install-openwrt.sh | sh
  2. Understand how FCC (Fast Channel Change) works

    Pure multicast streams can be slow to start because players must wait for the next keyframe (IDR frame) to begin decoding, which can take 1-5 seconds. FCC solves this by caching the most recent keyframes. When a channel is changed, rtp2httpd requests the keyframe from an FCC server via unicast to start playback immediately, then seamlessly switches to the multicast stream once the data synchronizes.
  3. Manually install rtp2httpd IPK packages on OpenWrt

    If the one-click script cannot be used, you can manually download the architecture-specific packages from the GitHub Releases page. Required packages include the main program (rtp2httpd_<version>_<arch>.ipk), the LuCI Web interface (luci-app-rtp2httpd_<version>_all.ipk), and the Chinese language pack (luci-i18n-rtp2httpd-zh-cn_<version>_all.ipk).
    # Identify device architecture
    cat /etc/openwrt_release | grep ARCH
    
    # Install uploaded ipk packages
    opkg install rtp2httpd_*.ipk luci-app-rtp2httpd_*.ipk luci-i18n-rtp2httpd-*.ipk
  4. Deploy rtp2httpd using static binaries

    Download the static binary matching your CPU architecture from the GitHub Releases page. The binary requires execution permissions (chmod +x). By default, it reads configuration from /etc/rtp2httpd.conf, but this can be overridden using --config or disabled with --noconfig.
    # Check architecture
    uname -m
    
    # Download and make executable
    wget https://github.com/stackia/rtp2httpd/releases/download/vX.Y.Z/rtp2httpd-X.Y.Z-x86_64
    chmod +x rtp2httpd-X.Y.Z-x86_64
    
    # Run with config file
    ./rtp2httpd-X.Y.Z-x86_64 --config /path/to/rtp2httpd.conf
    
    # Run with CLI arguments only
    ./rtp2httpd-X.Y.Z-x86_64 --noconfig --verbose 2 --listen 5140 --maxclients 20
  5. Compile rtp2httpd for OpenWrt firmware

    To include rtp2httpd in an OpenWrt build, add the repository to feeds.conf.default. You can specify the main branch or a specific version tag.
    # In feeds.conf.default
    src-git rtp2httpd https://github.com/stackia/rtp2httpd.git
    # OR for specific version
    src-git rtp2httpd https://github.com/stackia/rtp2httpd.git;v3.10.1
    # Update feeds
    ./scripts/feeds update rtp2httpd
    ./scripts/feeds install rtp2httpd
    
    # In make menuconfig: LuCI -> Applications -> luci-app-rtp2httpd
    
    # Compile specifically
    make package/feeds/rtp2httpd/luci-app-rtp2httpd/compile -j1 V=sc
  6. Build rtp2httpd from source

    Manual compilation for custom builds or development. Requires build-essential, cmake, pkg-config, curl, and Node.js LTS (for the Web UI).
    # Install dependencies (Ubuntu/Debian)
    sudo apt-get install build-essential cmake pkg-config curl
    curl -fsSL https://deb.nodesource.com/setup_24.x | sudo -E bash -
    sudo apt-get install -y nodejs
    corepack enable
    
    # Build process
    git clone https://github.com/stackia/rtp2httpd.git
    cd rtp2httpd
    
    # Build Web UI
    pnpm install --frozen-lockfile
    pnpm run web-ui:build
    
    # Compile
    cmake -B build -DCMAKE_BUILD_TYPE=Release -DENABLE_AGGRESSIVE_OPT=ON
    cmake --build build -j$(getconf _NPROCESSORS_ONLN)
    
    # Install
    sudo cmake --install build
  7. Access the M3U playlist

    Retrieve a converted M3U playlist containing all channels defined via configuration files and external M3U sources. The server converts original IPs, query parameters, and authentication info into rtp2httpd's own listening addresses and ports, effectively hiding the original source details.
    http://<server_address>:<port>/playlist.m3u
  8. rtp2httpd Data Batching and Payload Sharing

    rtp2httpd reduces per-client overhead through shared parsing and batching:

    • Batching: RTP parsing and reordering are performed once per shared source. Payloads are merged into 64 KiB batches (approx. 49 packets of 1316 bytes). Batches are sent when full or after a 100ms timeout.
    • Batch Pool: A dedicated 64 KiB batch pool is managed by the worker, starting with 4 batches (expanding by 4). The maximum capacity is derived from buffer-pool-max-size * 1536 bytes.
    • Payload Views: Multiple clients share the same underlying payload using buffer_ref_t views. Each view tracks its own send offset and remaining length. The underlying memory is returned to the pool only after the last view is released.
    • Slow Client Protection: Queue limits are charged based on the underlying buffer capacity. A batch occupying 64 KiB continues to count toward the limit until the client releases the reference, preventing slow clients from bypassing memory limits via shared buffers.
  9. Install the Web Player as a PWA

    The Web Player supports Progressive Web App (PWA) functionality, allowing it to be installed on various devices for a full-screen, app-like experience. Local settings like themes are preserved after installation.

    iOS / iPadOS (Safari)

    1. Open player page $\rightarrow$ Share $\rightarrow$ Add to Home Screen.

    Android (Chrome, Edge)

    1. Open player page $\rightarrow$ Menu (⋮) $\rightarrow$ Add to Home Screen / Install App.

    Desktop (Chrome, Edge)

    1. Open player page $\rightarrow$ Install icon in address bar OR Menu $\rightarrow$ Save and Share $\rightarrow$ Create Shortcut.

    LG TV (webOS)

    1. Open Web Browser $\rightarrow$ Enter player URL $\rightarrow$ Browser Menu $\rightarrow$ Add shortcut to the Home screen.
  10. Find FCC server addresses

    To use FCC, you must first identify the FCC server associated with your multicast source. There are two primary methods:

    1. Query known lists: Check the regional FCC address collection documentation.
    2. Packet capture from STB: Use Wireshark on an IPTV set-top box (STB) to find ChannelFCCIP and ChannelFCCPort fields in channel list requests, or use the Wireshark FCC protocol plugin to identify FCC protocol packets.
  11. Configure logrotate for rtp2httpd

    Because rtp2httpd workers keep access log files open, you must send a SIGHUP signal to the supervisor process to trigger a log reopen after rotation. This requires the pid-file to be configured.
    # 1. Enable PID file in config
    [global]
    pid-file = /var/run/rtp2httpd.pid
    # 2. logrotate configuration example
    /var/log/rtp2httpd/access.log {
        daily
        rotate 7
        missingok
        notifempty
        compress
        create 0644 root root
        sharedscripts
        postrotate
            [ ! -s /var/run/rtp2httpd.pid ] || kill -HUP "$(cat /var/run/rtp2httpd.pid)" 2>/dev/null || true
        endscript
    }
  12. Manage rtp2httpd configuration at runtime

    rtp2httpd supports hot-reloading of configuration without restarting the entire process. Signals must be sent to the supervisor process (the main PID).

    • SIGHUP: Reloads the configuration file. If [bind] addresses or workers count change, the supervisor will restart worker processes to apply changes. Other changes are forwarded to workers.
    • SIGUSR1: Terminates and restarts all worker processes. This interrupts active client connections.
    # Hot-reload configuration (SIGHUP)
    kill -HUP <supervisor_pid>
    
    # Restart all worker processes (SIGUSR1)
    kill -USR1 <supervisor_pid>