Record incoming SRTP audio/video streams.

1,015 views
Skip to first unread message

Darius

unread,
Apr 13, 2021, 11:03:32 AM4/13/21
to meetecho-janus
Hello,

I'm a newbe about Janus and WebRTC.
I'm using Janus to receive SRTP streams (2 videos and 1 audio) to send them to a remote client (I'm using janus multistreams version). All works fine right now, but I should be able to record all streams at Janus server. It's possible? 
Using recordplay plugin is possible to record a "local-generated" audio/video stream. Basically, do is possible to feed the recordplay plugin in order to record the inbound SRTP streams described?

Any help will be appreciated, many thanks!

Bye 

Mirko Brankovic

unread,
Apr 13, 2021, 5:07:30 PM4/13/21
to meetecho-janus
You can set record option on room creating:
It used to be a file per stream, not sure how it is on working with multistream, i guess you would still need a post processor

--
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/0846be23-3abe-4d8c-b34d-45beab696d75n%40googlegroups.com.

Lorenzo Miniero

unread,
Apr 14, 2021, 7:37:39 AM4/14/21
to meetecho-janus
It's the same in multistream, we still record each audio/video/data track to a separate file.

L.

Darius

unread,
Apr 14, 2021, 9:08:03 AM4/14/21
to meetecho-janus
Hi,

thanks for your information! Unfortunately I'm not able to start the recording. It's certainly my fault do to my unexperience. Basically, I'm using a modified streamingtest.js script (based on demos script). I try to enable recording in the function startStream(), after the watch request, like this:

...
// Prepare the request to start streaming and send it
var body = { request: "watch", id: parseInt(selectedStream) || selectedStream };
streaming.send({ message: body });
//TRY TO RECORD.
var record = { request: "record", name: "testrec" };
streaming.send({ message: record });
...

I get this error at client side from janus.js:1423:12:

error: "Unknown request 'record'"
error_code: 452
streaming: "event"

I think I'm in wrong. Can you suggest to me a right way to do that?

Many thanks, bye

Darius

unread,
Apr 14, 2021, 1:08:05 PM4/14/21
to meetecho-janus
Ok, referring to the correct documentation now I'm looking here:


So, the recording request look like this:
...
// Prepare the request to start streaming and send it
var body = { request: "watch", id: parseInt(selectedStream) || selectedStream };
streaming.send({ message: body });
var record = { request: "recording", action: "start", id: parseInt(selectedStream) || selectedStream, video: "/opt/janus/share/janus/recordings", audio: "/opt/janus/share/janus/recordings" };
streaming.send({ message: record });
Janus.log("Recording sent id " + selectedStream);
...

Janus log say:
Apr 14 19:00:45 us janus[27153]: [ERR] [record.c:janus_recorder_create_full:227] fopen error: 13
Apr 14 19:00:45 us janus[27153]: [ERR] [plugins/janus_streaming.c:janus_streaming_process_synchronous_request:4622] [multi-stream] Error starting recorder for video

I've tried to setup a specific filename in the video and audio tag without luck, same error. There is no permission issue. What can it depend on?

Thanks again!

Lorenzo Miniero

unread,
Apr 15, 2021, 4:32:36 AM4/15/21
to meetecho-janus
fopen error 13 *is* a permission error.

L.

Dario Maggiari

unread,
Apr 15, 2021, 6:19:51 AM4/15/21
to Lorenzo Miniero, meetecho-janus
Yes I know, but I'm not able to figure out why. Permissions on folders are corrects...

Janus run as janus user and the directory as the right permissions. In case of plugin recordplay or videoroom there are no problems (janus write into the same recordings folder without problems). Then I don't know the difference in this case... 

You received this message because you are subscribed to a topic in the Google Groups "meetecho-janus" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/meetecho-janus/nLQjZS2QzaU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to meetecho-janu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/meetecho-janus/11dd4308-9105-4d99-b1fb-6eafdd03b50en%40googlegroups.com.

Dario Maggiari

unread,
Apr 15, 2021, 6:48:10 AM4/15/21
to Lorenzo Miniero, meetecho-janus
Yes I know, but I'm not able to figure out why. Permissions on folders are corrects...

Janus run as janus user and the directory as the right permissions. In case of plugin recordplay or videoroom there are no problems (janus write into the same recordings folder without problems). Then I don't know the difference in this case... 


Darius

unread,
Apr 15, 2021, 9:54:34 AM4/15/21
to meetecho-janus
Hi,

Ok, the video pathname isn't passed to janus_recorder_create_full function.
Assuming to configure the record request linke this:

var record = { request: "recording", action: "start", id: parseInt(selectedStream) || selectedStream,
audio: "/opt/janus/share/janus/recordings/as",    
video: "/opt/janus/share/janus/recordings/vs" };

Debugging the janus_recorder_create_full(const char *dir, const char *codec, const char *fmtp, const char *filename) function I can see 'filename' param (and 'dir') is NULL in case of video streaming. In case of audio streaming 'filename' param is correct! Audio is recorded in /opt/janus/share/janus/recordings/as.mjr as request.
Instead, in case of video streaming, the code try to generate a random name, one for any streams, without NO basename and then the recording path is wrong because is just the filename. This lead to the previous error I mentioned about fopen permissions error.

