Home Blog

aws – SRS v6 Docker Cluster – WebRTC Fails Whereas FLV/HLS Work


I’m organising an SRS origin-edge cluster utilizing Docker. I need to publish a single RTMP stream to the origin and play it again on the proxy utilizing HTTP-FLV, HLS, and WebRTC. My motivation is that once I stream a number of cameras with WebRTC via my AWS server, the second digicam experiences latency. From my understanding, SRS works on a single thread which may create points. Thus, I made a decision to make use of multi-containers system (Please let me know if there are higher methods to do!). For now, I’m simply attempting two containers:

  1. origin that receives the stream
  2. proxy that pulls the stream from origin and stream on an html web page

I used to be capable of:

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

My drawback:

WebRTC playback is the one factor that fails. The browser makes a profitable connection to the proxy (logs present connection established), however no video ever seems. The proxy log exhibits it connects to the origin to tug the stream, however the connection then instances out or fails with a video parsing error (avc demux annexb : not annexb).

My docker-compose.yml:

model: '3.8'
networks:
  srs-net:
    driver: bridge
companies:
  srs-origin:
    picture: 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:
    picture: 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/native/srs/conf/srs.conf:ro"
      - "./html:/usr/native/srs/html"
    command: ["./objs/srs", "-c", "conf/srs.conf"]
    restart: unless-stopped

origin.conf:

hear 1935;
daemon off;
srs_log_tank console;
srs_log_level hint;

vhost __defaultVhost__ {
}

proxy.conf:

hear              1935;
max_connections     1000;
daemon              off;
srs_log_tank        console;
srs_log_level       hint;

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

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

rtc_server {
    enabled         on;
    hear          8000;
    candidate      xxx.xxx.xxx.xxx; # IP tackle
}

vhost __defaultVhost__ {
    enabled         on;

    # Allow cluster mode to tug from the origin server
    cluster {
        mode            distant;
        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;
        
        # Essential 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;
    }
}

The ffmpeg pipe I exploit in my python code from my host machine to push video frames to my AWS server:

IP_ADDRESS      = ip_address
        RTMP_SERVER_URL = f"rtmp://{IP_ADDRESS}:1936/reside/Camera_0"
        BITRATE_KBPS    = bitrate # Goal bitrate for the output stream (2 Mbps)
        # Threading and queue for body processing
        ffmpeg_cmd = [
            'ffmpeg',
            '-y',
            '-f', 'rawvideo',
            '-vcodec', 'rawvideo',
            '-pix_fmt', 'bgr24',
            '-s', f'{self.frame_width}x{self.frame_height}',
            '-r', str(self.camera_fps),
            '-i', '-',

            # Add audio source (silent audio if no mic)
            '-f', 'lavfi',
            '-i', 'anullsrc=channel_layout=stereo:sample_rate=44100',

            # Video encoding
            '-c:v', 'libx264',
            '-preset', 'ultrafast',
            '-tune', 'zerolatency',
            '-pix_fmt', 'yuv420p',
            # Keyframe interval: 1 second. Consider 0.5s if still high, but increases bitrate.
            '-g', str(2*self.camera_fps), 
            # Force no B-frames (zerolatency should handle this, but explicit is sometimes better)
            '-bf', '0', 
            '-profile:v', 'baseline',   # Necessary for apple devices 

            # Specific libx264 options for latency (often implied by zerolatency, but can be explicit)
            # Add options to explicitly disable features not in Baseline profile,
            # ensuring maximum compatibility and avoiding implicit enabling by preset.
            '-x264-params', 'cabac=0:ref=1:nal-hrd=cbr:force-cfr=1:no-mbtree=1:slice-max-size=1500', 
            # Force keyframes only if input allows (might not be practical for camera input)
            '-keyint_min', str(self.camera_fps), # Ensure minimum distance is also 1 second
            
            # Rate control and buffering for low latency
            '-b:v', f'{BITRATE_KBPS}k',         # Your target bitrate (e.g., 1000k)
            '-maxrate', f'{BITRATE_KBPS * 1.2}k', # Slightly higher maxrate than bitrate
            '-bufsize', f'{BITRATE_KBPS * 1.5}k', # Buffer size related to maxrate
            
            '-f', 'flv',
            RTMP_SERVER_URL
        ]

