Recording on/off by API (videoroom)

2,003 views
Skip to first unread message

Fabian Bernhard

unread,
Jul 13, 2016, 2:01:53 PM7/13/16
to meetecho-janus
Dear list,

We would like to only partially record a session, i.e. have the APIs "startRecording" and "stopRecording" available to start and stop recording of a video room session. Afaik this is not possible yet. 

Is there any one developing this feature at the moment? 

Thanks and regards,

Fabian

Lorenzo Miniero

unread,
Jul 13, 2016, 3:55:29 PM7/13/16
to meetecho-janus
Hi Fabian,

it's something you can do in a more "implicit" way. More specifically, you can start/stop at any time, through "configure" requests, the recording for individual publishers. This means that, if you use that instead of the global "record all" option for rooms, you're able to do what you need. Of course this means enabling/disabling it for each participant, and so keeping some sort of state, which can be annoying, but it works and we use it a lot ourselves.

L.

Chad Furman

unread,
Jul 15, 2016, 2:44:11 PM7/15/16
to meetecho-janus
You can only broadcast configure requests for your local session, though, right?  That is, a videoroom "host" cannot broadcast a configure request for all the participants on the room to start their recordings?

I had to add a "startrecording" event for this feature.  I'd feel silly now if it wasn't needed...

Lorenzo Miniero

unread,
Jul 16, 2016, 1:29:48 AM7/16/16
to meetecho-janus
Il giorno venerdì 15 luglio 2016 20:44:11 UTC+2, Chad Furman ha scritto:
You can only broadcast configure requests for your local session, though, right?  That is, a videoroom "host" cannot broadcast a configure request for all the participants on the room to start their recordings?

I had to add a "startrecording" event for this feature.  I'd feel silly now if it wasn't needed...



Yeah, you'd need to send an event out of band to your publishers to have them record, if no Janus wrapping is done on the server side. We control Janus a lot from server-side apps, rather than exposing the Janus API to users directy, which means it's easier to do there (you just keep state and send all messages yourself).

Does your new method iterate on publishers and enable/disable recordings in a bulk as Fabian said? If so, would you consider submitting a pull request?

Lorenzo

Fabian Bernhard

unread,
Jul 16, 2016, 1:51:24 AM7/16/16
to meetecho-janus
Hi Lorenzo,
 
it's something you can do in a more "implicit" way. More specifically, you can start/stop at any time, through "configure" requests, the recording for individual publishers. This means that, if you use that instead of the global "record all" option for rooms, you're able to do what you need. Of course this means enabling/disabling it for each participant, and so keeping some sort of state, which can be annoying, but it works and we use it a lot ourselves.

You mean "set" request, right?

{
        "request" : "set",
        "audio" : true|false,
        "video" : true|false,
        "bitrate" : <numeric bitrate value>,
        "record" : true|false,
        "filename" : <base path/filename to use for the recording>
}

If the server knew the session id's of the participants it could send out this request on behalf of the participants, right?

Thanks!

Lorenzo Miniero

unread,
Jul 16, 2016, 1:56:30 AM7/16/16
to meetecho-janus
No, there's no message called "set" in VideoRoom: it's "configure". But as Chad said, you cannot send a configure on behalf of other people, each publisher must send their own. That's why I said that, in case you're talking to Janus from browsers, you have to let your JavaScript code know it's time to record using an out-of-band mechanism, so that they can send a configure to start/stop recording themselves.

As to a new ad-hoc message, we're currently in Berlin to stream the IETF meeting and we'll stay there for one more week, and so it's not something we can do until we return. Of course I can help reviewing any PR that aims at adding such a feature, in the meanwhile.

L.

Chad Furman

unread,
Jul 18, 2016, 7:44:44 AM7/18/16
to meetecho-janus


On Saturday, July 16, 2016 at 1:29:48 AM UTC-4, Lorenzo Miniero wrote:
Does your new method iterate on publishers and enable/disable recordings in a bulk as Fabian said? If so, would you consider submitting a pull request?

It does this, yes.  There's also support for multiple participant playback.  It's very unstable at the moment, even more so now that I merged in the last two-months of changes from the main Janus repo.

There's a chance the client would be okay with this if it meant that we'd have more support in developing the features we're after. 

Chad Furman

unread,
Jul 18, 2016, 7:45:36 AM7/18/16
to meetecho-janus
The features we're after at the moment are multiple participant recording (which works), playback (which was working but isn't after the merge), and eventually seek-to-time 

Chad Furman

unread,
Jul 20, 2016, 1:03:23 AM7/20/16
to meetecho-janus
I did speak with the powers that be and I am not allowed to submit a PR at this point in time.

I am sorry.

Oscar Vadillo

unread,
Jul 25, 2016, 10:21:12 AM7/25/16
to meetecho-janus
Any news about this? It will be very interesting a request for configure the Videoroom parameters at live! For example, change the room_name or record value.

