Create DVB Channel Playlist
Posted: 29 Jan 2008 01:58
I've created 2 bash scripts that will parse the "channel list" downloaded by the dvbutils "scan" utility and create a playlist for vlc. I wanted to be able to update my channel lists for my DVB-T and DVB-S cards and create playlists for vlc easily.
TO SCAN FOR THE CHANNELS FOR YOUR DVB CARD:
(You can find the instructions for this in many places - I've just included them for completeness)
see the LinuxTV Wiki for details of dvbutils.
install dvbutils (debian):
sudo apt-get install dvb-utils
DVB-T channel scan:
scan -x 0 /usr/share/doc/dvb-utils/examples/scan/dvb-t/uk-Oxford > ~/dvbtchannels.conf
(I use "uk-Oxford" as it's my local terrestrial TV transmitter. IIRC the "-x 0" scans for free channels only)
DVB-S channel scan:
scan -x 0 /usr/share/doc/dvb-utils/examples/scan/dvb-s/Astra-28.2E > ~/dvbschannels.conf
(I use "Astra-28.2E" as this is the satellite my dish is pointed at)
If you have more than one card you'll need to set the adaptor number (with a "-a" argument) to scan with the second card, for example:
scan -a 1 -x 0 /usr/share/doc/dvb-utils/examples/scan/dvb-s/Astra-28.2E > ~/dvbschannels.conf
CREATING THE PLAYLISTS
once you have dvbtchannels.conf and/or dvbschannels.conf use the bash scripts below to create playlists:
DVBT
DVBS
Any comments are welcome.
TO SCAN FOR THE CHANNELS FOR YOUR DVB CARD:
(You can find the instructions for this in many places - I've just included them for completeness)
see the LinuxTV Wiki for details of dvbutils.
install dvbutils (debian):
sudo apt-get install dvb-utils
DVB-T channel scan:
scan -x 0 /usr/share/doc/dvb-utils/examples/scan/dvb-t/uk-Oxford > ~/dvbtchannels.conf
(I use "uk-Oxford" as it's my local terrestrial TV transmitter. IIRC the "-x 0" scans for free channels only)
DVB-S channel scan:
scan -x 0 /usr/share/doc/dvb-utils/examples/scan/dvb-s/Astra-28.2E > ~/dvbschannels.conf
(I use "Astra-28.2E" as this is the satellite my dish is pointed at)
If you have more than one card you'll need to set the adaptor number (with a "-a" argument) to scan with the second card, for example:
scan -a 1 -x 0 /usr/share/doc/dvb-utils/examples/scan/dvb-s/Astra-28.2E > ~/dvbschannels.conf
CREATING THE PLAYLISTS
once you have dvbtchannels.conf and/or dvbschannels.conf use the bash scripts below to create playlists:
DVBT
Code: Select all
#!/bin/bash
PLAYLIST=~/DVB-T_playlist.m3u
SOURCEFILE=~/dvbtchannels.conf
# Place header in playlist file
echo "#EXTM3U" > $PLAYLIST
# Read the dvbutils channel file
echo "please wait whilst $SOURCEFILE is parsed"
cat $SOURCEFILE | while read LINE
# Parse the channel name, frequency, symbol rate and service ID
do
CHANNELNAME=$(echo "$LINE" | sed 's/\:.*$//')
CHANNELFREQ=$(echo $LINE | sed 's/\:/+/1' | sed 's/.*+//' | sed 's/\:.*//')
CHANNELSERVICEID=$(echo "$LINE" | sed 's/^.*\://')
# echo the channel information into the correctly formatted playlist
echo "#EXTINF:0,$CHANNELNAME" >> $PLAYLIST
echo "#EXTVLCOPT:dvb-adapter=1" >> $PLAYLIST
echo "#EXTVLCOPT:dvb-frequency=$CHANNELFREQ" >> $PLAYLIST
echo "#EXTVLCOPT:program=$CHANNELSERVICEID" >> $PLAYLIST
echo "#EXTVLCOPT:dvb-bandwidth=8" >> $PLAYLIST
echo "dvb://" >> $PLAYLIST
done
echo "$PLAYLIST created"
echo "to play type:"
echo "vlc $PLAYLIST"
Code: Select all
#!/bin/bash
PLAYLIST=~/DVB-S_playlist.m3u
SOURCEFILE=~/dvbschannels.conf
# Place header in playlist file
echo "#EXTM3U" > $PLAYLIST
# Read the dvbutils channel file
echo "please wait whilst $SOURCEFILE is parsed"
cat $SOURCEFILE | while read LINE
# Parse the channel name, frequency, symbol rate and service ID
do
CHANNELNAME=$(echo "$LINE" | sed 's/\:.*$//')
CHANNELFREQ=$(echo $LINE | sed 's/\:/+/1' | sed 's/.*+//' | sed 's/\:.*//' | sed 's/$/000/')
CHANNELSYMBRATE=$(echo $LINE | sed 's/\:/+/4' | sed 's/.*+//' | sed 's/\:.*//' | sed 's/$/000/')
CHANNELSERVICEID=$(echo "$LINE" | sed 's/^.*\://')
# echo the channel information into the correctly formatted playlist
echo "#EXTINF:0,$CHANNELNAME" >> $PLAYLIST
echo "#EXTVLCOPT:dvb-adapter=0" >> $PLAYLIST
echo "#EXTVLCOPT:dvb-frequency=$CHANNELFREQ" >> $PLAYLIST
echo "#EXTVLCOPT:dvb-srate=$CHANNELSYMBRATE" >> $PLAYLIST
echo "#EXTVLCOPT:program=$CHANNELSERVICEID" >> $PLAYLIST
echo "dvb://" >> $PLAYLIST
done
echo "$PLAYLIST created"
echo "to play type:"
echo "vlc $PLAYLIST"