self.ffmpeg_process = subprocess.Popen(ffmpeg_cmd, stdin=subprocess.PIPE, stdout=subprocess.DEVNULL, stderr=subprocess.PIPE, bufsize=10**5)

ios – Why doesn’t calling serialQueue.sync() end in a impasse?


Whereas finding out DispatchQueue, I got here throughout one thing I don’t fairly perceive.

I created a customized serial queue and executed a synchronous block on it. After I printed the thread that was working the block, it turned out to be the principle thread. This confused me, as a result of the queue wasn’t the principle queue, but the block nonetheless executed on the principle thread.

let serialQueue = DispatchQueue(label: "serial.queue")

serialQueue.sync {
    print("present thread = (Thread.present)") // present thread = _NSMainThread
}

Within the documentation for sync(), I discovered the next assertion:

As a efficiency optimization, this perform executes blocks on the
present thread at any time when attainable, with one exception: Blocks submitted
to the principle dispatch queue all the time run on the principle thread.

Primarily based on this description, I assumed that if the block was certainly executed on the present thread (the principle thread on this case), then a impasse ought to have occurred.

Right here’s the reasoning I had:

  1. The primary thread calls serialQueue.sync(). As a result of it’s synchronous, the principle thread turns into blocked till the block completes.
  2. The block is submitted to the serial queue, which then makes an attempt to execute it on the principle thread (the present thread).
  3. Nevertheless, because the essential thread is already blocked, it wouldn’t be capable to course of the duty, which ought to trigger a impasse.

However opposite to my expectation, no impasse occurred and the code executed simply high-quality. I can’t work out why.

Query.

  1. Why is a block executed on the principle thread though it was submitted to a customized serial queue?
  2. If, because the documentation suggests, sync() executes on the present thread as an optimization, why doesn’t this result in a impasse on this case?
  3. Can the principle thread nonetheless execute different duties whereas it’s blocked? I want to perceive how precisely the principle thread operates.

Chemists rethink plastic recycling – NanoApps Medical – Official web site


What if recycling plastics have been so simple as flicking a change? At TU/e, Assistant Professor Fabian Eisenreich is making that imaginative and prescient a actuality by utilizing LED gentle to each create and break down a brand new class of high-performance plastics. This revolutionary materials allows really round recycling, as this course of might be repeated time and again, with none loss in high quality.

This analysis, revealed within the Rising Stars version of Superior Supplies, marks a breakthrough in  and will reshape how we deal with plastic waste sooner or later.

“In actual fact, we’re molecular designers,” is how Eisenreich describes himself and his fellow scientists from the Polymer Efficiency Supplies analysis group. Of their labs on the Division of Chemical Engineering and Chemistry, that’s what the main target is on.

“Our line of analysis facilities on ‘design for recycling.’ We create new polymers to allow revolutionary recycling methods for plastics. On the identical time, we use natural (bio-based) supplies, keep away from poisonous substances, and reduce waste to maintain all the course of as sustainable as attainable.”

High quality of polymer chains deteriorates

These polymers are developed to allow chemical closed-loop recycling, the last word aim of the analysis group. “Plastics usually include moldable polymer chains. Because of the present method by which plastics are normally recycled—in a nutshell: heating, melting, and reshaping—the standard of these polymer chains deteriorates over time. So you’ll be able to’t hold doing that indefinitely, which signifies that new plastic will ultimately must be made anyway.”

Chemical closed-loop recycling is subsequently the perfect various, in response to Eisenreich. “With the proper chemical response, a polymer chain might be selectively damaged down into its authentic constructing blocks. These can then be reused to make precisely the identical polymer once more, with similar properties and high quality.” Attaining this requires polymers designed to endure that exact response—therefore the main target of the Polymer Efficiency Supplies group’s analysis.

Selectively splitting a polymer with gentle

Inside that context, Eisenreich specifies his personal analysis on photochemical recycling, powered by LED gentle. “Making polymers by the use of gentle is comparatively easy. However breaking and making them once more in the identical method, aka recycling, is far more difficult and subsequently a complete new line of analysis. The problem lies in utilizing gentle to selectively break up steady chemical bonds throughout the polymer, so the unique constructing blocks might be recovered.”

Lately, Eisenreich and Ahsen Sare Yalin, a third-year Ph.D. candidate in his group, turned the primary to efficiently pull off this trick in his lab.

