Jibri Tip: send the recording folder name or a download link to the initiator

On jibri instances

apt-get install nginx libnginx-mod-http-lua dnsutils

/etc/nginx/sites-enabled/jibri.conf

server {
  listen 5000;
  listen [::]:5000;

  root /var/www/html;
  index index.html;

  server_name _;
  add_header Access-Control-Allow-Origin *;

  location = /jibri/nick {
    content_by_lua_block {
      local sh = io.popen(
        "egrep '^\\s*nickname\\s*=' /etc/jitsi/jibri/jibri.conf | cut -d\\\" -f2");
      local nick = sh:read("*all")
      nick = nick:gsub("%s+", "");
      sh.close();

      ngx.print(nick);
    }
  }

  location = /jibri/ip {
    content_by_lua_block {
      local sh = io.popen(
        "dig -4 +short myip.opendns.com a @resolver1.opendns.com");
      local ip = sh:read("*all")
      ip = ip:gsub("%s+", "");
      sh.close();

      ngx.print(ip);
    }
  }

  location = /jibri/url {
    content_by_lua_block {
      local sh = io.popen(
        "dig -4 +short myip.opendns.com a @resolver1.opendns.com");
      local ip = sh:read("*all")
      ip = ip:gsub("%s+", "");
      sh.close();

      ngx.print(string.format(
        "http://%s:5000/recordings", ip
      ));
    }
  }

  location ~ /recordings/([a-zA-Z0-9]+) {
    set $sid "$1";
    set $meta "/usr/local/recordings/${sid}/metadata.json";

    access_by_lua_block {
      if (os.execute("[ -f " .. ngx.var.meta .. " ]") == 0)
      then
        return;
      else
        return ngx.exit(ngx.HTTP_FORBIDDEN);
      end
    }

    root /usr/local;
    autoindex on;
  }

  location / {
    return 403;
  }
}

On JMS

/usr/share/jitsi-meet/body.html

<script>
  async function sendSessionId(attempt) {
    try {
      attempt += 1;
      if (attempt > 3) return;

      // skip if I am not recorder
      const isRecorder = APP.store.getState()["features/base/config"].iAmRecorder;
      if (!isRecorder) return;

      // session data
      const session = APP.store.getState()["features/recording"].sessionDatas[0];
      const sessionId = session.id;
      const sessionMode = session.mode;
      const initiatorId = session.initiator._id;

      // skip if this is not a recording session (possibly live streaming)
      if (sessionMode !== "file") return;

      let res;

      // jibri nick
      res = await fetch("http://127.0.0.1:5000/jibri/nick");
      let nick = await res.text();

      // jibri url (the recording folder's base url)
      res = await fetch("http://127.0.0.1:5000/jibri/url");
      let url = await res.text();

      // private message
      const msg =
        `${nick} started recording. To access the recording folder:\n\n` + 
        `${url}/${sessionId}/`;
      APP.conference._room.sendMessage(msg, initiatorId);
    } catch(e) {
      setTimeout(function() {sendSessionId(attempt);}, 3000);
    }
  }

sendSessionId(0);
</script>

thanks a lot, I’m using jibri on docker is the same thing I think!

I’ll test this and let you know!

Hi @Yassine,

Have you try this using jibri on docker? can you please share the configuration?

And @emrah, if I’m using jibri on docker, and the location of the recording files is located on /root/jibri-docker/recordings, is it enough if I change this:

location ~ /recordings/([a-zA-Z0-9]+) {
    set $sid "$1";
    set $meta "/srv/recordings/${sid}/metadata.json";

to this:

location ~ /recordings/([a-zA-Z0-9]+) {
    set $sid "$1";
    set $meta "/root/jibri-docker/recordings/${sid}/metadata.json";

And I have already tested this on native JMS (non-docker) and external jibri on docker, the recording initiator was able to receive the private message, but it failed to accessing the recording files.

Any help would be very appreciated.

Thanks

Do you have Nginx in your jibri container? This location block is for Jibri’s Nginx.

What if i Install nginx outside the jibri container? will it work with the above settings?
I plan to install nginx outside the jibri container

no