Skip to content

Latest commit

 

History

History
369 lines (291 loc) · 13 KB

recording.md

File metadata and controls

369 lines (291 loc) · 13 KB

Recording

As stated on the RAAR Import Recordings section, RAAR is not responsible for the actual recording of the audio files. It simply assumes that recordings are placed within directories defined by IMPORT_DIRECTORIES waiting for the RAAR Importer to pick them up.

But don't panic :-) we've got you covered in case you don't have your own recording solution already in place.

The following sections describes a recording solution based on JACK, Rotter and some systemd service units, which plays nicely together with RAAR.

Overview

Rotter is a Recording of Transmission / Audio Logger for JACK. It captures audio from jackd, encodes it in a specified format and creates a new recording file every hour by default. This makes it ideal to use together with RAAR.

In the following deployment walk-through rotter will be configured to capture the audio from the first two JACK input ports found, while storing the recordings into the /var/lib/rotter/raar directory in the lossless FLAC format. A separate recording-handler will move the finished recordings from the /var/lib/rotter/raar directory to a final RAAR import directory. Of course, the JACK configuration, audio codec and directory locations can be customized to meet the requirements of your environment.

Also note, that the deployment was tested on CentOS 7, but should work on other distributions as well (with some minor modifications).

Deployment

Deployment on CentOS 7 systems

There are pre-built binary packages for CentOS 7 available from Fedora EPEL (jack) and RaBe APEL (rotter), which can be installed as follows:

# Add Fedora EPEL repository
yum install epel-release

# Add RaBe APEL repository
curl -o /etc/yum.repos.d/home:radiorabe:audio.repo \
     http://download.opensuse.org/repositories/home:/radiorabe:/audio/CentOS_7/home:radiorabe:audio.repo
 
# Install rotter (which will also install "jack-audio-connection-kit" and
# "jack-audio-connection-kit-example-clients")
yum install rotter

Install the raar jackd systemd service instance override:

# Install the jackd@raar service instance unit override
mkdir "/etc/systemd/system/jackd@raar.service.d"
wget -O "/etc/systemd/system/jackd@raar.service.d/override.conf" \
     https://raw.githubusercontent.com/radiorabe/raar/master/config/systemd/jackd%40raar.service.d/override.conf 

# You might need to adapt the jackd service instance unit override to suite
# your environment
vi /etc/systemd/system/jackd@raar.service.d/override.conf

# Reload systemd manager configuration
systemctl daemon-reload

Install the raar rotter systemd service instance override:

# Install the rotter@raar service instance unit override
mkdir "/etc/systemd/system/rotter@raar.service.d"
wget -O "/etc/systemd/system/rotter@raar.service.d/override.conf" \
     https://raw.githubusercontent.com/radiorabe/raar/master/config/systemd/rotter%40raar.service.d/override.conf 

# You might need to adapt the rotter service instance unit override to suite
# your environment
vi /etc/systemd/system/rotter@raar.service.d/override.conf

# Reload systemd manager configuration
systemctl daemon-reload

You can now enable and start the raar@rotter.service instance, which will also trigger the start of the raar@jackd.service instance.

# Enable and start the service unit instance
systemctl enable raar@rotter.service
systemctl start raar@rotter.service

# Check the status
systemctl status raar@rotter.service
systemctl status raar@jackd.service

# In case of problems, inspect the systemd journal
journalctl -u raar@rotter.service
journalctl -u raar@jackd.service

The recordings should appear in the /var/lib/rotter/raar directory.

As a final step, install the RAAR Record Handler.

Deployment on other distributions

Dedicated system user for recording

First, a dedicated system user and group will be created under which all involved processes will run. The user and group is named rotter (you might need to adapt the supplementary groups, audio and jackuser, to match with your distribution).

# Create a dedicated audio recording user which belongs to the audio and
# jackuser groups. The later is required in order to gain real-time priority
# see also /etc/security/limits.d/95-jack.conf
useradd --comment "rotter system user" \
        --home-dir "/var/lib/rotter" \
        --create-home \
        --groups audio,jackuser \
        --password '*' \
        --system \
        --shell /sbin/nologin \
        --user-group \
        rotter

ALSA device configuration and testing

In case you want to use an ALSA device (such as an USB or PCI audio interface, or a virtual AoIP device) as your jackd backend, you have to configure it beforehand. Afterwards test that you're able to record from its capture device, with the help of arecord:

# Capture 10 seconds via arecord directly from the first ALSA device as the
# rotter user
su -l -s /bin/bash \
   -c 'arecord -D hw:0 -c 2 -d 10 -r 48000 -f S32_LE -v /tmp/test-arecord.wav' \
   rotter

Keep in mind, that you will have to change the jack configuration later on, if your device isn't available as hw:0 (refer to arecord -L). Also note, that you might have to adapt the sample format -f ... option according to your device's capabilities (refer to arecord -D hw:0 --dump-hw-params).

If the recorded test file can be played as expected, continue with the next section.

Jack

Install jackd (jack2) and the helper tools (example-clients) from the packages provided by your distribution or compile it from source (jack2 releases).

Allow headless operation of jackd by allowing users of the rotter group to own the first audio device service (you might have to adapt org.freedesktop.ReserveDevice1.Audio0 according to your device):

wget -O /etc/dbus-1/system.d/rotter.conf \
     https://raw.githubusercontent.com/radiorabe/centos-rpm-rotter/master/dbus-rotter.conf

# Reload the D-Bus configuration
systemctl reload dbus

Install the jackd systemd service unit template and raar jackd systemd service instance override:

