View Single Post
Posts: 46 | Thanked: 66 times | Joined on Jan 2010
#1
With the World Cup approaching, I found it really annoying that there is no good way of watching live TV on N900 in the UK. Recorded content works well on iPlayer in the pop-out window, but live TV does not.

The obvious alternative is to use TVCatchup, who provide a lighter stream for the iPhone. N900 cannot play these streams out of the box because they use some non-standard playlist format, so I wrote a simple shell script that extracts the video stream and plays it with mplayer. For the script to work, you'll also need Firefox because I couldn't find a way to tell the built-in browser not to send the playlist to the Media Player.

Save this script as /home/user/tvcatchup.sh:
Code:
#!/bin/sh
dldir=/var/tmp
catchupdir=/home/user/.catchup
initialwait=1
buffer=1
wgetopts=""
mplayeropts=""


note()
{
/usr/bin/dbus-send --type=method_call --dest=org.freedesktop.Notifications /org/freedesktop/Notifications org.freedesktop.Notifications.SystemNoteInfoprint string:"$1"
echo $1
}

download()
{
rm tmp*.ts
count=0
urlbase=`tail -1 $dldir/playlist.m3u8 | cut -d "/" -f 1-5`
echo Base URL: $urlbase
while [ 1 ]
        do
        wget $wgetopts -T10 `tail -1 $dldir/playlist.m3u8` -O url
        urlold=$url
        url=`tail -1 url`
        if [[ "$url" == "$urlold" ]] 
                then
                sleep 1
                else
                if [[ "`echo $url | cut -c1-4`" != "http" ]]
                        then
                        url2=$urlbase/$url
                        else
                        url2=$url
                        fi
                wget $wgetopts -T10 $url2 -O tmp$count.ts
		bytes=`wc -c < tmp$count.ts`
                echo "$count: Downloaded $bytes bytes"
		if [ "$bytes" == "0" ]
			then
			echo $url2
			echo Retrying
			else
	                count=`expr $count + 1`
			fi
                fi
        sleep 1
done
}

play()
{
count=0
while [ 1 ]
        do
        countnext=`expr $count + $buffer`
        while [ ! -e tmp$countnext.ts ]
                do
                sleep 1
                done
        cat tmp$count.ts 
        rm tmp$count.ts
        count=`expr $count + 1`
        done
}

rm $dldir/playlist.m3u8
echo Starting browser
sleep 1
/usr/bin/dbus-send --system --type=method_call --dest=com.nokia.osso_browser /com/nokia/osso_browser/request com.nokia.osso_browser.load_url string:"http://iphone.tvcatchup.com"
note "Choose the channel"
while [ ! -e $dldir/playlist.m3u8 ]
	do
	sleep 1
	done
note "Playlist file found - Buffering"
mkdir 2>/dev/null $catchupdir
cd $catchupdir
download &
while [ ! -e "$catchupdir/tmp$initialwait.ts" ]
        do
        sleep 3
	killall 2>/dev/null mediaplayer
	note "Initial buffering"
        done
killall 2>/dev/null mediaplayer
note "Starting mplayer - Please be patient!"
rm tvfifo.ts
mkfifo tvfifo.ts
play > tvfifo.ts &
mplayer $mplayeropts -fs -hardframedrop -ao pulse -cache 4096 -vfm ffmpeg -lavdopts fast tvfifo.ts
""rm -r $catchupdir
exit
You should now be able to find the TV Catchup icon (just the plain blue square) in your menu. When you click it, it opens Firefox and takes you to the TVCatchup iPhone page, where you can choose the channel you want to watch. Firefox will ask you what you want to do with playlist.m3u8. You'll need to save it to /home/user/MyDocs/.documents, which I believe is the default location. Once you have saved that file, close Firefox, and you can see in the terminal window how it starts to buffer the stream. After a while MPlayer should start playing it.

This is very experimental, so I won't give any guarantees, but it works on my phone. You need at least Mplayer and Firefox, and possibly something else too. There is a lot of room for improvement, so if anyone with more skill and experience wants to develop this further, I would encourage them to do so.

EDIT: There is now a low quality stream available on the tvcatchup.com website, which works fine on N900. However, the quality is a bit lower, so this script may still be of use. Updated the script so that it no longer needs Firefox. It runs in fullscreen mode now - press q to exit. To install, save the attached tarball and run
Code:
tar -xzvf tvcatchup.tar.gz -C /home/user
in the terminal. You need to have wget installed (thanks [DarkGUNMAN] - see post #19 for details).
Attached Files
File Type: gz tvcatchup.tar.gz (1.2 KB, 238 views)

Last edited by arajantie; 2010-06-09 at 08:57. Reason: Updated the script to use builtin browser
 

The Following 24 Users Say Thank You to arajantie For This Useful Post: