I am using janus-gateway for recording in web-browser. Once the recording is completed, two files are generated, one is audio and another is a video. Both have format mjr. How can I combine both these files to create a single file?
3 Answers
I was dealing with the same need.
If you did the default janus-gateway install you only miss these steps:
run this on the folder where you downloaded the git sources:
./configure --enable-post-processing
then
make
(sudo) make install
then run this for each file you want to convert them to audio/video formats:
./janus-pp-rec /opt/janus/share/janus/recordings/video.mjr /opt/janus/share/janus/recordings/video.webm
./janus-pp-rec /opt/janus/share/janus/recordings/audio.mjr /opt/janus/share/janus/recordings/audio.opus
if you don't have ffmpeg installed run this (i'm on Ubuntu, on other distros ffmpeg might be already in apt-get repositories)
sudo add-apt-repository ppa:kirillshkrogalev/ffmpeg-next
sudo apt-get update
sudo apt-get install ffmpeg
and then finally to merge audio with video:
(sudo) ffmpeg -i audio.opus -i video.webm -c:v copy -c:a opus -strict experimental mergedoutput.webm
from there you can build a shell script to convert all mjr files automatically on a cron

- 2,197
- 2
- 19
- 22
-
1I needed to also install the following on my Debian system to run `janus-pp-rec`: `apt-get install -y libavutil54 libavcodec56 libavformat56` – Ezekiel Victor Feb 25 '19 at 21:20
-
after convert by ffmpeg Video not showing, any Idea? – Kalyan Halder Aug 15 '20 at 18:05
I have a very primitive example of doing this in C with Gstreamer. Note, this code is very messy but it should show you what you need to do.
Here is a list of what needs to be done to merge these files:
- Build the list of RTP buffers so that you can iterate over them in the file. There are examples of this in the janus-gateway post processing
- Start iterating over your files at the same time. The timestamps should sync up OK, though I have run into issues where a packet would be lost or corrupted on write which will screw up the merge
- I decode the media and re-encode it here so that I can statically set the framerate and size for the video. I am sure that there is a way to do this without having to transcode the media.
- Multiplex and write to a file
I do step 1 exactly like the janus post processer. Step 2 I push each rtp packet from the files to a gstreamer appsrc element. Steps 3 and 4 are done within the gstreamer pipelines.

- 7,378
- 3
- 31
- 41
sudo apt-get install libavutil-dev libavcodec-dev libavformat-dev
After Installing Dependencies...
./configure --prefix=/opt/janus --enable-post-processing
Then Use this BASH file
#!/bin/bash
# converter.sh
# Declare the binary path of the converter
januspprec_binary=/opt/janus/bin/janus-pp-rec
# Contains the prefix of the recording session of janus e.g
session_prefix="$1"
output_file="$2"
# Create temporary files that will store the individual tracks (audio and video)
tmp_video=/tmp/mjr-$RANDOM.webm
tmp_audio=/tmp/mjr-$RANDOM.opus
echo "Converting mjr files to individual tracks ..."
$januspprec_binary $session_prefix-video.mjr $tmp_video
$januspprec_binary $session_prefix-audio.mjr $tmp_audio
echo "Merging audio track with video ..."
ffmpeg -i $tmp_audio -i $tmp_video -c:v copy -c:a opus -strict experimental $output_file
echo "Done !"
The following command should do the trick:
bash converter.sh ./room-1234-user-0001 ./output_merged_video.webm

- 11
- 1
- 5