Reshape the best way we cope with plastic waste

“We see it as a breakthrough in sustainable chemistry that may reshape the best way we cope with plastic waste sooner or later,” says Eisenreich. “In the intervening time, our designer polymer continues to be a distinct segment materials and subsequently not appropriate for on a regular basis plastic purposes. As an alternative, it’s geared toward specialised makes use of, for instance, as a recyclable adhesive that binds strongly to glass and different plastics.”

In the end, additional improvement ought to broaden the appliance prospects. Furthermore, Eisenreich sees loads of potential in closed-loop recycling expertise with gentle. “I additionally work on 3D printing recyclable polymers utilizing gentle, which is a really fascinating course of. You begin with a liquid materials that takes on a stable type as quickly as gentle falls on it. You should utilize this course of to print advanced 3D objects.”

His aim is to at some point notice photochemical recycling of conventional plastics with solely daylight. “Then you definitely don’t want another vitality supply, how cool would that be?” Eisenreich’s chemical breakthrough is subsequently not solely shining new gentle on plastic recycling, but in addition on his whole discipline. “This isn’t only a new materials. It’s a brand new method ahead.”

Extra info: Ahsen Sare Yalin et al, A Mild‐Pushed Closed‐Loop Chemical Recycling System for Polypinacols, Superior Supplies (2025). DOI: 10.1002/adma.202506733

policing – Juniper MX and never working policer with NAT service


I’ve a Juniper MX wherte I have to do a community translation and bandwidth policing in the identical time. I’ve tried each approaches – direct policing of a logical interface and a policer inside a firewall filter and in each circumstances output policing would not occur (netspeed take a look at on a bunch in vlan 207 reveals incoming pace of 500 Mbits/sec, add reveals 80 Mbit/secs):

direct policing:

[show interfaces ge-1/0/0 unit 207]
vlan-id 207;
household inet {
    filter {
        output deny-rfc1918-and-allow-some;
    }
    policer {
        enter 80m-30.6m-discard;
        output 80m-30.6m-discard;
    }
    service {
        enter {
            service-set nat-lan;
        }
        output {
            service-set nat-lan-portforward service-filter nat-lan-filter;
            service-set nat-lan;
        }
    }
    tackle 172.16.25.9/29;
}
[show firewall policer 80m-30.6m-discard]
logical-interface-policer;
if-exceeding {
    bandwidth-limit 80m;
    burst-size-limit 30720000;
}
then discard;

policing inside a firewall filter:

[show interfaces ge-1/0/0 unit 207]
vlan-id 207;
household inet {
    filter {
        output deny-rfc1918-and-allow-some-shape-to-80m;
    }
    policer {
        enter 80m-30.6m-discard;
    }
    service {
        enter {
            service-set nat-lan;
        }
        output {
            service-set nat-lan-portforward service-filter nat-lan-filter;
            service-set nat-lan;
        }
    }
    tackle 172.16.25.9/29;
}
[show firewall filter deny-rfc1918-and-allow-some-shape-to-80m]
time period allow-some-and-shape-to-80m {
    from {
        source-address {
            172.16.20.0/23;
            172.16.25.8/29;
        }
    }
    then settle for;
}
time period deny-rfc1918 {
    filter deny-rfc1918;
}
time period accept-the-rest {
    then {
        policer 80m-30.6m-discard-specific;
        settle for;
    }
}
[show firewall policer 80m-30.6m-discard-specific]
filter-specific;
if-exceeding {
    bandwidth-limit 80m;
    burst-size-limit 30720000;
}
then discard;

I suppose that is occurring due to existance of the service-set on the identical logical interface. Is there any approach to make this work ? Might this be a JunOS bug (sadly, this unit has to possibility of aquiring a help contract from Juniper Networks) ?

This unit is working the next JunOS model:

run present system software program
Info for jbase:

Remark:
JUNOS Base OS Software program Suite [21.2R3-S5.4]

Info for jcrypto:

Remark:
JUNOS Crypto Software program Suite [21.2R3-S5.4]

Info for jcrypto-dp-support:

Remark:
JUNOS DP Crypto Software program Software program Suite [21.2R3-S5.4]

Info for jdocs:

Remark:
JUNOS On-line Documentation [21.2R3-S5.4]

Info for jkernel:

Remark:
JUNOS Kernel Software program Suite [21.2R3-S5.4]

Info for jmacsec:

Remark:
JUNOS Macsec Software program Suite [21.2R3-S5.4]

Info for jpfe:

Remark:
JUNOS Packet Forwarding Engine Help (MX80) [21.2R3-S5.4]

Info for jroute:

Remark:
JUNOS Routing Software program Suite [21.2R3-S5.4]

Info for jsd:

Remark:
JUNOS jsd [powerpc-21.2R3-S5.4-jet-1]

Info for jsdn-powerpc:

Remark:
JUNOS SDN Software program Suite [21.2R3-S5.4]

Info for jservices-alg:

Remark:
JUNOS Companies Utility Stage Gateways [21.2R3-S5.4]

Info for jservices-cos:

Remark:
JUNOS Companies COS [21.2R3-S5.4]

Info for jservices-cpcd:

Remark:
JUNOS Companies Captive Portal and Content material Supply Container bundle [21.2R3-S5.4]

Info for jservices-crypto-base:

Remark:
JUNOS Companies Crypto [21.2R3-S5.4]

Info for jservices-ipsec:

Remark:
JUNOS Companies IPSec [21.2R3-S5.4]

Info for jservices-jflow:

Remark:
JUNOS Companies Jflow Container bundle [21.2R3-S5.4]

Info for jservices-nat:

Remark:
JUNOS Companies NAT [21.2R3-S5.4]

Info for jservices-rpm:

Remark:
JUNOS Companies RPM [21.2R3-S5.4]

Info for jservices-rtcom:

Remark:
JUNOS Companies RTCOM [21.2R3-S5.4]

Info for jservices-sfw:

Remark:
JUNOS Companies Stateful Firewall [21.2R3-S5.4]

Info for jservices-softwire:

Remark:
JUNOS Companies SOFTWIRE [21.2R3-S5.4]

Info for jservices-ssl:

Remark:
JUNOS Companies SSL [21.2R3-S5.4]

Info for jservices-tcp-log:

Remark:
JUNOS Companies TCP-LOG [21.2R3-S5.4]

Info for junos:

Remark:
JUNOS Base OS boot [21.2R3-S5.4]

Info for py-base-powerpc:

Remark:
JUNOS py-base-powerpc [21.2R3-S5.4]

Info for py-extensions-powerpc:

Remark:
JUNOS py-extensions-powerpc [21.2R3-S5.4]

dnat – Juniper MX and vacation spot/portforwarding NAT


I am struggling to get portforwarding engaged on a Juniper MX:

[show interfaces ge-1/0/0 unit 13]
description "CCTV and Entry Management";
vlan-id 13;
household inet {
    filter {
        output cctv-and-access-control;
    }
    service {
        enter {
            service-set nat-lan;
        }
        output {
            service-set nat-lan-portforward service-filter nat-lan-filter;
            service-set nat-lan;
        }
    }
    handle 172.16.20.1/24 {
        major;
    }
    handle 172.16.21.1/24;
}
[show services service-set nat-lan-portforward]
nat-rules sk7-port-forwarding;
interface-service {
    service-interface ms-0/2/0;
}
[show services nat]
pool prospects {
    address-range low 91.196.137.4 excessive 91.196.137.6;
    port {
        automated;
    }
}
pool sk7 {
    handle 91.196.137.254/32;
    port {
        automated;
    }
}
pool infrastructure {
    handle 91.196.137.253/32;
    port {
        automated;
    }
}
pool sk7-portforwarded {
    handle 91.196.137.252/32;
}
rule default {
    match-direction enter;
    time period no-nat {
        from {
            destination-address {
                10.0.0.0/8;
                172.16.0.0/12;
                192.168.0.0/16;
            }
        }
        then {
            no-translation;
        }
    }
    time period prospects {
        from {
            source-address {
                10.20.100.0/22;
            }
        }
        then {
            translated {
                source-pool prospects;
                translation-type {
                    napt-44;
                }
            }
        }
    }
    time period infrastructure {
        from {
            source-address {
                10.10.10.0/24;
                10.10.12.0/24;
                10.10.16.0/21;
            }
        }
        then {
            translated {
                source-pool infrastructure;
                translation-type {
                    napt-44;
                }
            }
        }
    }
    time period sk7 {
        from {
            source-address {
                172.16.25.8/29;
            }
        }
        then {
            translated {
                source-pool sk7;
                translation-type {
                    napt-44;
                }
            }
        }
    }
}
rule sk7-port-forwarding {
    match-direction output;
    time period default {
        from {
            destination-address {
                91.196.137.252/32;
            }
            destination-port {
                vary low 7000 excessive 7000;
            }
        }
        then {
            translated {
                destination-prefix 172.16.21.3/32;
                translation-type {
                    dnat-44;
                }
            }
        }
    }
}
[show firewall]
household inet {
    service-filter nat-lan-filter {
        time period skip-translation {
            from {
                source-address {
                    10.0.0.0/8;
                    172.16.0.0/12;
                    192.168.0.0/16;
                }
            }
            then skip;
        }
        time period default {
            then service;
        }
    }
}

