This I use to generate a modified channels configuration file for mplayer, so that channels can be selected by number rather than by name in mplayer.
#!/bin/bash # This script scans the DVB-T frequencies and puts # them into Freeview channel ordering, # for easy selection from the console by number such as “mplayer dvb://700” for Radio 1 # change the WHERE line to point to tuning data for your location WHERE=/usr/share/doc/dvb-utils/examples/scan/dvb-t/uk-SuttonColdfield RAW=~/.mplayer/freeview.raw MAP=~/.mplayer/freeview.map OUT=~/.mplayer/channels.conf.ter scan -u ${WHERE} > ${RAW} scan -q -o vdr -e 4 -u ${WHERE} > ${MAP} N=0 IFS=$';' while read LINE EXTRA do if test "${LINE:0:2}" = ":@" then PROGNUM="${LINE}" else if test -n "${PROGNUM}" then C[${N}]="${PROGNUM:2}" P[${N}]="${LINE}" N=$((${N}+1)) PROGNUM="" fi fi done < ${MAP} while IFS=: && read CHAN FREQ INVER REST do IFS=: N=0 for W in ${P[*]} do IFS= if [ "${CHAN}" = "${W}" ] then PROG=${C[${N}]} SO[${PROG}]=${PROG}$':'${FREQ}$':'${CHAN}$':'${REST} fi N=$((${N}+1)) done done < ${RAW} IFS= for N in ${SO[*]} do echo ${N} done > ${OUT}
It is possible to stream DVB to mp2 or mpeg
#!/bin/bash # dvbstream and ts_filter are in package dvbstream # dvb-mpegtools compiled as dvb-mpegtools_main is in the source of package libdvb-dev (and have to compile it) # chrt is in schedutils (and needs realtime-lsm) # tee is in coreutils # madplay is in madplay # aplay in in alsa-utils LINE=$(grep $'^'"${1}" ~/.mplayer/channels.conf.ter) FREQUENCY=$(cut -d":" -f2 <<<"${LINE}") VIDEOPID=$(cut -d":" -f11 <<<"${LINE}") AUDIOPID=$(cut -d":" -f12 <<<"${LINE}") if test "${VIDEOPID}" != "0" then chrt -r 1 dvbstream -f "${FREQUENCY}" "${VIDEOPID}" "${AUDIOPID}" -o | \ chrt -r 1 ts_filter "${VIDEOPID}" "${AUDIOPID}" | \ chrt -r 1 dvb-mpegtools ts2ps "${VIDEOPID}" "${AUDIOPID}" | \ chrt -r 1 tee /tmp/$(date +%Y%m%d%H%M%S).mpeg | chrt -r 1 mplayer - else chrt -r 1 dvbstream -f "${FREQUENCY}" "${AUDIOPID}" -o | \ chrt -r 1 ts_filter "${AUDIOPID}" | \ chrt -r 1 dvb-mpegtools ts2es "${AUDIOPID}" | \ chrt -r 1 tee /tmp/$(date +%Y%m%d%H%M%S).mp2 | \ chrt -r 1 madplay - -b 32 -o wave:- -R 48000 | \ chrt -r 1 aplay - fi
It is also possible to accept a stream from a videolan VLC instance over multicast.
Put #duplicate{dst=std{access=rtp,mux=ts,dst=239.255.0.0:5004}} in the default stream output chain in stream output in vlc preferences.
The newer #rtp{dst=239.255.0.0,port=5004,mux=ts,proto=udp,ttl=2} has the same effect
If you want to cross multiple networks, such as cabled to wlan, use a ttl of more than 1 on vlc and use a multicast forwarder like smcroute on each computer interconnecting the networks. Example: smcroute -a eth0 192.0.2.0 239.255.0.0 wlan0 goes in /etc/smcroute/startup.sh.
chrt -r 1 dumprtp 239.255.0.0 5004 | \ chrt -r 1 ts_filter 68 | \ chrt -r 1 dvb-mpegtools ts2es 68 | \ chrt -r 1 madplay - -b 32 -o wave:- -R 48000 | \ chrt -r 1 aplay -
The idea is ultimately multicast out updates, especially security ones, to allow instantaneous simultaneous deployment, such as for GNU/Linux.
Further info could be had in the DVB standards, DVB SSU may be the preferred method.
The encode may fail, the muxer does not seem to like large files or too many file, so such files might need splitting or multiple runs
If successful, the user gets a files.ts ready to mux and then transmit, which can be via multicast RTP on udp port 5004
At the receiving end the recovered transport stream is fed into some other programs to recover the caroursel from the PID selected during the encode, in this example 2003 was used.