AllStarLink Recording Script

Here are some details on setting up an automated recording system for AllStar Link nodes. The ground work for this has been done in app_rpt, but this script will assist in publishing the recordings making them more accessible.

The original script was from Joshua Nolton (KG5EBI) – Self Proclaimed Engineer on youtube.

Joshua’s post is here: https://dvswitch.groups.io/g/allstarlink/topic/recording_your_qso_s_as_an/32389801

I have modified his script to not cut off any currently recording transmissions and also to sort the recordings in to day, month and year.

The script can be added to cron to automate everything.

Firstly watch and follow the instructions in the above video, using the modified script below instead. Note that my script location and name may be different to the ones used in the video and you also need to install lsof.

You need to do the following:

  • enable recording in rpt.conf
  • create the script using the code below and put it in a suitable location – I just use /var/log/asterisk/recording/encodepost.sh as the location and name.
  • change the script file to allow it to execute (chmod u+x)

You will need to install the following:

  • apache2 – to serve up the files.
  • lsof – for checking if a recording is being accessed.
  • ffmpeg – for conversion of the audio files to mp3 to save space.
  • rsync – for copying the files around.

Bash Script:

#!/bin/bash

#This script can be safely added to cron to run every minute. It will not copy and convert the currently recording file as it checks to see if each .WAV is in use by using lsof.

#Required programs:
#lsof, rsync, ffmpeg. i.e. run "apt install lsof rsync ffmpeg"


#Set your node number here:
node=42688

cd /var/log/asterisk/recording/$node
for i in *.WAV;
        do name=`echo "$i" | cut -d'.' -f1`
        echo "$name"
                if [ -z "$(lsof "$name".WAV)" ]
                        then
                                ffmpeg -i "$i" -codec:a libmp3lame -filter:a loudnorm -qscale:a 2 "${name}.mp3"
                                mkdir -p "/var/www/html/library/`date -d now +%Y`/`date -d now +%m - %B`/`date -d now +%d - %A`"
                                rsync -avP ./"$name".mp3 "/var/www/html/library/`date -d now +%Y`/`date -d now +%m - %B`/`date -d now +%d - %A`"
                                rm ./"$name".*
                                rm *.txt
                        else
                                sleep 1
                fi

done

Your root crontab can have the following added to automate the whole process. Of course change the script location and name as required. This will run the script every minute.

* * * * * /var/log/asterisk/recording/encodepost.sh 

Leave a Reply

Your email address will not be published. Required fields are marked *