Has anyone gotten Call recording to save in MP3 instead of wav?

I used Chatgpt to get a script to use lame to change the recording to MP3 and it worked for about a half dozen calls and thenit stopped working. I have the sh file in /usr/local/bin with asterisk as the owner (originally had root as owner) There is no error in any log that I can find. Call recording module is 15.0.7.29. Here is the script.

#!/bin/bash

# This script converts WAV recordings to MP3 and deletes the original WAV file

# Get the full path of the recording from FreePBX
REC_FILE=$1

# Check if the file exists
if [ -f "$REC_FILE" ]; then
    # Extract the directory, filename, and extension
    DIR=$(dirname "$REC_FILE")
    BASE=$(basename "$REC_FILE" .wav)

    # Convert to MP3 using lame
    lame "$REC_FILE" "${DIR}/${BASE}.mp3"

    # Check if the conversion was successful
    if [ $? -eq 0 ]; then
        # Remove the original WAV file
        rm "$REC_FILE"
    else
        echo "Conversion failed for $REC_FILE" >> /var/log/convert_to_mp3.log
    fi
else
    echo "File $REC_FILE does not exist" >> /var/log/convert_to_mp3.log
fi

Also there is a new Custom Destination

custom-recording,s,1

Any idea why it would just quit?

Thanks

run it manually with sudo -u root

Add debugging to the script

ChatGPT will do this for you too… ask it to add debugging and ways to help you figure out why it isn’t working.

Here is an old but possibly relevant discussion on doing this task. Reading through may give you some insights on the magic.

Thanks James

Could you change the script and check whether recording has completed before doing any conversion ?
Is the wav file more than xx minutes old ? If no, then leave it alone.
YMMV

It should be done in the ‘POST call recording script’ :wink:

1 Like