How to Convert RTSP / RTMP / SRT to WebRTC Stream

Seamlessly relay or push your existing media streams to WebRTC for ultra-low-latency playback in any modern browser using Happytimesoft Media Server.

📌 Important note: This process is primarily a stream proxy / relay (with optional transcoding). By default, video (H.264/H.265) and audio (OPUS/G711) are forwarded without re-encoding, preserving quality while changing the transport protocol to WebRTC.

Two Proven Methods

You can achieve RTSP/RTMP/SRT to WebRTC conversion using either Stream Proxy Mode (server pulls the stream) or Push Mode (encoder pushes to server). Choose the one that fits your workflow.

Method Best For Configuration Scope
Stream Proxy Mode Pulling existing RTSP/RTMP/SRT streams (e.g., from IP cameras, encoders) and exposing them as WebRTC. mediaserver.cfg (<proxy> sections)
Push Mode Actively pushing streams from OBS, FFmpeg, or any encoder to the server; get instant WebRTC playback. Server-wide (<rtmp>, <rtsp>, <srt> listeners) + <application> name

Method 1: Stream Proxy Mode (Pull from Source)

Configure the Media Server to pull an RTSP, RTMP, or SRT stream and re-publish it as WebRTC. Edit mediaserver.cfg and add one or more <proxy> entries.

Step 1: Edit mediaserver.cfg

<proxy>
    <suffix>proxy</suffix>                      <!-- URL suffix for WebRTC -->
    <url>rtsp://192.168.3.36/live</url>         <!-- Source stream (RTSP, RTMP, or SRT) -->
    <user></user>                               <!-- Optional credentials -->
    <pass></pass>
    <transfer>TCP</transfer>                    <!-- Transport for RTSP (UDP/TCP) -->
    <ondemand>1</ondemand>                      <!-- 1: pull on first client request -->
    <output>                                    <!-- Optional transcode settings -->
        <video>
            <codec>H264</codec>                 <!-- Leave empty to passthrough -->
            <width></width>
            <height></height>
            <framerate></framerate>
            <bitrate></bitrate>
        </video>
        <audio>
            <codec>G711U</codec>                <!-- or OPUS, etc. -->
            <samplerate>8000</samplerate>
            <channels>1</channels>
            <bitrate></bitrate>
        </audio>
    </output>
</proxy>

<!-- More proxy entries can be added -->
<proxy>
    <suffix>camera2</suffix>
    <url>rtmp://192.168.3.40/live/stream</url>
    ...
</proxy>

Resulting WebRTC URL

After configuration, the stream becomes available at:

http://[serverip]:[serverport]/webrtc?streamid=[application-name]/[suffix]

Example: If HTTP server IP is 192.168.1.100, port 8080, application name live, and suffix proxy, the WebRTC address becomes:

http://192.168.1.100:8080/webrtc?streamid=live/proxy

Open this URL in a browser that supports WebRTC (Chrome, Firefox, Edge) to play the stream with <1s latency.


Method 2: Push Mode (Encoder Pushes to Server)

You can push RTSP, RTMP, or SRT streams directly to the Happytimesoft Media Server. The server automatically makes them available as WebRTC streams without additional proxy configuration.

Step 1: Push Your Stream

Use OBS, FFmpeg, RTMP Pusher, or any encoder that supports the protocol. The push URL format depends on the protocol:

Protocol Push URL format Notes
RTMP rtmp://[serverip]:[rtmp-port]/[application-name]/[stream-key] Default RTMP port: 1935
RTSP rtsp://[serverip]:[rtsp-port]/[application-name]/[stream-id] Default RTSP port: 554
SRT srt://[serverip]:[srt-port]?streamid=[application-name]/[stream-name] Default SRT port: 10080 (configurable)

Example using RTMP with OBS/FFmpeg:
rtmp://192.168.1.100:1935/live/stream1
(application-name = live, stream-key = stream1)

Step 2: WebRTC Playback URL

Once data is received, the WebRTC stream is immediately available at:

http://[serverip]:[http-port]/webrtc?streamid=[application-name]/[stream-name]

The streamid parameter must match the application and stream name used in the push URL. For the RTMP example above, the WebRTC URL becomes:

http://192.168.1.100:8080/webrtc?streamid=live/stream1
✏️ Note: The HTTP port (8080 by default) and server IP are defined in the <http> section. For RTSP/SRT pushes, the stream name after the application becomes the stream identifier.

Workflow Diagram

📹 RTSP Camera ➡️ 🔄 RTMP Encoder ➡️ 📡 SRT Source 👇 Happytimesoft Media Server 🌐 WebRTC 🖥️ Browser (Chrome, Firefox, Edge)

Source → (Pull via proxy or push) → Media Server → WebRTC → Any modern browser


Best Practices & Tips


Configuration Summary (mediaserver.cfx / .cfg)

Key sections to verify:

<application>
    <name>live</name>                       <!-- used in streamid -->
    ...
</application>

<http>
    <serverip></serverip>                   <!-- listen IP -->
    <serverport>8080</serverport>           <!-- WebRTC HTTP port -->
</http>

<rtmp>
    <serverip></serverip>
    <serverport>1935</serverport>           <!-- for RTMP push -->
</rtmp>
<!-- similar for RTSP and SRT -->
RTSP to WebRTC RTMP to WebRTC SRT to WebRTC