[mythtv-users] FM radio support for mythbackend [hack]
Andrew M. Bishop
amb at gedanken.demon.co.uk
Sun Jun 11 16:29:09 UTC 2006
I have worked out a method of adding FM radio support to mythbackend
that doesn't require any changes to the source code. It may seem to
be an ugly hack but actually it works well (for me).
The trick is to use the external channel change script to trigger the
tuning of the radio device and set the video device to the composite
input with nothing connected.
I have two Hauppauge WinTV analogue cards with built-in FM tuner and I
have configured the second one to use for FM radio. This is what I
did to configure everything:
1) In mythtv-setup under "Video Sources" I set up a new video source
which I called "radio". When asked for an XMLTV grabber I chose
the normal one although this doesn't have any radio data.
2) In mythtv-setup under "Input Connections" I selected the second card
(/dev/video1) Composite1 input. I selected "radio" as video source
and entered "/home/mythtv/bin/mythtv-fm.sh" as the external channel
change command (script provided later).
3) In mythtv-setup under "Channel Editor" I entered my radio stations,
making sure to select "radio" as the video source and choosing my
local TV format. For the channel number I selected a number that
was 10 times the frequency in MHz of the channel and entered a made
up xmltv ID even though there is no XMLTV grabber.
On the second page I entered the same number for the frequency ID
as I had for the channel number (see script for why).
4) I created the following script and saved it as
/home/mythtv/bin/mythtv-fm.sh
-------------------- mythtv-fm.sh --------------------
#!/bin/sh -x
channel=$1
radio=/dev/radio1
int=$(($channel / 10))
frac=$(($channel - 10 * $int))
freq=`printf "%d.%d" $int $frac`
( sleep 10 ; radio -c $radio -f $freq -q ) &
exit 0
-------------------- mythtv-fm.sh --------------------
The important parts about the script are that the radio device is
specified (in my case /dev/radio1) and the frequency (in MHz) can
be determined by dividing the command line argument by 10. The
trick to making this work is the delay of 10 seconds after the
script is run before tuning the radio (using the 'radio' program
from xawtv). If this isn't done then MythTV will tune the TV tuner
after the script and you capture TV sound instead. If the delay
was 5 seconds I still had this problem.
5) Connect the FM aerial to the correct device (the second one for me)
and disconnect the composite input. It is important that there is
no composite input or else you will capture video with your radio
audio.
What happens when you select a radio channel is that the channel
change script gets called and returns OK. MythTV sets up the video
device input to Composite1 and the audio to go with it and starts
recording. When the delayed part of the script executes a few seconds
later the radio is tuned to the correct FM station and the audio mixer
on the card automatically selects it. While recording you get FM
radio audio and a solid unchanging blue screen as video. The video
gets compressed to almost nothing and the total comes in at about 1 MB
per minute with my default settings.
It works well for scheduled recordings, but less well (although it
still does work) for LiveTV mode. Due to the delay the first few
seconds of the recording are wrong, but just a little static or
nothing.
--
Andrew.
----------------------------------------------------------------------
Andrew M. Bishop amb at gedanken.demon.co.uk
http://www.gedanken.demon.co.uk/
More information about the mythtv-users
mailing list