Skip to content

WebRTC to RTSP Bridge Tutorial

This tutorial shows how to convert WebRTC streams to RTSP so they can be used with CVEDIA-RT.

Prerequisites

  • FFmpeg with WebRTC support
  • Network access to both WebRTC source and CVEDIA-RT

Configuration

Step 1: Install FFmpeg with WebRTC Support

Ubuntu/Debian:

sudo apt update
sudo apt install ffmpeg

Windows:

Download from https://ffmpeg.org/download.html

Step 2: Create the Bridge

Convert WebRTC to RTSP:

ffmpeg -protocol_whitelist file,udp,rtp,tcp \
        -i "webrtc://your-webrtc-source-url" \
        -c copy \
        -f rtsp \
        rtsp://localhost:8554/stream

Step 3: Configure CVEDIA-RT

In your CVEDIA-RT instance configuration, set the source to: rtsp://localhost:8554/stream

Option 2: Using GStreamer (Ubuntu/Debian)

Prerequisites

  • GStreamer with webrtc plugin
  • gst-rtsp-server

Configuration

Step 1: Install GStreamer

sudo apt install gstreamer1.0-tools gstreamer1.0-plugins-good \
                 gstreamer1.0-plugins-bad gstreamer1.0-rtsp
Check WebRTC plugin availability:

gst-inspect-1.0 webrtc

Step 2: Create RTSP Server Script

Create webrtc-bridge.sh:

#!/bin/bash
gst-launch-1.0 webrtcsrc location="your-webrtc-url" ! \
               videoconvert ! \
               x264enc ! \
               rtspclientsink location=rtsp://localhost:8554/stream

Step 3: Run the Bridge

chmod +x webrtc-bridge.sh
./webrtc-bridge.sh

Step 4: Configure CVEDIA-RT

In your CVEDIA-RT instance configuration, set the source to: rtsp://localhost:8554/stream

Option 3: Node.js Bridge (For Developers)

Prerequisites

  • Node.js
  • npm packages: node-webrtc, node-rtsp-stream

Configuration

Step 1: Create Bridge Application

Create webrtc-rtsp-bridge.js:

const wrtc = require('node-webrtc');
const Stream = require('node-rtsp-stream');

// WebRTC to RTSP bridge configuration
const stream = new Stream({
    name: 'webrtc-bridge',
    streamUrl: 'your-webrtc-stream-url',
    wsPort: 9999,
    ffmpegOptions: {
        '-stats': '',
        '-r': 30,
        '-s': '1920x1080'
    }
});

console.log('WebRTC to RTSP bridge running on rtsp://localhost:8554/stream');

Step 2: Install Dependencies and Run

npm init -y
npm install node-webrtc node-rtsp-stream
node webrtc-rtsp-bridge.js

Step 3: Configure CVEDIA-RT

In your CVEDIA-RT instance configuration, set the source to: rtsp://localhost:8554/stream