Mythtv Convert mpg Recorded File to mp3

I have used MythTV for a number of years, having migrated from Freevo, recording Freeview television and radio programmes to watch or listen to.

To listen to radio programmes recorded by MythTV on a smartphone requires a conversion of the recorded .mpg file into a smaller and more transferable .mp3 file.

Mythweb is used to manage the recordings on the media server. Allowing access from any computer in the house. VLC allows the programme to be watched or listened to. It also allows files to be saved locally. Originating as Television video broadcasts MythTV saves the files are as .mpg. To make the file available for use on a smartphone requires a change of format, which fortunately will also reduce the size of the file.

On the main house computer, running Linux, a conversion program runs daily looking within a directory and converting outstanding files. For convenience it runs at a little after 8pm each evening.

The file located in the downloads folder is called mpg2mp3, with the following content:

#!/bin/bash
IFS=
for filename in /home/neil/Music/*.mpg
do
MPGNAME=/home/neil/Music/$( basename "$filename" .mpg ).mpg
MP3NAME=/home/neil/Music/$( basename "$filename" .mpg ).mp3
#echo "MPGNAME: " $MPGNAME
echo "MP3NAME: " $MP3NAME
if [ ! -f $MP3NAME ]
then
ffmpeg -i $MPGNAME -vn -ar 44100 -ac 2 -ab 192 -f mp3 $MP3NAME
fi
done

A line in the /etc/crontab file calls the program each day at 8:15pm.

neil@:~$ cat /etc/crontab
# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# m h dom mon dow user  command
15 20   * * *   neil    /home/neil/Music/mpg2mp3
17 *    * * *   root    cd / && run-parts --report /etc/cron.hourly