What do you recommend to get it Lorenzo?

Thanks in advanced

Lorenzo Miniero

unread,
Jul 25, 2016, 10:23:50 AM7/25/16
to meetecho-janus
It sounds like an excellent idea for a pull request ;-)
I'm currently busy on other stuff so no immediate plan to work on this myself.

L.

Oscar Vadillo

unread,
Jul 27, 2016, 3:16:34 AM7/27/16
to meetecho-janus
Maybe I use an event to notify to publishers that they must start to record. 

What event of example you recommend me to notify all publishers of a Videoroom?

Thanks in advanced.

Oscar Vadillo

unread,
Jul 27, 2016, 5:17:06 AM7/27/16
to meetecho-janus
It's possible to set a Videoroom as private dynamically?

Best regards

Lorenzo Miniero

unread,
Jul 27, 2016, 11:18:28 AM7/27/16
to meetecho-janus
Nope, you can't modify any aspect of a room after you created it as of now,

L.

Chad Furman

unread,
Jul 29, 2016, 1:51:19 AM7/29/16
to meetecho-janus
socket.io would probably be sufficient to trigger all participants to start recording.

Alternatively...
  1. https://github.com/meetecho/janus-gateway/blob/master/plugins/janus_videoroom.c#L1850  <-- add an event, something like "startrecording" and "stoprecording"
  2. https://github.com/meetecho/janus-gateway/blob/master/plugins/janus_videoroom.c#L2884 <-- copy this simple handler here and adapt it to start recording... 

    } else if(!strcasecmp(request_text, "startrecording") || !strcasecmp(request_text, "stoprecording")) {
       int starting = !strcasecmp(request_text, "startrecording") ? TRUE : FALSE;
       janus_videoroom_participant *p = (janus_videoroom_participant *)session->participant;

       if(p->room == NULL) {
          JANUS_LOG
    (LOG_ERR, "No videoroom exists for participant %"SCNu64" (%s)\n", p->user_id, p->display ? p->display : "??");
          error_code = JANUS_VIDEOROOM_ERROR_NO_SUCH_ROOM;
          g_snprintf(error_cause, 512, "No videoroom exists for participant %"SCNu64" (%s)\n", p->user_id, p->display ? p->display : "??");
          goto error;
       }

       JANUS_LOG
    (LOG_INFO, "Locking room mutex...");
       janus_mutex_lock(&rooms_mutex);
       JANUS_LOG(LOG_INFO, "locked.\n");
       janus_videoroom *videoroom = g_hash_table_lookup(rooms, &p->room->room_id);
       if(videoroom->destroyed) {
          JANUS_LOG
    (LOG_ERR, "No such room (%"SCNu64")\n", videoroom->room_id);
          error_code = JANUS_VIDEOROOM_ERROR_NO_SUCH_ROOM;
          g_snprintf(error_cause, 512, "Videoroom (%"SCNu64")", videoroom->room_id);
          goto error;
       }

       
    if(videoroom->room_secret) {
         
    /* A secret is required for this action */
          json_t *secret = json_object_get(root, "secret");
          if(!secret) {
             JANUS_LOG
    (LOG_ERR, "Missing element (secret)\n");
             error_code = JANUS_VIDEOROOM_ERROR_MISSING_ELEMENT;
             g_snprintf(error_cause, 512, "Missing element (secret)");
             goto error;
          }
         
    if(!json_is_string(secret)) {
             JANUS_LOG
    (LOG_ERR, "Invalid element (secret should be a string)\n");
             error_code = JANUS_VIDEOROOM_ERROR_INVALID_ELEMENT;
             g_snprintf(error_cause, 512, "Invalid element (secret should be a string)");
             goto error;
          }
         
    if(!janus_strcmp_const_time(videoroom->room_secret, json_string_value(secret))) {
             JANUS_LOG
    (LOG_ERR, "Unauthorized (wrong secret)\n");
             error_code = JANUS_VIDEOROOM_ERROR_UNAUTHORIZED;
             g_snprintf(error_cause, 512, "Unauthorized (wrong secret)");
             goto error;
          }
       
    }
       JANUS_LOG
    (LOG_INFO, "Unlocking rooms mutex...");
       janus_mutex_unlock(&rooms_mutex);
       JANUS_LOG(LOG_INFO, "done.\n");

       janus_videoroom_set_recording_status(videoroom, starting, participant->user_id);

       event = json_object();
       json_object_set_new(event, "videoroom", json_string("event"));
       json_object_set_new(event, "room", json_integer(participant->room->room_id));
       if (starting) {
          json_object_set_new
    (event, "startrecordingdone", json_string("ok"));
       } else {
          json_object_set_new
    (event, "stoprecordingdone", json_string("ok"));
       }

Of course, this doesn't solve the problem of playing back the recordings in the videoroom.  That's a bit harder.  Still, similar concept.  You can get the playback code from another demo...


On Wednesday, July 13, 2016 at 2:01:53 PM UTC-4, Fabian Bernhard wrote:

Chad Furman

unread,
Jul 29, 2016, 1:56:32 AM7/29/16
to meetecho-janus
continuing from above, in "set_recording_status" you'll basically be doing the following:
  1. locking room mutex
  2. setting videoroom->recording_active to true / false (if starting/stopping)
  3. setting the user that started the recording (optional, I added a property for this, helps for when users leave the room to know who started so when they leave you can stop the recording , I have UI enforced host behavior)
  4. unlocking room mutex
  5. locking participant mutex
  6. iterating over the list of participants in the room to a) setup their recorders and b) notify them that recording has started/stopped so they can update their local UI
  7. unlocking participant mutex
