Building a PVR project

Discuss Applications
User avatar
Void Main
Site Admin
Site Admin
Posts: 5716
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA

Post by Void Main »

I asked a question the other day (in the wrong section of these forums) about how to stream audio from the FM tuner in my Hauppauge PVR-500 card over http:

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


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"


DATE="`date +%m/%d/%y`"
DATETIME="`date +%Y%m%d-%H%M`"
YEAR="`date +%Y`"

if [ "${FREQ}" = "kshe" ]; then
if [ "${FREQ}" = "fox" ]; then
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}" &
ivtv-radio -d /dev/radio1 -i /dev/video25 -f ${FREQ} -c "sleep ${DURATION}"
kill ${PID}
The show is 4 hours long every day and I want to keep the file size down so I have reduced the bitrate and resampled it to 11k. This only takes up a little over 10MB/hr which. The recording/encoding/vlc streaming processes only consume around 10% of the CPU on the old 800Mhz PC acting as my MythTV machine which can also happily record 3 TV programs at the same time (via 1 PVR-350 and 1 PVR-500). Here is the cron job to record Bob and Tom for 4 hours starting at 5:00am:

Code: Select all

0 5 * * 1-5 /usr/local/bin/radio-record 94.7 "Bob and Tom" 14400 > /tmp/radio-record.log
Now I can stream that file with VLC while it is recording, or stream any of the archived files with this script:

$ cat /usr/local/bin/stream-oggfile

Code: Select all


if [ $# -ne 1 ]; then
   echo "Syntax: stream-oggfile <filename>"

/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}"
Then I just point my Firefox browser (or vlc client) to my myth box http://myth:8001/ to listen to the stream and I can control the stream with http://myth:8002/.


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.

Post Reply