An updated version of our script to bulk convert wav call recordings to mp3 as mentioned here.

This version may be redistributed freely, as long as the copyright message remains.

# A Script to Convert FreePBX call recordings from WAV to MP3
# Also updates the CDR database, for correct downloads through the web UI
# Version 2 - 2016/04/15
# Changelog
# v2 - Skip broken files (but show an error message)
# v1 - Initial version
# Copyright Jaytag Computer Limited 2016 -
# You may use or modify this script as you wish as long as this copyright
# message remains. Redistribution is permitted.

# Set the Asterisk Recording Directory

# Start the Loop
for wavfile in `find $recorddir -name \*.wav`; do

# Make Variables from the WAV file names
wavfilenopath="$(echo $wavfile | sed 's/.*\///')"
mp3file="$(echo $wavfile | sed s/".wav"/".mp3″/)"
mp3filenopath="$(echo $mp3file | sed 's/.*\///')"

# Convert the WAV files to MP3, exit with an error message if the conversion fails
nice lame -b 16 -m m -q 9-resample "$wavfile" "$mp3file" && rm -frv $wavfile || echo "$wavfile encoding failed"

# Update the CDR Database, only if conversion is sucessful
if [ -e "$mp3file" ] then
mysql -u root -s -N -D asteriskcdrdb<<<"UPDATE cdr SET recordingfile='$mp3filenopath' WHERE recordingfile = '$wavfilenopath'"
echo "DBUPDATE ——————————————————-"
echo "DBUPDATE – $wavfilenopath changed to $mp3filenopath in CDR DB"
echo "DBUPDATE ——————————————————-"

# On-Screen display of variables for debugging/logging
# echo ""
# echo "File ——————————————————-"
# echo "Wav File : " $wavfile
# echo "Wav No Path : " $wavfilenopath
# echo "MP3 File : " $mp3file
# echo "MP3 No Path : " $mp3filenopath
# echo "End File —————————————————"
# echo ""

# End the Loop

Previous Post Next Post