janus-webrtc-gateway-docker

适用于媒体流专家用户的完美 Docker 映像。「Perfect Docker Image for Media Streaming Expert User ( https://github.com/meetecho/janus-gateway )」

Github stars Tracking Chart

介绍

这是 Janus Webrtc Gateway 的 Docker 映像。 Janus Gateway 仍处于积极的开发阶段。 因此,如官方文档所述,中间件库版本的一些较小修改经常发生。 我会尽我所能应对这种麻烦。 如果您需要有关此回购的任何请求,请随时与我联系。 关于此Docker映像的设置详细信息,您应该仔细阅读官方文档https://janus.conf.meetecho.com/index.html

Janus WebRTC 网关性能

使用最新的 libnice,janus 网关似乎表现出色。 此存储库包含此补丁(请参阅https://gitlab.freedesktop.org/libnice/libnice/mer...https://webrtchacks.com/sfu-load-testing/load-test

[wip] Janus WebRTC 网关与 Jitsi Video Bridge(个人观点)

我认为 janus 对于网络研讨会(网络研讨会)更好,而 jitsi 对于网络会议系统更好。 当前的 Jitsi Video Bridge(20181007)的可伸缩性很差,因为没有本地录制文件(我不确定..)。

https://www.youtube.com/watch?v=OHHoqKCjJ0E Jitsi last-n + VP8 同播对网络会议 https://jitsi.org/wp-content/uploads/2016/12/nossd... 具有很好的性能。 pdf 对于视频格式,janus 录制是按视频流进行的,jitsi 是使用 chrome headlesss + ffmpeg(alsa,libxcb)进行的混合视频会议。 从这些方面来看,janus 适合举办网络研讨会,jitsi 适合举办网络会议。 当然,两个 WebRTC SFU 都很棒! 我同时使用。

[wip] 用于准备 WebRTC SFU 开发的网络基准测试

使用 iperf, netperf

Janus ./configure

libsrtp version:           2.x
SSL/crypto library:        BoringSSL
DTLS set-timeout:          yes
Mutex implementation:      GMutex (native futex on Linux)
DataChannels support:      yes
Recordings post-processor: yes
TURN REST API client:      yes
Doxygen documentation:     no
Transports:
    REST (HTTP/HTTPS):     yes
    WebSockets:            yes
    RabbitMQ:              no
    MQTT:                  no
    Unix Sockets:          no
    Nanomsg:               no
Plugins:
    Echo Test:             yes
    Streaming:             yes
    Video Call:            yes
    SIP Gateway (Sofia):   yes
    SIP Gateway (libre):   no
    NoSIP (RTP Bridge):    yes
    Audio Bridge:          yes
    Video Room:            yes
    Voice Mail:            yes
    Record&Play:           yes
    Text Room:             yes
    Lua Interpreter:       no
    Duktape Interpreter:   no
Event handlers:
    Sample event handler:  no
    RabbitMQ event handler:no
    MQTT event handler:    no
JavaScript modules:        no

RTMP -> RTP -> WEBRTC

IP=0.0.0.0
PORT=8888
/root/bin/ffmpeg -y -i  "rtmp://$IP:80/rtmp_relay/$1  live=1"  -c:v libx264 -profile:v main -s 640x480  -an -preset ultrafast  -tune zerolatency -f rtp  rtp://$IP:$PORT

你应该使用 janus 流插件
https://github.com/meetecho/janus-gateway/blob/8b388aebb0de3ccfad3b25f940f61e48e308e604/plugins/janus_streaming.c

WEBRTC -> RTP -> RTMP

IP=0.0.0.0
PORT=8888
SDP_FILE=sdp.file
/root/bin/ffmpeg -analyzeduration 300M -probesize 300M -protocol_whitelist file,udp,rtp  -i $SDP_FILE  -c:v copy -c:a aac -ar 16k -ac 1 -preset ultrafast -tune zerolatency  -f flv rtmp://$IP:$PORT/rtmp_relay/atyenoria

In order to get the keyframe much easier, it is useful to set fir_freq=1 in janus conf
you should use janus video room or audiobridge plugin
https://github.com/meetecho/janus-gateway/blob/8b388aebb0de3ccfad3b25f940f61e48e308e604/plugins/janus_videoroom.c
https://github.com/meetecho/janus-gateway/blob/8b388aebb0de3ccfad3b25f940f61e48e308e604/plugins/janus_audiobridge.c
After publishing your feed in your room, you should use rtp-forward. The sample javascript command is

# Input this in Google Chrome debug console. you must change publisher_id, room, video_port, host, secret for your conf.
var register = { "request" : "rtp_forward", "publisher_id": 3881836128186438, "room" : 1234, "video_port": 8050, "host" : "your ip address", "secret" : "unko" }
sfutest.send({"message": register});


[wip] 混合进行 janus 录制

从 janus 录制输出文件的 ffmpeg 混合我认为,对于长 mp4 文件,很难从倍数时间戳对齐文件。您可以考虑口形同步。

`#{ffmpeg_path} -y \
              -ss #{member[0].ss_at_time} -t #{member[0].t_at_time} -i #{member[0].file_path} -ss #{member[1].ss_at_time} -t #{member[1].t_at_time}  -i #{member[1].file_path} \
              -ss #{member[2].ss_at_time} -t #{member[2].t_at_time} -i #{member[2].file_path}  -f lavfi -i "color=White" \
                -filter_complex \"
                nullsrc=size=640x480 [base];
                [0:v] setpts=PTS-STARTPTS, scale=320x240 [upperleft];
                [1:v] setpts=PTS-STARTPTS, scale=320x240 [upperright];
                [2:v] setpts=PTS-STARTPTS, scale=320x240 [lowerleft];
                [3:v] setpts=PTS-STARTPTS, scale=320x240 [lowerright];
                [base][upperleft] overlay=shortest=1 [tmp1];
                [tmp1][upperright] overlay=shortest=1:x=320 [tmp2];
                [tmp2][lowerleft] overlay=shortest=1:y=240 [tmp3];
                [tmp3][lowerright] overlay=shortest=1:y=240:x=320;
                [0:a][1:a][2:a] amerge=inputs=3
              \" \
                -preset ultrafast -r 30 -b:v 300k -c:v libx264 #{"/tmp/" + @conference["room_name"] + "/" + index.to_s + ".mp4"}`
  1. jibri 的解决方案 headless chrome + 用 ffmpeg 抓取屏幕是一种积极的方法。这是可能的,但可伸缩性很差。例如,jibri 的 ffmpeg + chrome 进程在我的 vps 服务器中消耗了大约300%。

rtp => rtmp => hls 的示例 nginx.conf

server_names_hash_bucket_size 64;

server {
    listen 443 ssl;
    server_name temp;

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers on;
    ssl_ciphers "EECDH+ECDSA+AESGCM:EECDH+aRSA+AESGCM:EECDH+ECDSA+SHA256:EECDH+aRSA+SHA256:EECDH+ECDSA+SHA384:EECDH+ECDSA+SHA256:EECDH+aRSA+SHA384:EDH+aRSA+AESGCM:EDH+aRSA+SHA256:EDH+aRSA:EECDH:!aNULL:!eNULL:!MEDIUM:!LOW:!3DES:!MD5:!EXP:!PSK:!SRP:!DSS:!RC4:!SEED";

    add_header Strict-Transport-Security "max-age=31536000";

    ssl_certificate /usr/local/nginx/server.crt;
    ssl_certificate_key /usr/local/nginx/server.key;

    access_log  /app/log/nginx_access.log  ;
    error_log  /app/log/nginx_error.log  debug;

    location /janus {
         proxy_set_header X-Real-IP $remote_addr;
         proxy_set_header Host $host;
         proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
         proxy_set_header X-Forwarded-Proto $scheme;
         proxy_http_version 1.1;
         proxy_set_header Upgrade $http_upgrade;
         proxy_set_header Connection "upgrade";
         proxy_set_header Host $host;
         proxy_redirect off;

         proxy_pass http://127.0.0.1:8188;
     }

     location /janus_http {
     proxy_pass http://127.0.0.1:8078;
     }

    location /janus_admin {
         proxy_set_header X-Real-IP $remote_addr;
         proxy_set_header Host $host;
         proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
         proxy_http_version 1.1;
         proxy_set_header Upgrade $http_upgrade;
         proxy_set_header Connection "upgrade";
         proxy_set_header Host $host;
         proxy_pass http://127.0.0.1:7188;
    }

    location /janus_admin_http {
     proxy_pass http://127.0.0.1:7088;
     }

    location /hls {
         types {
             application/vnd.apple.mpegurl m3u8;
             video/mp2t ts;
         }
         root /tmp;
         add_header Cache-Control no-cache;
     }

}

待完成事项

  • janus docker image
  • janus performance improvement patch
  • jitsi vide bridge image ( in other repo)
  • example app for transcording
  • demo site for RTMP -> RTP -> WEBRTC
  • demo site for WEBRTC -> RTP -> RTMP
  • client video mixing in janus gateway
  • rtp => HLS with ffmpeg using GPU transcording

项目贡献者

Akinori Nakajima https://twitter.com/atyenori

任何人都欢迎。


(The first version translated by vz on 2020.07.22)

Overview

Name With Owneratyenoria/janus-webrtc-gateway-docker
Primary LanguageDockerfile
Program languageMakefile (Language Count: 2)
PlatformDocker, Linux, Mac
License:
Release Count5
Last Release Name1.2 (Posted on )
First Release Name1.0 (Posted on )
Created At2016-07-03 16:49:26
Pushed At2023-01-09 05:06:30
Last Commit At2023-01-09 14:06:30
Stargazers Count688
Watchers Count48
Fork Count200
Commits Count116
Has Issues Enabled
Issues Count65
Issue Open Count0
Pull Requests Count9
Pull Requests Open Count0
Pull Requests Close Count2
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private

system
Build Status
CII Best Practices

How to use

https://www.useloom.com/share/325799006d6f4b64a6ce0662ca3f1d57

1. git clone https://github.com/atyenoria/janus-webrtc-gateway-docker.git && cd janus-webrtc-gateway-docker
2. make build
3. make run
4. star this repository after succeeding. Create the issue if you failed. We will help you as much as possible
  • open in Safari (http can't work in Chrome and Firefox)
  • use the host having global ip

Dockerfile Characteristics

Introduction

This is a docker image for Janus Webrtc Gateway. Janus Gateway is still under active development phase. So, as the official docs says, some minor modification of the middleware library versions happens frequently. I try to deal with such a chage as much as I can. If you need any request about this repo, free to contact me. About the details of setup for this docker image, you should read the official docs https://janus.conf.meetecho.com/index.html carefully.

Janus WebRTC Gateway Performance

With the latest libnice, janus gateway seems to be great performance. This repo contains this patch(see https://gitlab.freedesktop.org/libnice/libnice/merge_requests/13 )
https://webrtchacks.com/sfu-load-testing/
load-test
(right side janus graph is available for this docker image )

[wip]Janus WebRTC Gateway vs Jitsi Video Bridge(Personal Opinion)

I think that janus is better for webinar(web seminar), and jitsi is better for web conference system.
The scalability of the current Jitsi Video Bridge(20181007) is poor because of having no local recording file(I'm not sure of this..). https://www.youtube.com/watch?v=OHHoqKCjJ0E
Jitsi last-n + VP8 simulcasting has the very good performance for web conference https://jitsi.org/wp-content/uploads/2016/12/nossdav2015lastn.pdf
For the video format, janus recording is per video streaming, jitsi is for mixed video conference by using chrome headlesss + ffmpeg(alsa, libxcb).
From these points, janus is suitable for webinar, jitsi is for web conference.
Of course, both WebRTC SFU are amazing work!! I'm using both.

[wip]Network benchmarking for preparing WebRTC SFU development

use iperf, netperf

Janus ./configure

libsrtp version:           2.x
SSL/crypto library:        BoringSSL
DTLS set-timeout:          yes
Mutex implementation:      GMutex (native futex on Linux)
DataChannels support:      yes
Recordings post-processor: yes
TURN REST API client:      yes
Doxygen documentation:     no
Transports:
    REST (HTTP/HTTPS):     yes
    WebSockets:            yes
    RabbitMQ:              no
    MQTT:                  no
    Unix Sockets:          no
    Nanomsg:               no
Plugins:
    Echo Test:             yes
    Streaming:             yes
    Video Call:            yes
    SIP Gateway (Sofia):   yes
    SIP Gateway (libre):   no
    NoSIP (RTP Bridge):    yes
    Audio Bridge:          yes
    Video Room:            yes
    Voice Mail:            yes
    Record&Play:           yes
    Text Room:             yes
    Lua Interpreter:       no
    Duktape Interpreter:   no
Event handlers:
    Sample event handler:  no
    RabbitMQ event handler:no
    MQTT event handler:    no
JavaScript modules:        no

RTMP -> RTP -> WEBRTC

IP=0.0.0.0
PORT=8888
/root/bin/ffmpeg -y -i  "rtmp://$IP:80/rtmp_relay/$1  live=1"  -c:v libx264 -profile:v main -s 640x480  -an -preset ultrafast  -tune zerolatency -f rtp  rtp://$IP:$PORT

you should use janus streaming plugin
https://github.com/meetecho/janus-gateway/blob/8b388aebb0de3ccfad3b25f940f61e48e308e604/plugins/janus_streaming.c

WEBRTC -> RTP -> RTMP

IP=0.0.0.0
PORT=8888
SDP_FILE=sdp.file
/root/bin/ffmpeg -analyzeduration 300M -probesize 300M -protocol_whitelist file,udp,rtp  -i $SDP_FILE  -c:v copy -c:a aac -ar 16k -ac 1 -preset ultrafast -tune zerolatency  -f flv rtmp://$IP:$PORT/rtmp_relay/atyenoria

In order to get the keyframe much easier, it is useful to set fir_freq=1 in janus conf
you should use janus video room or audiobridge plugin
https://github.com/meetecho/janus-gateway/blob/8b388aebb0de3ccfad3b25f940f61e48e308e604/plugins/janus_videoroom.c
https://github.com/meetecho/janus-gateway/blob/8b388aebb0de3ccfad3b25f940f61e48e308e604/plugins/janus_audiobridge.c
After publishing your feed in your room, you should use rtp-forward. The sample javascript command is

# Input this in Google Chrome debug console. you must change publisher_id, room, video_port, host, secret for your conf.
var register = { "request" : "rtp_forward", "publisher_id": 3881836128186438, "room" : 1234, "video_port": 8050, "host" : "your ip address", "secret" : "unko" }
sfutest.send({"message": register});

[wip] Mixing for janus recording

  1. ffmpeg mixing from the janus recording outputs files
    I think that it is very difficult to align the file from the multiples timestamps in the case of the long mp4 file. you may consider the lipsync.
`#{ffmpeg_path} -y \
              -ss #{member[0].ss_at_time} -t #{member[0].t_at_time} -i #{member[0].file_path} -ss #{member[1].ss_at_time} -t #{member[1].t_at_time}  -i #{member[1].file_path} \
              -ss #{member[2].ss_at_time} -t #{member[2].t_at_time} -i #{member[2].file_path}  -f lavfi -i "color=White" \
                -filter_complex \"
                nullsrc=size=640x480 [base];
                [0:v] setpts=PTS-STARTPTS, scale=320x240 [upperleft];
                [1:v] setpts=PTS-STARTPTS, scale=320x240 [upperright];
                [2:v] setpts=PTS-STARTPTS, scale=320x240 [lowerleft];
                [3:v] setpts=PTS-STARTPTS, scale=320x240 [lowerright];
                [base][upperleft] overlay=shortest=1 [tmp1];
                [tmp1][upperright] overlay=shortest=1:x=320 [tmp2];
                [tmp2][lowerleft] overlay=shortest=1:y=240 [tmp3];
                [tmp3][lowerright] overlay=shortest=1:y=240:x=320;
                [0:a][1:a][2:a] amerge=inputs=3
              \" \
                -preset ultrafast -r 30 -b:v 300k -c:v libx264 #{"/tmp/" + @conference["room_name"] + "/" + index.to_s + ".mp4"}`
  1. jibri's solution
    headless chrome + grab the screen with ffmpeg is agressive approach. It is possible, but the scalabilitiy is poor.
    For example, the jibri's ffmpeg + chrome process consumes about 300% in my vps server.

Example nginx.conf for rtp => rtmp => hls for scalablity

server_names_hash_bucket_size 64;

server {
    listen 443 ssl;
    server_name temp;

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers on;
    ssl_ciphers "EECDH+ECDSA+AESGCM:EECDH+aRSA+AESGCM:EECDH+ECDSA+SHA256:EECDH+aRSA+SHA256:EECDH+ECDSA+SHA384:EECDH+ECDSA+SHA256:EECDH+aRSA+SHA384:EDH+aRSA+AESGCM:EDH+aRSA+SHA256:EDH+aRSA:EECDH:!aNULL:!eNULL:!MEDIUM:!LOW:!3DES:!MD5:!EXP:!PSK:!SRP:!DSS:!RC4:!SEED";

    add_header Strict-Transport-Security "max-age=31536000";

    ssl_certificate /usr/local/nginx/server.crt;
    ssl_certificate_key /usr/local/nginx/server.key;

    access_log  /app/log/nginx_access.log  ;
    error_log  /app/log/nginx_error.log  debug;

    location /janus {
         proxy_set_header X-Real-IP $remote_addr;
         proxy_set_header Host $host;
         proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
         proxy_set_header X-Forwarded-Proto $scheme;
         proxy_http_version 1.1;
         proxy_set_header Upgrade $http_upgrade;
         proxy_set_header Connection "upgrade";
         proxy_set_header Host $host;
         proxy_redirect off;

         proxy_pass http://127.0.0.1:8188;
     }

     location /janus_http {
     proxy_pass http://127.0.0.1:8078;
     }

    location /janus_admin {
         proxy_set_header X-Real-IP $remote_addr;
         proxy_set_header Host $host;
         proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
         proxy_http_version 1.1;
         proxy_set_header Upgrade $http_upgrade;
         proxy_set_header Connection "upgrade";
         proxy_set_header Host $host;
         proxy_pass http://127.0.0.1:7188;
    }

    location /janus_admin_http {
     proxy_pass http://127.0.0.1:7088;
     }

    location /hls {
         types {
             application/vnd.apple.mpegurl m3u8;
             video/mp2t ts;
         }
         root /tmp;
         add_header Cache-Control no-cache;
     }

}

TODO

  • janus docker image
  • janus performance improvement patch
  • jitsi vide bridge image ( in other repo)
  • example app for transcording
  • demo site for RTMP -> RTP -> WEBRTC
  • demo site for WEBRTC -> RTP -> RTMP
  • client video mixing in janus gateway
  • rtp => HLS with ffmpeg using GPU transcording

Project Contributor

Akinori Nakajima
https://twitter.com/atyenori

Anyone welcomed.

To the top