Simple utility to post-process .mjr Recordings saved by Janus.
- Author
- Lorenzo Miniero loren.nosp@m.zo@m.nosp@m.eetec.nosp@m.ho.c.nosp@m.om
- Copyright
- GNU General Public License v3
As explained in the Recordings documentation, our Janus WebRTC server provides a simple helper (janus_recorder) to allow plugins to record audio, video and text frames sent by users. At the time of writing, this helper has been integrated in several plugins in Janus. To keep things simple on the Janus side, though, no processing at all is done in the recording step: this means that the recorder actually only dumps the RTP frames it receives to a file in a structured way, so that they can be post-processed later on to extract playable media files. This utility allows you to process those files, in order to get a working media file you can playout with an external player. The tool will generate a .webm/.mkv if the recording includes VP8 frames, an .opus/.ogg/.mka if the recording includes Opus frames, an .mp4/.mkv if the recording includes H.264/H.265/AV1 frames, and a .wav file if the recording includes G.711 (mu-law or a-law) frames. In case the recording contains text frames as received via data channels, instead, a .srt file will be generated with the text content and the related timing information.
Using the utility is quite simple. Just pass, as arguments to the tool, the path to the .mjr source file you want to post-process, and the path to the destination file, e.g.:
./janus-pp-rec /path/to/source.mjr /path/to/destination.[opus|ogg|mka|wav|webm|mkv|h264|srt]
An attempt to specify an output format that is not compliant with the recording content (e.g., a .webm for H.264 frames) will result in an error since, again, no transcoding is involved.
You can also just print the internal header of the recording, or parse it without processing it (e.g., for debugging), by invoking the tool in a different way:
./janus-pp-rec --json /path/to/source.mjr
./janus-pp-rec --header /path/to/source.mjr
./janus-pp-rec --parse /path/to/source.mjr
For a more complete overview of the available command line settings, launch the tool with no arguments or by passing --help
and it will show something like this:
Usage: janus-pp-rec [OPTIONS] source.mjr
[destination.[opus|ogg|mka|wav|webm|mkv|h264|srt]]
-h, --help Print help and exit
-V, --version Print version and exit
-F, --file-extensions Only print the supported target file extensions
per codec (default=off)
-j, --json Only print JSON header (default=off)
-H, --header Only parse .mjr header (default=off)
-p, --parse Only parse and re-order packets (default=off)
-e, --extended-report Only print extended report (automatically
enables --header) (default=off)
-m, --metadata=metadata Save this metadata string in the target file
-i, --ignore-first=count Number of first packets to ignore when
processing, e.g., in case they're cause of
issues (default=0)
-P, --payload-type=pt Ignore all RTP packets that don't match the
specified payload type (default=none)
-a, --audiolevel-ext=id ID of the audio-levels RTP extension
(default=none)
-v, --videoorient-ext=id ID of the video-orientation RTP extension
(default=none)
-d, --debug-level=1-7 Debug/logging level (0=disable debugging,
7=maximum debug level; default=4)
-D, --debug-timestamps Enable debug/logging timestamps (default=off)
-o, --disable-colors Disable color in the logging (default=off)
-f, --format=STRING Specifies the output format (overrides the
format from the destination) (possible
values="opus", "ogg", "mka", "wav",
"webm", "mkv", "mp4", "srt")
-t, --faststart For mp4 files write the MOOV atom at the head
of the file (default=off)
-S, --audioskew=milliseconds Time threshold to trigger an audio skew
compensation, disabled if 0 (default=0)
-C, --silence-distance=count RTP packets distance used to detect RTP silence
suppression, disabled if 0 (default=0)
-r, --restamp=count If the latency of a packet is bigger than the
`moving_average_latency * (<restamp>/1000)`
the timestamps will be corrected, disabled if
0 (default=0)
-c, --restamp-packets=count Number of packets used for calculating moving
average latency for timestamp correction
(default=10)
-n, --restamp-min-th=milliseconds
Minimum latency of moving average to reach
before starting to correct timestamps.
(default=500)
- Note
- This utility does not do any form of transcoding. It just depacketizes the RTP frames in order to get the payload, and saves the frames in a valid container. Any further post-processing (e.g., muxing audio and video belonging to the same media session in a single .webm file) is up to third-party applications.
Recordings post-processing utility