jitsi / jibri

Jitsi BRoadcasting Infrastructure
Apache License 2.0
609 stars 313 forks source link
hacktoberfest

Jibri

JItsi BRoadcasting Infrastructure

What is Jibri

Jibri provides services for recording or streaming a Jitsi Meet conference.

It works by launching a Chrome instance rendered in a virtual framebuffer and capturing and encoding the output with ffmpeg. It is intended to be run on a separate machine (or a VM), with no other applications using the display or audio devices. Only one recording at a time is supported on a single jibri.

NOTE: Jibri currently only works with a full-fledged Jitsi Meet installation. Using a different frontend won't work.

Installing Jibri

Installation notes

Pre-requisites

ALSA and Loopback Device

Ffmpeg with X11 capture support

sudo add-apt-repository ppa:mc3man/trusty-media
sudo apt-get update
sudo apt-get install ffmpeg

Google Chrome stable & Chromedriver

The latest Google Chrome stable build should be used. It may be able to be installed direclty via apt, but the manual instructions for installing it are as follows:

sudo su -l
apt-get -y install wget curl gnupg jq unzip

curl -fsSL https://dl.google.com/linux/linux_signing_key.pub | gpg --dearmor -o /usr/share/keyrings/google-chrome-keyring.gpg
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/google-chrome-keyring.gpg] http://dl.google.com/linux/chrome/deb/ stable main" | tee /etc/apt/sources.list.d/google-chrome.list

apt-get -y update
apt-get -y install google-chrome-stable
apt-mark hold google-chrome-stable

Add chrome managed policies file and set CommandLineFlagSecurityWarningsEnabled to false. It will hide warnings in Chrome. You can set it like so:

mkdir -p /etc/opt/chrome/policies/managed
echo '{ "CommandLineFlagSecurityWarningsEnabled": false }' >>/etc/opt/chrome/policies/managed/managed_policies.json

Chromedriver is also required and can be installed like so:

CHROME_VER=$(dpkg -s google-chrome-stable | egrep "^Version" | cut -d " " -f2 | cut -d. -f1-3)
CHROMELAB_LINK="https://googlechromelabs.github.io/chrome-for-testing"
CHROMEDRIVER_LINK=$(curl -s $CHROMELAB_LINK/known-good-versions-with-downloads.json | jq -r ".versions[].downloads.chromedriver | select(. != null) | .[].url" | grep linux64 | grep "$CHROME_VER" | tail -1)
wget -O /tmp/chromedriver-linux64.zip $CHROMEDRIVER_LINK

rm -rf /tmp/chromedriver-linux64
unzip -o /tmp/chromedriver-linux64.zip -d /tmp
mv /tmp/chromedriver-linux64/chromedriver /usr/local/bin/
chown root:root /usr/local/bin/chromedriver
chmod 755 /usr/local/bin/chromedriver

Jitsi Debian Repository

The Jibri packages can be found in the stable repository on downloads.jitsi.org. First install the Jitsi repository key onto your system:

curl https://download.jitsi.org/jitsi-key.gpg.key | sudo sh -c 'gpg --dearmor > /usr/share/keyrings/jitsi-keyring.gpg'

Create a sources.list.d file with the repository:

echo 'deb [signed-by=/usr/share/keyrings/jitsi-keyring.gpg] https://download.jitsi.org stable/' | sudo tee /etc/apt/sources.list.d/jitsi-stable.list > /dev/null

Update your package list:

sudo apt-get update

Install the latest jibri

sudo apt-get install jibri

User and Group

sudo usermod -aG adm,audio,video,plugdev jibri

Config files

jibri {
    .....
    api {
        xmpp {
            environments = [
                {
                    name = "yourdomain.com"
                    xmpp-server-hosts = ["1.2.3.4"],
                    xmpp-domain = "yourdomain.com"
                    control-login {
                        domain = "auth.yourdomain.com"
                        username = "jibri"
                        password = "jibriauthpass"
                        port = 5222
                    }
                    control-muc {
                        domain = "internal.auth.yourdomain.com"
                        room-name = "JibriBrewery"
                        nickname = "myjibri-1-2-3-4"
                    }
                    call-login {
                        domain = "recorder.yourdomain.com"
                        username = "recorder"
                        password = "jibrirecorderpass"
                    }
                    strip-from-room-domain = "conference."
                    trust-all-xmpp-certs = true
                    usage-timeout = 0
                }
            ]
        }
    }
    .....
}

Logging

By default, Jibri logs to /var/log/jitsi/jibri. If you don't install via the debian package, you'll need to make sure this directory exists (or change the location to which Jibri logs by editing the log config

Configuring a Jitsi Meet environment for Jibri

Jibri requires some settings to be enabled within a Jitsi Meet configuration. These changes include virtualhosts and accounts in Prosody, settings for the jitsi meet web (within config.js) as well as jicofo.conf.

Prosody

Create the internal MUC component entry. This is required so that the jibri clients can be discovered by Jicofo in a MUC that's not externally accessible by jitsi meet users. Add the following in /etc/prosody/prosody.cfg.lua:

-- internal muc component, meant to enable pools of jibri and jigasi clients
Component "internal.auth.yourdomain.com" "muc"
    modules_enabled = {
      "ping";
    }
    -- storage should be "none" for prosody 0.10 and "memory" for prosody 0.11
    storage = "memory"
    muc_room_cache_size = 1000

Create the recorder virtual host entry, to hold the user account for the jibri chrome session. This is used to restrict only authenticated jibri chrome sessions to be hidden participants in the conference being recordered. Add the following in /etc/prosody/prosody.cfg.lua:

VirtualHost "recorder.yourdomain.com"
  modules_enabled = {
    "ping";
  }
  authentication = "internal_hashed"

Setup the two accounts jibri will use:

prosodyctl register jibri auth.yourdomain.com jibriauthpass
prosodyctl register recorder recorder.yourdomain.com jibrirecorderpass

The first account is the one Jibri will use to log into the control MUC (where Jibri will send its status and await commands). The second account is the one Jibri will use as a client in selenium when it joins the call so that it can be treated in a special way by the Jitsi Meet web UI.

Jicofo

Edit /etc/jitsi/jicofo/jicofo.conf, set the appropriate MUC to look for the Jibri Controllers. This should be the same MUC as is referenced in jibri's jibri.conf file. Restart Jicofo after setting this property. It's also suggested to set the pending-timeout to 90 seconds, to allow the Jibri some time to start up before being marked as failed.

jicofo {
  ...
  jibri {
    brewery-jid = "JibriBrewery@internal.auth.yourdomain.com"
    pending-timeout = 90 seconds
  }
  ...
}

Jitsi Meet

Edit the /etc/jitsi/meet/yourdomain-config.js file, add/set the following properties:

// recording
config.recordingService = {
  enabled: true,
  sharingEnabled: true,
  hideStorageWarning: false,
};

// liveStreaming
config.liveStreaming = {
  enabled: true,
};

config.hiddenDomain = "recorder.yourdomain.com";

Once recording is enabled in yourdomain-config.js, the recording button will become available in the user interface. However, until a valid jibri is seen by Jicofo, the mesage "Recording currently unavailable" will be displayed when it is pressed. Once a jibri connects successfully, the user will instead be prompted to enter a stream key.

Note: Make sure to update Jibri's jibri.conf appropriately to match any config done above.

Start Jibri

Once you have configured jibri.conf, start the jibri service:

sudo systemctl restart jibri