Do is a bug related to the multistream case? In example, with 2 streams I'm expecting to find two recordings like /opt/janus/share/janus/recordings/vs-<randomnum>.mjr and /opt/janus/share/janus/recordings/vs-<anotherrandomnum>.mjr ('vs' can be a custom identifier to recognize videos later). I've tried to hardcode a path in the  janus_recorder_create_full function and this works fine generating 2 video streams but with totally random names. Obviously, setting a custom name from recording javascript request is mandatory in order to recognize the specific recording later. Can you check this error? Is there a workaround to fix that?

In addition, the documentation say:

"audio" : "<enable audio recording, and use this base path/filename; optional>", 
"video" : "<enable video recording, and use this base path/filename; optional>",

...but audio and video are mandatory because without those params there is another error like:

[ERR] [plugins/janus_streaming.c:janus_streaming_process_synchronous_request:4568] Missing audio, video and/or data

I think this is a secondary problem. 

Many thanks, bye

Darius

unread,
May 3, 2021, 10:50:00 AM5/3/21
to meetecho-janus
Hi!

Looking to last Janus update I see you have added the new "Drill-down" syntax for recording. This fix my problem related to start recording on multi-stream condition. Thanks.

Unfortunately, now I see some errors stopping the recording and I'm not able to stop the recording itself! 
Record start correctly sending a message like this:
{
"request":"recording",
"action":"start",
"id":10,
"media":[{"mid":"c10","filename":"/path/file-c10"},{"mid":"l10","filename":"/path/file-l10"}]
}


Then I try to stop the recording like this:
{
"request":"recording",
"action":"stop",
"id":10,
"media":[{"mid":"c10"},{"mid":"l10"}]
}

...I receive this error after a couple of seconds:

"Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://localhost:8089/janus/5008822521115662/6318282198043770. (Reason: CORS request did not succeed)."

And then Janus say (1441:11): "Probably a network error, is the server down?: Object { message: "Probably a network error, is the server down?", error: TypeError }"

Obviously, recording does not stop and continue to record the session. Janus is still alive and there are no errors at janus logs apparently...
Do you know what it depends on?

Many thanks, bye

Darius

unread,
May 19, 2021, 7:56:49 AM5/19/21
to meetecho-janus
Hello,

Have you some news about last problem? 

Many thanks, bye

Lorenzo Miniero

unread,
May 20, 2021, 6:45:23 AM5/20/21
to meetecho-janus
The CORS error has nothing to do with Janus or the VideoRoom API. You should check why the HTTP request is not getting to Janus at all.
The HTTP transport has settings related to CORS, if that helps.

L.

Darius

unread,
May 20, 2021, 10:20:55 AM5/20/21
to meetecho-janus
Hi,

thanks for your replay.

Executing from Chrome (the previous error was from Firefox) the behaviour is the same but the error message is slightly different:

janus.js:117 POST https://localhost:8089/janus/669997840190928/49736472494438 net::ERR_INCOMPLETE_CHUNKED_ENCODING 200 (OK)
httpAPICall @ janus.js:117
sendMessage @ janus.js:1406
send @ janus.js:1300
stopRecordStream @ streamingtest.js:805
stopStream @ streamingtest.js:677
removeJanusSession @ streamingtest.js:548
processWsMessage @ streamingtest.js:74
janus.js:1441 Failed to parse response body: {message: "Failed to parse response body", error: TypeError: Failed to fetch, response: Response}

What about " "Failed to parse response body", error: TypeError: Failed to fetch, response: Response" and "net::ERR_INCOMPLETE_CHUNKED_ENCODING 200"?

Thanks again, bye

Darius

unread,
May 20, 2021, 10:41:47 AM5/20/21
to meetecho-janus
...just to clarify:

this happens only when I use the 'stop recording' message the first time. Without recording I have no errors like this.
Therefore, after the first "Failed to parse response body" at 'stop recording' message no one subsequent request is accepted. For example, after a 'stop recording' message I can create another new Janus session and I would to send a new 'list' message, but even in this case I have the same error:

Failed to parse response body: {message: "Failed to parse response body", error: TypeError: Failed to fetch, response: Response}
error @ janus.js:1441
(anonymous) @ janus.js:151
Promise.catch (async)
httpAPICall @ janus.js:149
sendMessage @ janus.js:1406
send @ janus.js:1300
updateStreamsList @ streamingtest.js:564
success @ streamingtest.js:265
success @ janus.js:1322
(anonymous) @ janus.js:140
Promise.then (async)
(anonymous) @ janus.js:139
Promise.then (async)
httpAPICall @ janus.js:136
createHandle @ janus.js:1254
Janus.attach @ janus.js:552
success @ streamingtest.js:254
success @ janus.js:947
(anonymous) @ janus.js:140
Promise.then (async)
(anonymous) @ janus.js:139
Promise.then (async)
httpAPICall @ janus.js:136
createSession @ janus.js:927
Janus @ janus.js:537
addJanusSession @ streamingtest.js:249
processWsMessage @ streamingtest.js:65

If recording is disabled I have no errors in a situation like this and all works fine. I'm not able to figure out this problem is related to the recording only but it seems...

Thanks, bye
Reply all
Reply to author
Forward
0 new messages