http://forum.videolan.org/viewtopic.php?t=34320
There is a program that I enjoy listening to on the FM radio but I only can catch a little bit of it on my drive to work in the morning. So now I have a cron job set up to record it every day and another script I can execute to stream the file over http using VLC if I should want to listen to the show over a stream as it is recording, or listen to a previous show I may have missed.
Basically here is the script to record the audio and save it in a low quality ogg file:
$ cat /usr/local/bin/radio-record
Code: Select all
#!/bin/bash
if [ $# -ne 3 ]; then
echo "Syntax: radio-record <freq> <prefix> <seconds>"
echo "Example: radio-record 94.7 \"Bob and Tom\" 14400"
echo "Example: radio-record fox Glover 7200"
exit
fi
FREQ=$1;
PREFIX=$2;
DURATION=$3;
DATE="`date +%m/%d/%y`"
FULLDATE="`date`"
DATETIME="`date +%Y%m%d-%H%M`"
YEAR="`date +%Y`"
if [ "${FREQ}" = "kshe" ]; then
FREQ="94.7"
fi
if [ "${FREQ}" = "fox" ]; then
FREQ="97.1"
fi
FILE="/backup/radio/${PREFIX}_${DATETIME}.ogg"
echo "Recording to ${FILE}"
cat /dev/video25 | sox -t raw -r 48000 -w -s -c2 /dev/stdin -t wav - | oggenc --resample 11025 - -b 8 -q 0 -a "${PREFIX}" -G "Other" -t "${PREFIX} - ${DATE}" -c "=${FREQ} FM on ${FULLDATE}" -o "${FILE}" &
PID=$!
ivtv-radio -d /dev/radio1 -i /dev/video25 -f ${FREQ} -c "sleep ${DURATION}"
kill ${PID}
Code: Select all
0 5 * * 1-5 /usr/local/bin/radio-record 94.7 "Bob and Tom" 14400 > /tmp/radio-record.log
$ cat /usr/local/bin/stream-oggfile
Code: Select all
#!/bin/bash
if [ $# -ne 1 ]; then
echo "Syntax: stream-oggfile <filename>"
exit
fi
/usr/bin/vlc "$1" -I http --http-host=:8002 ":sout=#standard{access=http{user=$HTTP_USER,pwd=$HTTP_PWD,mime=application/ogg},mux=ogg,url=:8001}"
Screenshot:
http://voidmain.is-a-geek.net/i/vlc.png
I set up an ssh tunnel from work into my Myth box so I can listen to the parts of the show I missed on the drive in. :)
Maybe this will help someone else. Or maybe someone will give me some advice on a much easier/better way to do what I am doing.