Something like that...

On Wednesday, July 13, 2016 at 2:01:53 PM UTC-4, Fabian Bernhard wrote:

Lorenzo Miniero

unread,
Jul 29, 2016, 4:35:49 AM7/29/16
to meetecho-janus
Probably much better and easier doing this out-of-band (eg. via socket.io) than overloading the plugin messaging.

L.
Message has been deleted

Derek W

unread,
Aug 30, 2016, 4:00:05 PM8/30/16
to meetecho-janus

Hello,

I would essentially like to do the same thing as mentioned in the post title....  I would like to have Janus setup on a Raspberry pi and be able to start/stop streaming as well as start/stop recording, then manipulate the audio/video file, encode, compress, transfer...etc.  I will be connecting using a computer on the same LAN.  To start, there will only be one subscriber to the feed (the computer I am connecting from).


a) Would it be possible to create a custom web page hosted on the pi that would interface with Janus which would also be running on Pi and provide me the above functionality?

or

b) Would it be possible to send the commands from a mobile device to accomplish the above using socket.io or another method?

Would you recommend using one method over other (A or B)?


Are there any examples that I may refer to, especially for the socket.io?  I am not familiar at all with how that would work...

Respectfully,

Derek

Webmaster Webmaster

unread,
Aug 30, 2016, 5:57:17 PM8/30/16
to meetecho-janus
On Tuesday, 30 August 2016 22:00:05 UTC+2, Derek W wrote:

a) Would it be possible to create a custom web page hosted on the pi that would interface with Janus which would also be running on Pi and provide me the above functionality?

Have a look at UV4L for Raspberry Pi. It can already start/stop the audio/video/data streaming from the Rpi camera (or any other supported input device) to/from a given videoroom on a given Janus Gateway (but start/stop recording is not supported yet, see below).

As a convenience, this is an OS image for Raspberry Pi with UV4L and Janus installed working out-of-the-box:

http://www.linux-projects.org/rpi-videoconference-demo-os/

It's everything web-based so you should be able to easily customize the pages as you wish.

b) Would it be possible to send the commands from a mobile device to accomplish the above using socket.io or another method?

There is some work in progress on UV4L to provide a well-defined RESTful API over HTTP/HTTPS which would allow a client to control *every* single detail of a videoroom session, including start/stop commands.

Jaffer Kazmi

unread,
Jun 10, 2020, 8:33:20 AM6/10/20
to meetecho-janus
Hi janus team and member!
I am facing janus crash on server while enabling recording in video room , and i got following errors in server log
Unsupported codec 'null'
Attempt to unlock mutex that was not locked

here is my configuration 

{
      request: "create",
      room: roomUniqueId,
      publishers: 20,
      fir_freq: 10,
      audiocodec: "opus",
      videocodec: "vp8",
      record: true,
      rec_dir: `file path`,
    }
Can anyone help me? Thanks in Advance

Mirko Brankovic

unread,
Jun 10, 2020, 9:05:08 AM6/10/20
to meetecho-janus
Those 2 loglines are different things.
This one: Unsupported codec 'null' i've seen in case you create room with audio: true, video: true , and in sdp you provide only one of those. so if you start with only audio, set only audio to true and use configure to enable video later, but it is just a logline warning so it doesn't hurt.

The second one I don't know much about.

--
You received this message because you are subscribed to the Google Groups "meetecho-janus" group.
To unsubscribe from this group and stop receiving emails from it, send an email to meetecho-janu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/meetecho-janus/014bd35c-1fa9-4d43-ba00-484ee929eba1o%40googlegroups.com.


--
Regards,
Mirko

Lorenzo Miniero

unread,
Jun 10, 2020, 9:09:58 AM6/10/20
to meetecho-janus
Why exactly are you asking questions on a post from FOUR YEARS AGO?

L.
Message has been deleted

Jaffer Kazmi

unread,
Jun 10, 2020, 2:43:48 PM6/10/20
to meetecho-janus
sorry , but i thought that this thread is related to my problem that's why i posted here, i will create new topic for it kindly help me there
Reply all
Reply to author
Forward
0 new messages