Skip to content

SRS v6 Docker Cluster - WebRTC Fails While FLV/HLS Work #4425

@Faradkho

Description

@Faradkho

I am setting up an SRS origin-edge cluster using Docker. I want to publish a single RTMP stream to the origin and play it back on the proxy using HTTP-FLV, HLS, and WebRTC. My motivation is that when I stream several camera with WebRTC through my AWS server, the second camera experiences latency. From my understanding, SRS works on a single thread that might create issues. Thus, I decided to use multi-containers system (Please let me know if there are better ways to do!). For now I am just trying two containers:

  1. origin that receive the stream
  2. proxy that pull the stream from origin and stream on an html page

I was able to:

  • Setup a single-container setup works perfectly for all protocols (FLV, HLS, and WebRTC).
  • Create a multi-container setup, HTTP-FLV and HLS playback works correctly, which proves the stream is being pulled from the origin to the proxy.

My problem:
WebRTC playback is the only thing that fails. The browser makes a successful connection to the proxy (logs show connection established), but no video ever appears. The proxy log shows it connects to the origin to pull the stream, but the connection then times out or fails with a video parsing error (avc demux annexb : not annexb).

My docker-compose.yml:

version: '3.8'
networks:
  srs-net:
    driver: bridge
services:
  srs-origin:
    image: ossrs/srs:6
    container_name: srs-origin
    networks: [srs-net]
    ports: ["1936:1935"]
    expose:
      - "1935"
    volumes: ["./origin.conf:/usr/local/srs/conf/srs.conf:ro"]
    command: ["./objs/srs", "-c", "conf/srs.conf"]
    restart: unless-stopped      
  srs-proxy:
    image: ossrs/srs:6
    container_name: srs-proxy
    networks: ["srs-net"]
    ports:
      - "1935:1935"
      - "1985:1985"
      - "8000:8000/udp"
      - "8080:8080"
    depends_on:
      - srs-origin
    volumes: 
      - "./proxy.conf:/usr/local/srs/conf/srs.conf:ro"
      - "./html:/usr/local/srs/html"
    command: ["./objs/srs", "-c", "conf/srs.conf"]
    restart: unless-stopped

origin.conf:

listen 1935;
daemon off;
srs_log_tank console;
srs_log_level trace;

vhost __defaultVhost__ {
}

proxy.conf:

listen              1935;
max_connections     1000;
daemon              off;
srs_log_tank        console;
srs_log_level       trace;

http_server {
    enabled         on;
    listen          8080;
    dir             ./html;
    crossdomain     on;
}

http_api {
    enabled         on;
    listen          1985;
    crossdomain     on;
}

rtc_server {
    enabled         on;
    listen          8000;
    candidate      xxx.xxx.xxx.xxx; # IP address
}

vhost __defaultVhost__ {
    enabled         on;

    # Enable cluster mode to pull from the origin server
    cluster {
        mode            remote;
        origin          srs-origin:1935;
    }

    # Low latency settings
    play {
        gop_cache       off;
        queue_length    1;
        mw_latency      50;
    }

    # WebRTC configuration (Not working)
    rtc {
        enabled         on;
        rtmp_to_rtc     on;
        rtc_to_rtmp     off;
        
        # Important for SRS v6
        bframe          discard;
        keep_bframe     off;
    }

    # HTTP-FLV (working)
    http_remux {
        enabled     on;
        mount       /[app]/[stream].flv;
    }
    
    # HLS (working)
    hls {
        enabled         on;
        hls_path        ./html;
        hls_fragment    3;
        hls_window      9;
    }
}

I do not understand why it is so difficult to make it work... Please help me.

Metadata

Metadata

Assignees

No one assigned

    Labels

    EnglishNativeThis issue is conveyed exclusively in English.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions