Saturday, August 30, 2008

MyBook uShare

I have movies stored on the MyBook streaming to the XBox and it works better than I could have imagined!

I was expecting stuttering (as happens when viewing films on my wireless PC connected to the telly (I suspect the USB wireless adapter on it just isn't up to the task) ) and it streams almost instantly, unlike on my laptop which seems to download the whole file before starting to play it.

Here's how.

Install ushare on the MyBook world edition. This depends upon the upnp library so get, build and install it first, then same for ushare. If anything run under sudo doesn't work then you can alternatively log in as root and run the command as root.

[gordon]$ mkdir usharebuild
[gordon]$ cd usharebuild
[gordon]$ wget http://dfn.dl.sourceforge.net/sourceforge/pupnp/libupnp-1.6.6.tar.bz2
[gordon]$ bzcat libupnp-1.6.6.tar.bz2 | tar xv
[gordon]$ cd libupnp-1.6.6
[gordon]$ ./configure
[gordon]$ make
[gordon]$ sudo make install

This will install linupnp in /usr/local/lib so we need to check this is in our libpath. Ensure the /etc/ld.so.conf file contains an entry for /usr/local/lib and run ldconfig to ensure it's added to the path.

[gordon]$ more /etc/ld.so.conf
/usr/local/lib
[gordon]$ sudo ldconfig

Now get, build and install ushare. NLS is disabled otherwise there is a dependency error on some library I don't have, possibly iconv? DLNA is disabled as it's not used for the XBox. If you have a PS3 you will need this and the dependent libraries.

[gordon]$ cd ..
[gordon]$ wget http://ushare.geexbox.org/releases/ushare-1.1a.tar.bz2
[gordon]$ bzcat ushare-1.1a.tar.bz2 | tar xv
[gordon]$ cd ushare-1.1a
[gordon]$ ./configure --disable-dlna --disable-nls
[gordon]$ make
[gordon]$ sudo make install

Simple! Technically that's it, ushare is installed and ready to run. Here's my config file after editing from the default location, /usr/local/etc/ushare.conf. Obviously you need to change your USHARE_DIR setting.

[gordon]$ more /usr/local/etc/ushare.conf
# /etc/ushare.conf
# Configuration file for uShare

# uShare UPnP Friendly Name (default is 'uShare').
USHARE_NAME="Anya uShare Media Server"

# Interface to listen to (default is eth0).
# Ex : USHARE_IFACE=eth1
USHARE_IFACE=eth0

# Port to listen to (default is random from IANA Dynamic Ports range)
# Ex : USHARE_PORT=49200
USHARE_PORT=

# Port to listen for Telnet connections
# Ex : USHARE_TELNET_PORT=1337
USHARE_TELNET_PORT=

# Directories to be shared (space or CSV list).
# Ex: USHARE_DIR=/dir1,/dir2
USHARE_DIR=/shares/internal/VIDEO

# Use to override what happens when iconv fails to parse a file name.
# The default uShare behaviour is to not add the entry in the media list
# This option overrides that behaviour and adds the non-iconv'ed string into
# the media list, with the assumption that the renderer will be able to
# handle it. Devices like Noxon 2 have no problem with strings being passed
# as is. (Umlauts for all!)
#
# Options are TRUE/YES/1 for override and anything else for default behaviour
USHARE_OVERRIDE_ICONV_ERR=

# Enable Web interface (yes/no)
ENABLE_WEB=

# Enable Telnet control interface (yes/no)
ENABLE_TELNET=no

# Use XboX 360 compatibility mode (yes/no)
ENABLE_XBOX=yes

# Use DLNA profile (yes/no)
# This is needed for PlayStation3 to work (among other devices)
ENABLE_DLNA=no

And here's my /etc/init.d/ushare.sh file used for starting and stopping the process. Call /etc/init.d/ushare.sh start to kick things off.

[gordon]$ more /etc/init.d/ushare.sh
#!/bin/sh -e
### BEGIN INIT INFO
# Required-Start: $local_fs $syslog
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: start and stop ushare
# Description:
### END INIT INFO

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/local/bin/ushare
NAME=ushare
DESC="uShare UPnP A/V Media Server"
PIDFILE=/var/run/ushare.pid
# Use default in /usr/local/etc/ushare.conf
CONFIGFILE=/usr/local/etc/ushare.conf
USHARE_OPTIONS=-x

# abort if no executable exists
[ -x $DAEMON ] || exit 0

# Get lsb functions
#. /lib/lsb/init-functions
#. /etc/default/rcS

[ -f /etc/default/ushare ] && . /etc/default/ushare

checkpid() {
[ -e $PIDFILE ] || touch $PIDFILE
}

check_shares() {
if [ -r "$CONFIGFILE" ]; then
. $CONFIGFILE
[ -n "$USHARE_DIR" ] && return 0
fi
return 1
}

case "$1" in
start)
echo -n "Starting $DESC: $NAME"
if ! $(check_shares); then
echo -n "No shares available ..."
# echo -n 0
else
checkpid
start-stop-daemon --start --quiet --background --oknodo \
--make-pidfile --pidfile $PIDFILE \
--exec $DAEMON -- $USHARE_OPTIONS
fi
;;
stop)
echo -n "Stopping $DESC: $NAME"
start-stop-daemon --stop --signal 2 --quiet --oknodo --pidfile $PIDFILE
;;
reload|force-reload)
echo -n "Reloading $DESC: $NAME"
start-stop-daemon --stop --signal 1 --quiet --oknodo --pidfile $PIDFILE --exec $DAEMON
;;
restart)
$0 stop
$0 start
;;
*)
N=/etc/init.d/$NAME
echo -n "Usage: $N {start|stop|restart|reload|force-reload}"
exit 1
;;
esac

exit 0

Finally, if you want ushare to start automatically on bootup, and die cleanly on shutdown then add the following softlinks in your /etc/init.d directory.

[root]$ cd /etc/init.d
[root]$ ln -s ushare.sh S36ushare
[root]$ ln -s ushare.sh K64ushare
[root]$ ls -al *ushare*
lrwxrwxrwx 1 root root 9 Aug 29 17:05 K36ushare -> ushare.sh
lrwxrwxrwx 1 root root 9 Aug 29 17:05 S36ushare -> ushare.sh
-rwxr-xr-x 1 root root 1615 Aug 29 17:00 ushare.sh

And the final thing I had to do was add a "broadcast" route to the mybook's routing path. without this, the XBox could browse the files, but not play any of them. I admit I've only added this on the command line for the moment so it my need re-added if the mybook is ever rebooted.

[root]$ route add -net 239.0.0.0 netmask 255.0.0.0 eth0

That's it! It worked. Now browsing files on the XBox prompted me to connect to XBox Live to download a media update (containing the DivX codecs an such) and following that I was watching MOVIES I RIPPED FROM MY OWN DVDS on my lovely 1080p LCD TV. Any upscaling is unnoticable (to me).

I guess the next step is to, um, "find" some hi-def ripped films and try those to check the wireless bandwidth and the MyBook disk controller are up to the task.

2 comments:

Mr Ives said...

Thanks for the Blog. I have a similar config mybook and xbox360, though I have the firmare with no compiler so I used a ushare via optware.

Almost ot it working thanks to your blog. One problem I'm seeing is it doesn't find music though, and having found no music, if I move back to the Movies app on the xbox it can no longer find any video's. have you see this ?

the Movies app can initially see the folder hierarchy , in which I have both mp3 and video files (mpeg4 & AVI)

odd

Unknown said...

Hello

i have the same mybook world (500gb)..

i cannot find out how to install ushare on it.. i want to use it for my Ps3..

can you help a NOT linux person?. (i have an Acer Aspire one with linux if this is needed. otherwise i only have my windows based pc).

thank you in advance.

you can answer on mpannen (@) gmail.com if you like.