Playing Videoroom .mjr files

1,410 views
Skip to first unread message

Oscar Vadillo

unread,
Aug 8, 2016, 10:14:33 AM8/8/16
to meetecho-janus
Hello everybody,

I'd like to know if it's possible to play a video that has been recorded via Videoroom Plugin since the Recorder/Playout Demo.

I modify the path value at the janus.plugin.recordplay.cfg file but I can't see the .mjr files generated via Videoroom plugin in the select combo.

Thanks in advanced.

Best regards
Oscar

Lorenzo Miniero

unread,
Aug 8, 2016, 4:32:10 PM8/8/16
to meetecho-janus
No, post-processing is always ex-post.

L.

Chad Furman

unread,
Aug 29, 2016, 2:44:01 PM8/29/16
to meetecho-janus
Yes, it absolutely is possible to play the videoroom recordings.  Though, it's a little bit of a pain in the butt.

What I've been doing is, when recording ends, I use code from the recordplay and streaming plugins in the following way:

recordplay code gives me code for sorting frame headers and for playing frame headers via playout thread.
streaming plugin gives me code for determining if a frame is a keyframe or not (useful for seeking)

So basically, if you make a group of "playback" participants and have the client subscribe to the playback participants like they're real participants, then use setup media to start a playout thread for each playback participant, you can do the following:

when recording is stopped, process mjr files to get sorted frame header lists, write these list to files (keep track of which header files go to which mjr)
read frame header file one header at a time, use offset to get rtp packet from mjr file, send rtp packet
repeat 

I prefer using mjr headers in a file rather than in memory so you can have long recordings without any memory concerns.  It's also not really slow.

Jaych Su

unread,
Oct 22, 2016, 10:38:40 AM10/22/16
to meetecho-janus
I want to play `.mjr` files via janus too. May i have more detail?

I am now using a stupid way:

1. Using `VideoRoom` to record stream and save as `.mjr`.
2. Create `.nfo` file by command and load `.mjr` by `RecordPlay`

Any good idea?

Lorenzo Miniero

unread,
Oct 24, 2016, 7:05:26 AM10/24/16
to meetecho-janus
That doesn't look stupid to me ;-)
It's probably the best way to do that currently, unless you want to write your own plugin to handle that.

L.

Chad Furman

unread,
Oct 24, 2016, 9:40:23 AM10/24/16
to meetecho-janus
What I do is use the logic of the record/play plugin inside the videoroom plugin.  I build mjr files for each participant, and when recording ends I process the mjr files into frame header files (rather than the frame header structure provided by the recordplay plugin which tends to run me out of memory sometimes on larger recordings)

I use new event types: playbackprep, playbackstart, and playback stop.  Playback prep builds participant objects like people are joining the room, but I flag them as playback participants.  Playbackstart triggers a thread to offer playback participants at the relative time associated with when they entered the room during recording (i.e. 10 minutes into recording person joins, so 10 minutes into playback the playback participant is offered).  The front-end receives playback participants like regular participants and subscribes to their stream, then in setup_media I start playout threads for each of the playback participants associated with the user requesting playback.  The playout thread uses the frame file that we constructed to send audio and video RTP packets at the right time.

There's some logic in there for seeking, mainly adjusting the timestamps.  Seeking also requires that video start from a keyframe, and so I've adjusted my keyframe interval to be every second.  Seeking from a keyframe also requires synchronizing audio to that keyframe, and so I normalize the difference in packet frequency using the existing logic in the recordplay code, and use the normalized difference to determine what is the first audio packet I send.

I can't share code at the moment, but hopefully this helps :)

Jaych Su

unread,
Oct 25, 2016, 11:46:04 AM10/25/16
to meetecho-janus
Actually, I only use the audio file in mixed version, and I want to play this audio later.

So I try another way:

1. Use `AudioBridge` to record voice from all client in the room.
2. Use `RecordPlay` to play this audio file.

And there are my questions:

1. Could `AudioBridge` output `.mjr` format? I try to change extension directly in `rec_file`, and then got an incomplete audio. Or need to use `janus-pp-rec.c` tool to convert that manually?
2. Could `RecordPlay` play `.wav` file by any config?

Chad Furman

unread,
Oct 25, 2016, 11:53:33 AM10/25/16
to meetecho-janus
Ahh, I don't know for sure.  The original question was about playing MJR files.  MJR files are just raw RTP packets, a format that I think is unique to Janus.  I don't know if the AudioBridge plugin can replicate this format, or if you'd want it to.  If you want to use .wav files, there might be something in the streaming plugin that can help you.  Otherwise, send them to the client as a download on pageload, put them in an HTML5 audio element, and play them from there. 

Good luck :)

Jaych Su

unread,
Oct 25, 2016, 12:07:04 PM10/25/16
to meetecho-janus
Thx for ur reply. Well, I digress from the subject. I just want to seek a way to handle my demand via `Janus` totally without something extra. It seems to write my own plugin is the clear solution.

Lorenzo Miniero

unread,
Oct 26, 2016, 5:07:19 AM10/26/16
to meetecho-janus
MJR expects RTP packets. The AudioBridge can save MJR for specific users (their own contribution), but not for the mix, as that's not associated to a specific RTP session. That's why the mix is simply saved to a wav file, which is very easy to integrate into a replay mechanism anyway (either replay it as it is in an <audio> element or convert it to mp3/ogg/whatever first), without the need of involving WebRTC for that.

L.
Reply all
Reply to author
Forward
0 new messages