#!/bin/sh -x
#---------#---------#---------#---------#---------#---------#---------#---------
#
# title
#   record a BBC AOD (Audio On Demand) stream from realplayer to MP3
# author
#   idc@planetlarg.net 15/10/2007
# description
#   based on BBCsummary.sh
#   I like to record a BBC radio Internet stream. 
#   This captures the realaudio stream, 
#   converts it to a wav file and then to an MP3 file. 
# options
# -nojoystick -nolirc - no joystick or remote control support
# -noframedrop  - don't try to keep realtime by dropping frames. 
#     May only apply to video, I dunno.
# -softsleep   - use a pretend clock, not the rtc (RealTimeClock)
# -prefer-ipv4 - assume the network is IPv4, not IPv6 (eg. for DNS)
# -ao pcm:file=FILE  audio output driver to use. Redirects to file FILE
# -vc          - video codec. Turned off using dummy device null.
# -vo          - video output driver. Turned off.
#
# bugs
#    lame does not return an exit value. 
#    the .wav file is always deleted even if lame fails to create a .mp3. 
#
#---------#---------#---------#---------#---------#---------#---------#---------
# setup
#
date=`date -u "+%y%m%d"`
file="breezeblock-$date"
#
# changed from 
#rtsp://rmv8.bbc.net.uk/radio1/breezeblock.ra 
# to 
#rtsp://rmv8.bbc.net.uk:554/radio1/hobbs.ra
mplayer \
    rtsp://rmv8.bbc.net.uk:554/radio1/hobbs.ra \
    -nojoystick -nolirc -noframedrop \
    -softsleep  -prefer-ipv4 \
    -ao pcm:file=$file.wav   \
    -vc null    -vo null     \
&& \ 
lame \
    -q 2 -V 3  \
    --replaygain-accurate --resample 44.1 \
    --tt "Breezeblock $date" --ta "Mary Anne Hobbs" --tc "BBC Radio 1" \
    --add-id3v2 --pad-id3v2 \
    $file.wav $file.mp3 \
&& \
rm -vf $file.wav
#
#---------#---------#---------#---------#---------#---------#---------#---------