pnat does work, so the hosts have entry to the Web, however portforwarding of tcp/7000 doesn’t:

[from MX itself]
emz@perm-mx5# run telnet 172.16.21.3 port 7000
Attempting 172.16.21.3...
Linked to 172.16.21.3.
Escape character is '^]'.
�^]
telnet> Connection closed.
[edit]

[from a host in WAN]
$ telnet 91.196.137.252 7000
Attempting 91.196.137.252...
telnet: Unable to connect with distant host: Connection timed out

This unit is operating the next JunOS model:

run present system software program
Info for jbase:

Remark:
JUNOS Base OS Software program Suite [21.2R3-S5.4]

Info for jcrypto:

Remark:
JUNOS Crypto Software program Suite [21.2R3-S5.4]

Info for jcrypto-dp-support:

Remark:
JUNOS DP Crypto Software program Software program Suite [21.2R3-S5.4]

Info for jdocs:

Remark:
JUNOS On-line Documentation [21.2R3-S5.4]

Info for jkernel:

Remark:
JUNOS Kernel Software program Suite [21.2R3-S5.4]

Info for jmacsec:

Remark:
JUNOS Macsec Software program Suite [21.2R3-S5.4]

Info for jpfe:

Remark:
JUNOS Packet Forwarding Engine Assist (MX80) [21.2R3-S5.4]

Info for jroute:

Remark:
JUNOS Routing Software program Suite [21.2R3-S5.4]

Info for jsd:

Remark:
JUNOS jsd [powerpc-21.2R3-S5.4-jet-1]

Info for jsdn-powerpc:

Remark:
JUNOS SDN Software program Suite [21.2R3-S5.4]

Info for jservices-alg:

Remark:
JUNOS Providers Software Degree Gateways [21.2R3-S5.4]

Info for jservices-cos:

Remark:
JUNOS Providers COS [21.2R3-S5.4]

Info for jservices-cpcd:

Remark:
JUNOS Providers Captive Portal and Content material Supply Container bundle [21.2R3-S5.4]

Info for jservices-crypto-base:

Remark:
JUNOS Providers Crypto [21.2R3-S5.4]

Info for jservices-ipsec:

Remark:
JUNOS Providers IPSec [21.2R3-S5.4]

Info for jservices-jflow:

Remark:
JUNOS Providers Jflow Container bundle [21.2R3-S5.4]

Info for jservices-nat:

Remark:
JUNOS Providers NAT [21.2R3-S5.4]

Info for jservices-rpm:

Remark:
JUNOS Providers RPM [21.2R3-S5.4]

Info for jservices-rtcom:

Remark:
JUNOS Providers RTCOM [21.2R3-S5.4]

Info for jservices-sfw:

Remark:
JUNOS Providers Stateful Firewall [21.2R3-S5.4]

Info for jservices-softwire:

Remark:
JUNOS Providers SOFTWIRE [21.2R3-S5.4]

Info for jservices-ssl:

Remark:
JUNOS Providers SSL [21.2R3-S5.4]

Info for jservices-tcp-log:

Remark:
JUNOS Providers TCP-LOG [21.2R3-S5.4]

Info for junos:

Remark:
JUNOS Base OS boot [21.2R3-S5.4]

Info for py-base-powerpc:

Remark:
JUNOS py-base-powerpc [21.2R3-S5.4]

Info for py-extensions-powerpc:

Remark:
JUNOS py-extensions-powerpc [21.2R3-S5.4]