# Install the jackd system service unit template
wget -O "/etc/systemd/system/jackd@.service" \
     https://raw.githubusercontent.com/radiorabe/centos-rpm-rotter/master/jackd%40.service

# Install the jackd@raar service instance unit override
mkdir "/etc/systemd/system/jackd@raar.service.d"
wget -O "/etc/systemd/system/jackd@raar.service.d/override.conf" \
     https://raw.githubusercontent.com/radiorabe/raar/master/config/systemd/jackd%40raar.service.d/override.conf 

# You might need to adapt the jackd service instance unit override to suite
# your environment
vi /etc/systemd/system/jackd@raar.service.d/override.conf

# Reload systemd manager configuration
systemctl daemon-reload

Rotter

Install rotter from the packages provided by your distribution or compile it from source.

Install the rotter systemd service unit template and raar rotter systemd service instance override:

# Install the rotter system service unit template
wget -O "/etc/systemd/system/rotter@.service" \
     https://raw.githubusercontent.com/radiorabe/centos-rpm-rotter/master/rotter%40.service

# Install the rotter@raar service instance unit override
mkdir "/etc/systemd/system/rotter@raar.service.d"
wget -O "/etc/systemd/system/rotter@raar.service.d/override.conf" \
     https://raw.githubusercontent.com/radiorabe/raar/master/config/systemd/rotter%40raar.service.d/override.conf 

# You might need to adapt the rotter service instance unit override to suite
# your environment
vi /etc/systemd/system/rotter@raar.service.d/override.conf

# Reload systemd manager configuration
systemctl daemon-reload

You can now enable and start the raar@rotter.service instance, which will also trigger the start of the raar@jackd.service instance.

# Enable and start the service unit instance
systemctl enable raar@rotter.service
systemctl start raar@rotter.service

# Check the status
systemctl status raar@rotter.service
systemctl status raar@jackd.service

# In case of problems, inspect the systemd journal
journalctl -u raar@rotter.service
journalctl -u raar@jackd.service

The recordings should appear in the /var/lib/rotter/raar directory:

ls -la /var/lib/rotter/raar
total 717844
drwxr-xr-x. 2 rotter rotter      4096 Feb  6 16:59 .
drwxr-xr-x. 3 rotter rotter        17 Feb  6 15:45 ..
-rw-r--r--. 1 rotter rotter 120309610 Feb  6 16:00 2018-02-06T154512+0100_60.flac
-rw-r--r--. 1 rotter rotter 230000737 Feb  6 16:28 2018-02-06T160000+0100_60.flac
-rw-r--r--. 1 rotter rotter 250600686 Feb  6 16:59 2018-02-06T162851+0100_60.flac
-rw-r--r--. 1 rotter rotter 127717296 Feb  6 17:16 2018-02-06T170000+0100_60.flac

RAAR Record Handler

The RAAR Record Handler will move the finished recordings from the /var/lib/rotter/raar directory to a final RAAR import directory (IMPORT_DIRECTORIES) for the RAAR Importer to pick them up.

Install the RAAR Record Handler and its corresponding systemd service unit (raar-record-handler.service):

wget -O /usr/local/bin/raar-record-handler.sh \
     https://raw.githubusercontent.com/radiorabe/raar/master/bin/raar-record-handler.sh

chmod 755 /usr/local/bin/raar-record-handler.sh


wget -O /etc/systemd/system/raar-record-handler.service \
     https://raw.githubusercontent.com/radiorabe/raar/master/config/systemd/raar-record-handler.service


wget -O /etc/tmpfiles.d/rotter-raar.conf \
     https://raw.githubusercontent.com/radiorabe/raar/master/config/systemd/tmpfiles.d/rotter-raar.conf

You might want to adapt the destination directory, which defaults to /var/tmp/raar/import (this must match with a directory from IMPORT_DIRECTORIES of the RAAR importer):

systemctl edit raar-record-handler.service
[Service]
# Use a different destination directory
Environment="RAAR_RECORD_HANDLER_DEST_DIR="/path/to/my/raar-import/dir"

Make sure the rotter user has read/write access to the destination directory:

# Adapt to your import directory
chown rotter:rotter /var/tmp/raar/import

Enable and start the raar-record-handler.service:

# Enable and start the service unit
systemctl enable raar-record-handler.service
systemctl start raar-record-handler.service

# Check the status and logs
systemctl status raar-record-handler.service
journalctl -u raar-record-handler.service

At every hour, the service should move the finished recordings to /var/tmp/raar/import (or whatever directory you have configured).

Troubleshooting

The following commands and logs might be helpful for troubleshooting.

ALSA:

  • List all audio devices

    arecord -l

  • List all PCMs

    arecord -L

  • Dump the capabilities of a device

    arecord -D <device> --dump-hw-params

  • List hardware parameters of an active capture device

cat /proc/asound/card0/pcm0c/sub0/hw_params

Jackd:

  • List Jack ports

    su -l -s /bin/bash -c "jack_lsp -s raar -c -p" rotter

  • Status of the jackd@raar.service systemd service instance unit

    systemctl status jackd@raar.service

  • Systemd journal of jackd@raar.service

    journalctl -u jackd@raar.service
    journalctl -u jackd@raar.service -f

Rotter:

  • Status of the rotter@raar.service systemd service instance unit

    systemctl status rotter@raar.service

  • Systemd journal of rotter@raar.service

    journalctl -u rotter@raar.service
    journalctl -u rotter@raar.service -f

RAAR Record Handler:

  • Status of the raar-record-handler.service systemd service unit

    systemctl status raar-record-handler.service

  • Systemd journal of raar-record-handler.service

    journalctl -u raar-record-handler.service
    journalctl -u raar-record-handler.service -f

Links