Name

extractaudio — convert RTP session recordings made by rtpproxy into audio files

Synopsis

extractaudio [-idsne] [-F file_fmt] [-D data_fmt] [-r rate] [ -b kbps | -C level ] recname outfile [link...]

extractaudio [-idsne] [-F file_fmt] [-D data_fmt] [-r rate] [ -b kbps | -C level ] [-A answer_cap] [-B originate_cap] [--alice-crypto cspec] [--bob-crypto cspec] outfile [link...]

extractaudio -S recname

extractaudio -S [-A answer_cap] [-B originate_cap]

DESCRIPTION

extractaudio reads RTP streams recorded by rtpproxy(8), decodes them and writes the resulting audio into outfile using the libsndfile library.

A call is recorded by rtpproxy as two captures, one per direction: recname.a.rtp for the answering side and recname.o.rtp for the originating side, where recname is rec_dir/call_id=tag. In the first form, extractaudio takes recname and loads both captures. In the second form, the captures are given explicitly with the -A and/or -B options, which also allows processing of just one side, or of captures with arbitrary names. RTCP captures (.rtcp) are not used.

Both the native rtpproxy recording format and the pcap format (as produced by rtpproxy -P) are supported; the format is detected automatically. Pcap files must be in version 2.4 format, with the Ethernet or BSD loopback link type. A single-file pcap recording containing both directions can be given with -A, in which case all of it is treated as coming from the answering side.

Each SSRC found in a capture is decoded as a separate stream. Streams are aligned using the packet arrival times: gaps in the received audio are filled with silence, and RTP timestamps that run off the arrival times by more than a second are re-synchronized. Streams of the same side are mixed together. In mono output (the default) both sides are then mixed together as well, in stereo output (-s) the answering side goes into the first (left) channel and the originating side into the second (right) one.

The following payload types are decoded:

  • G.711 u-law (0) and A-law (8);

  • GSM 06.10 (3), G.722 (9) and G.729 (18), if the respective codec support has been compiled in;

  • comfort noise (13) and telephone events (100, 101) are played out as silence.

Statistics of each stream (packet counts, losses, duplicates, jitter) and, when done, the number of samples decoded for each side and written into the output file are reported on the standard error.

OPTIONS

-A answer_cap

Load the answering side capture from answer_cap.

-B originate_cap

Load the originating side capture from originate_cap.

--alice-crypto cspec, --bob-crypto cspec

Decrypt SRTP in the answering (--alice-crypto) or the originating (--bob-crypto) side capture. cspec has the form suite:key, where key is the base64-encoded master key and salt, as in the inline: parameter of the SDP a=crypto attribute. The supported suites are AES_CM_128_HMAC_SHA1_32, AES_CM_128_HMAC_SHA1_80, AES_192_CM_HMAC_SHA1_32, AES_192_CM_HMAC_SHA1_80, AES_256_CM_HMAC_SHA1_32 and AES_256_CM_HMAC_SHA1_80, plus AEAD_AES_128_GCM, AEAD_AES_128_GCM_8, AEAD_AES_256_GCM and AEAD_AES_256_GCM_8 when built with libsrtp2. Suite names are case-insensitive. Packets that fail to decrypt are skipped. These options are only available if SRTP support has been compiled in.

-b kbps

Opus bitrate in kbit/s, from 6 to 256 per channel. Requires -D opus. Mutually exclusive with -C.

-C level

Compression level, from 0.0 (lowest compression, best quality) to 1.0 (highest compression), for the output formats that support it, such as FLAC, Vorbis and Opus. It is an error to specify it for a format that does not. Mutually exclusive with -b.

-D data_fmt

Output data format (encoding), one of pcm_s8, pcm_16, pcm_24, pcm_32, pcm_u8, float, double, ulaw, alaw, ima_adpcm, ms_adpcm, gsm610, vox_adpcm, g721_32, g723_24, g723_40, dwvw_12, dwvw_16, dwvw_24, dwvw_n, dpcm_8, dpcm_16, vorbis or opus. The default is gsm610 for mono 8 kHz output and ms_adpcm otherwise. gsm610, g721_32, g723_24 and g723_40 only support 8 kHz. Not every data format can be used with every file format, see the libsndfile documentation.

-d

Delete the input captures when done.

-e

Fail if any of the input captures cannot be loaded. By default it is enough for one of them to be loaded successfully.

-F file_fmt

Output file format, one of wav (default), aiff, au, raw, paf, svx, nist, voc, ircam, w64, mat4, mat5, pvf, xi, htk, sds, avr, wavex, sd2, flac, caf, wve, ogg, mpc2k or rf64.

Format names are case-insensitive for both -F and -D; an unknown name makes extractaudio print the list of supported ones. The FLAC, Ogg, Vorbis and Opus formats are only available if libsndfile has been built with support for them.

-i

Run at idle priority.

-n

Do not synchronize streams: gaps in the received audio are not filled with silence, so the audio of each stream is played out back to back.

-r rate

Output sample rate, either 8000 (default) or 16000. At 16 kHz, G.722 is decoded at its native rate, while narrowband codecs are upsampled, so that streams using different codecs stay aligned in one file.

-S

Scan only: for each of the captures, print its name followed by the number of RTP packets in it (-1 if it cannot be read), and exit without producing any output file.

-s

Produce stereo output, with the answering side in the first channel and the originating side in the second.

link

Additional names to hard link outfile to once it has been written.

EXIT STATUS

extractaudio exits 0 on success, 2 if the output file cannot be created, and 1 on any other error.

EXAMPLES

Convert a recording into a mono WAV file:

extractaudio /var/spool/rtpproxy/call1=tag1 call1.wav

Convert a recording into a stereo 16 kHz Opus file at 64 kbit/s:

extractaudio -s -r 16000 -F ogg -D opus -b 64 \
    /var/spool/rtpproxy/call1=tag1 call1.opus

Convert SRTP pcap captures of both sides:

extractaudio -A call1.a.pcap -B call1.o.pcap \
    --alice-crypto AES_CM_128_HMAC_SHA1_80:base64_key \
    --bob-crypto AES_CM_128_HMAC_SHA1_80:base64_key \
    call1.wav

Count the packets recorded for each side:

extractaudio -S /var/spool/rtpproxy/call1=tag1

SEE ALSO

rtpproxy(8), makeann(1)

LICENSE

All components of the rtpproxy are licensed under the BSD 2-Clause License. See LICENSE file in the top of source tree for details.

AVAILABILITY

The latest version of this program and its components can be found at http://www.rtpproxy.org/.