MythWiiFE
From Wiire
Contents |
Introduction
MythWiiFE is my effort to create a MythTV frontend for Nintendo's Wii game console. Mythweb makes a great starting point, with only a few things missing. Namely, I would like some sort of live TV support, and have made a little progress in that direction.
Screen Shots
Frontend
The Wii's internet channel, with Flash Player 7 makes quick work of playing your recordings via an flv player. Live TV needs a little more help on the back end though. A flash video player to display the video and XMLHttpRequest to call the channel changer is the approach I have taken.
Backend
For my purposes FFMpeg does a great job of encoding to flash video. My capture hardware is a generic (no manufacturer name on the box or card) US-NTSC Phillips saa7134 based PCI card. Unfortunately the support of this card isn't perfect, so what I have here so far is pretty hacked together. Especially changing channels.
Shell Scripts
You will need a text file with one line that contains the current channel at /var/www/localhost/htdocs/curchan. The first time stream runs it will throw an error from the kill process. Lots of improvments to come.
| File: chan |
#!/bin/bash # This script gets the frequency of the channel passed as the first argument from # /usr/share/xawtv/ntsc-cable.list and uses v4lctl to change the tuner to that freq.. CHAN=`grep "\[$1\]" -A 1 /usr/share/xawtv/ntsc-cable.list | grep freq | sed s/^.*=\ //g | sed s/.../\&\./g` v4lctl setfreq $CHAN |
| File: chdn |
#!/bin/bash # This script get the current channel, subtracts one and calls chan with the result. # THIS IS A HACK! if adapting to your own card you could just use 'v4ctl setchannel prev' CHAN=`cat /var/www/localhost/htdocs/curchan` NCHAN=$(($CHAN - 1)) /var/www/localhost/htdocs/chan $NCHAN echo $NCHAN > /var/www/localhost/htdocs/curchan |
| File: chup |
#!/bin/bash # This script get the current channel, adds one and calls chan with the result. # THIS IS A HACK! if adapting to your own card you could just use 'v4ctl setchannel next' CHAN=`cat /var/www/localhost/htdocs/curchan` NCHAN=$(($CHAN + 1)) /var/www/localhost/htdocs/chan $NCHAN echo $NCHAN > /var/www/localhost/htdocs/curchan |
| File: stream |
#!/bin/bash
# This script kills the last instance of itself that has been run. ans starts FFMpeg encoding the raw streams from /dev/video0 and /dev/dsp1
# into flash video. Redirects the stderr to /dev/null and outputs the encoding to stdout
PID=`cat /var/www/localhost/htdocs/stream.pid`
kill -9 `ps -ef | grep $PID | grep ffmpeg | awk '{print $2}'`
echo $$ > /var/www/localhost/htdocs/stream.pid
sleep 2
ffmpeg -y -f video4linux2 -s 704x480 -i /dev/video0 -f audio_device -ar 32000 -ab 32 -ac 2 -i /dev/dsp1 -s 300x200 -f flv -deinterlace -r 29.97 -ar 22050 -b 400000 - 2>/dev/null
|
Flash Video Player
There are many that will do, some that will not. I chose the player located at http://www.videospark.com/index.php?ssp=24 that filename it was contained in is 2004_dynamic_flv_player_v2.3.zip. works well with FP7 and is pretty lightweight.
Web Source
| File: index.html |
<body bgcolor="#000000">
<center><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="933" height="700" id="670x525" align="middle">
<PARAM NAME=allowFlashAutoInstall VALUE=true>
<param name=Flashvars value="url=tvstream.flv.php?f=2">
<param name="allowScriptAccess" value="sameDomain" />
<param name="movie" value="320x240.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#ffffff" />
<embed src="320x240.swf" swLiveConnect="true" Flashvars="url=tvstream.flv.php?f=2" quality="high" bgcolor="#ffffff" width="933" height="700" name="352x240" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object><br><font size="10">
<script language="JavaScript">
disableZooming();
/* A little Wii Remote Experiment */
document.onkeydown = function(e)
{
//document.getElementById('debug').innerHTML = e.keyCode+"<br>\n";
if (e.keyCode == 175) loadXMLDoc('chup.php');
if (e.keyCode == 176) loadXMLDoc('chdn.php');
if (e.keyCode == 40) loadXMLDoc('chdn.php');
if (e.keyCode == 38) loadXMLDoc('chup.php');
e.preventDefault();
}
var xmlhttp
function loadXMLDoc(url)
{
xmlhttp=null
// code for Mozilla, etc.
if (window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest()
}
// code for IE
else if (window.ActiveXObject)
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
}
if (xmlhttp!=null)
{
xmlhttp.onreadystatechange=state_Change
xmlhttp.open("GET",url,true)
xmlhttp.send(null)
}
else
{
alert("Your browser does not support XMLHTTP.")
}
}
function state_Change()
{
// if xmlhttp shows "loaded"
if (xmlhttp.readyState==4)
{
// if "OK"
if (xmlhttp.status==200)
{
// ...some code here...
}
else
{
alert("Problem retrieving XML data")
}
}
}
</script>
|
| File: chdn.php |
<?php
exec("/var/www/localhost/htdocs/chdn");
?>
|
| File: chup.php |
<?php
exec("/var/www/localhost/htdocs/chup");
?>
|
