Convert wav to mp3 records

Hello.
Please help solve the problem.
FreePBX 13. A script is used to convert conversation records from WAV to MP3. The script runs, the files are converted.
The problem appears if you try to listen to the recording through the CDR Report.
Gives an error message:

RuntimeException
/usr/bin/sox formats: can’t open input file /var/spool/asterisk/monitor/2020/04/07/out-89107901515-3316-20200407-182949-1586273387.58.wav': Unhandled WAV file encoding (MP3). Try overriding the encoding: e.g. for an MP3 WAV,-t mp3’
File:/var/www/html/admin/libraries/media/Media/Driver/Drivers/SoxShell.php:194

Conversion script:
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin

YEAR=$1
MONTH=$2
DAY=$3
CALLFILENAME=$4
MIXMON_FORMAT=$5
MIXMON_DIR=$6

if [ -z “${MIXMON_DIR}” ]; then
SPOOLDIR="/var/spool/asterisk/monitor/"
else
SPOOLDIR=${MIXMON_DIR}
fi

FFILENAME=${SPOOLDIR}${YEAR}/${MONTH}/${DAY}/${CALLFILENAME}.${MIXMON_FORMAT}

test ! -e ${FFILENAME} && exit 21

WAVFILE=${FFILENAME}
MP3FILE=echo ${WAVFILE} | sed 's/.wav/.mp3/g'

LOWNICE=“nice -n 19 ionice -c3”

${LOWNICE} lame --quiet --preset phone ${WAVFILE} ${MP3FILE}

test -e ${MP3FILE} && rm -f ${WAVFILE}

${LOWNICE} ffmpeg -loglevel quiet -y -i ${MP3FILE} -f wav -acodec copy ${WAVFILE} >/dev/null 2>&1

test -e ${WAVFILE} && rm -f ${MP3FILE}

It seems as if the wav file was indeed converted to mp3 but the extension was not changed from .wav to .mp3

In any case, don’t expect to play the mp3 file trough the FreePBX gui. The gui is expecting to find the wav file, not the converted mp3 file.

It’s a bit of a pickle here, between Apple Microsoft and Linux, mp3 is not as good a fit as ogg as a ‘container’

OGG) All the above agree about the names and case of the file and what it would contain, also all current browsers also understand how to play them

wav/WAV) some OS’ remain case insensitive so simply the name of a file extension confuses multi-billion dollar companies.

mp3) Not native to asterisk , needs extra libraries, lame mp3123, soxlib-fmt-mp3 blah blah (It works mostly but is a pain)

So most all of us are now using ogg as a general purpose container for audio files native to asterisk when presented to the outside world.

(For Voicemail, and cellphones you might need to add gsm to your generated formats for iphones for the same fails)

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.