Copyright 2009-2012 by djg. All Rights Reserved.

Wonky Gibbon Ramblings



D-Link DNS-320 NAS, DebianSqueeze and Twonky Media Server 7

Posted on November 28, 2012 by danny

I gave myself a bit of a shock today by working out something in Linux that actually worked, all by mself! Obviously to any proper linux person it’s little more than a child’s first steps – but it was quite satisfying!

So …

Having got the NAS loaded with all my media files, I enabled the UPnP MediaServer that came with it – to discover it was total crap. And promptly disabled it again.

But the word on the street, is that the Twonky Media Server is good, so I thought, put that on it.

And indeed people have put it on the DNS-320. This post covers much of what needs to be done, providing a link to a build of Twonky for the ARM processor and instructions on how to configure.

The only problem, is that all the instructions are for the lightweight ffp Linux install – rather than debiansqueeze which I’m using (because of the subversion project posted about previously).

Nevertheless – I followed the instructions, and with a few variations … got it to work … which surprised me!

The main thing I did was to strip off every occurrence of /ffp wherever I saw it in a path eg: /ffp/opt/twonky/ became /opt/twonky/
I did this both with the instructions in the blog post and with the content of the two scripts downloaded by those instructions ‘twonky.sh’ and ‘twonkyserver-default.ini’
Note: Two things to be aware of here: 1) Don’t edit these files with Windows Notepad, it messes up the line feeds at the end of each line such that linux doesn’t like the result! The free editor Notepad++ can probably handle it. 2) The debiansqueeze equivalent of the /ffp/start directory is /etc/inet.d so drop the twonky.sh file in there.

twonky.sh
#!/bin/sh

# PROVIDE: twonky
# REQUIRE: LOGIN

. /etc/ffp.subr
name="twonky"
start_cmd="twonky_start"
stop_cmd="twonky_stop"

twonky_start()
{
# Add a route for twonky to be published via UPNP
route add -net 224.0.0.0 netmask 240.0.0.0 dev egiga0 >/dev/null 2>/dev/null </dev/null &
cd /opt/twonky
mkdir -p /opt/twonky/data/ &
# Twonky requires one handle per monitored filesystem if inotify is
# used. On many devices, this is set to 8192, which might be too low
# if music or photos are scanned. Therefor this value is raised to
# the doubled amount. If more is required, change the value below.
# Thanks Michael for reporting this!
/sbin/sysctl fs.inotify.max_user_watches=16384 >/dev/null 2>/dev/null </dev/null &
# The line below is without logging (logs are written to /dev/null).
# If you want logging, exchange it with the line below the current one.
/opt/twonky/twonkystarter -logfile /dev/null -appdata /opt/twonky/data/ >/dev/null 2>/dev/null </dev/null &
# /opt/twonky/twonkystarter -logfile /opt/twonky/data/TwonkyMediaServer-log.txt -appdata /opt/twonky/data/ >/dev/null 2>/dev/null </dev/null &
}

twonky_stop()
{
# Kill Twonky
if [ -n "`pidof twonkyserver`" -o -n "`pidof twonkystarter`" ]; then
echo "Stopping twonkyserver"
kill -9 `pidof twonkyserver` `pidof twonkystarter`
fi

if [ -n "`pidof twonkyproxy`" ]; then
echo "Stopping twonkyproxy"
kill -9 `pidof twonkyproxy`
fi

if [ -n "`pidof twonkywebdav`" ]; then
echo "Stopping twonkywebdav"
kill -9 `pidof twonkywebdav`
fi
# Remove the route
route del -net 224.0.0.0 netmask 240.0.0.0 dev egiga0 >/dev/null 2>/dev/null </dev/null &
}

run_rc_command "$1"
twonkyserver-default.ini
#!/bin/sh

# PROVIDE: twonky
# REQUIRE: LOGIN

. /etc/ffp.subr
name="twonky"
start_cmd="twonky_start"
stop_cmd="twonky_stop"

twonky_start()
{
# Add a route for twonky to be published via UPNP
route add -net 224.0.0.0 netmask 240.0.0.0 dev egiga0 >/dev/null 2>/dev/null </dev/null &
cd /opt/twonky
mkdir -p /opt/twonky/data/ &
# Twonky requires one handle per monitored filesystem if inotify is
# used. On many devices, this is set to 8192, which might be too low
# if music or photos are scanned. Therefor this value is raised to
# the doubled amount. If more is required, change the value below.
# Thanks Michael for reporting this!
/sbin/sysctl fs.inotify.max_user_watches=16384 >/dev/null 2>/dev/null </dev/null &
# The line below is without logging (logs are written to /dev/null).
# If you want logging, exchange it with the line below the current one.
/opt/twonky/twonkystarter -logfile /dev/null -appdata /opt/twonky/data/ >/dev/null 2>/dev/null </dev/null &
# /opt/twonky/twonkystarter -logfile /opt/twonky/data/TwonkyMediaServer-log.txt -appdata /opt/twonky/data/ >/dev/null 2>/dev/null </dev/null &
}

twonky_stop()
{
# Kill Twonky
if [ -n "`pidof twonkyserver`" -o -n "`pidof twonkystarter`" ]; then
echo "Stopping twonkyserver"
kill -9 `pidof twonkyserver` `pidof twonkystarter`
fi

if [ -n "`pidof twonkyproxy`" ]; then
echo "Stopping twonkyproxy"
kill -9 `pidof twonkyproxy`
fi

if [ -n "`pidof twonkywebdav`" ]; then
echo "Stopping twonkywebdav"
kill -9 `pidof twonkywebdav`
fi
# Remove the route
route del -net 224.0.0.0 netmask 240.0.0.0 dev egiga0 >/dev/null 2>/dev/null </dev/null &
}

run_rc_command "$1"

NB: These scripts are provided for reference only – more current versions may vary.

Also – I didn’t bother with this line [[ $(ls -1 /mnt|grep -c HD_a2) -eq 0 ]] && sed -i -e ‘s!/HD_a2!/HD/HD_a2!g’ -e ‘s!/HD_b2!/HD/HD_b2!g’ /ffp/opt/twonky/twonkyserver-default.ini
in the instructions – it does a search and replace – but it doesn’t seem necessary.

Finally the ‘twonky.sh’ script makes use of a script called ‘ffp.subr’ which I think is used to start and stop the twonky service. This doesn’t exist in Debiansqueeze. There is probably some native way of achieving the same thing – but I don’t know what it is so instead, I went and found the download for ffp – unpacked it, and retrieved the script. There’s nothing specific to ffp in it so I dropped it into the /etc directory. You do need to go through the file and remove /ffp off the start of any paths that it appears in.

Then as instructed, I ran the twonky,sh script to start the service and connected via a web browser – and OMG!!!! IT WORKED!!!! First time too, which usually only happens to people who are either (a) lucky or (b) liars.

Once I had configured the server through the web page, I left it to get on with the job of indexing my media collection. This was a task that UPnP service that came with the NAS had taken all night to do. Twonky seemed to do it in minutes. Not only that, connecting using Windows Media Player, it downloads the metadata from Twonky so much more rapidly. Streaming of both audio and video is very rapid and smooth as is seeking to a certain spot in the video. All in all – very impressed with Twonky. It’s good.

There are three reasons, changing all this stuff worked:
1) All the scripts use the sh shell which is of course available in both ffp and debiansqueeze (ie the syntax was the same)
2) The folder structures of ffp and debiansqueeze are very similar.
3) Can’t remember – it’ll come back to me.

The only reference for this post, is to thank (again) Uli author of the http://nas-tweaks.net site
for this page http://nas-tweaks.net/384/installation-of-twonky-server-7-on-nas-devices/

Can old Hardware run Windows 7 Media Center? 1

Posted on September 25, 2009 by danny

When the RC of Windows 7 came out – I was minded to investigate whether the same hardware I built to run MCE 2005 (ie: XP) could run Windows 7 Media Center (particularly as time goes by my MCE2005 system gets less and less stable) ? I never bothered to upgrade to Vista because it was clear that Vista was too processor hungry but with Windows 7 making waves for being as quick if not quicker than XP, I wanted to investigate.

The post for the original MCE2005 build is here

The original spec was:

  • Soltek 75DRV2 Motherboard (circa 2002)
  • AMD Athlon XP 1600+
  • 1.0 GB Ram (can run on 512MB – but gets sluggish once you have many recordings to index)
  • NVidia GeForce FX5200 Video card (fanless) with TV output
  • A Seagate Barracuda 7200 320GB hard drive
  • Twin Black Gold Signature TV cards to encode DVB-T (Freeview) signals
  • Gigabit LAN card

Well, in summary – yes it can – but there were a number of problems, mostly revolving around drivers.

After installing Windows 7 on a spare 80GB drive, audio and networking worked immediately. Also it can playback XVID natively so no XVID instal required. Nor does it require a third party mpeg decoder in the way that MCE2005 did. It has one built in, out of the box.

NVidia Graphics Card

The graphics card is old (though you can still buy it even new in 2009) – an NVidia GeForce FX 5200. The only drivers currently available were released back in 2006 (for Vista) and they do just about work. Worryingly NVidia have only so far released proper Windows 7 drivers for their more recent cards. I hope they expand support for older cards in due course but it doesn’t look promising.

Configuring the card was tricky, a lot of the NVidia Control Panel that had been available in XP was gone. I believe the Windows 7 driver model (inherited from Vista) has changed meaning those features would have to be reimplemented – if indeed it is even possibel to do so. Luckilly – I was able to select the correct resolution of 768 x 576 (PAL) once I had set “TV0” to be the main card output. The refresh rates available are way low (29Hz or something) – but I haven’t found away yet to tell Windows 7, that the display is a TV (a non plug-n-play device) and that it should be using 50Hz. That said it doesn’t seem to flicker – so it’s a low priority to fix.

Black Gold Digital Tuners

The Black Gold situation is annoying (and is well documented on “The Green Button” website here). Black Gold seem unable or unwilling to update the drivers such that two of these cards can work side by side in the same box. You can only use one. So one has to come out. Which means I shall have to buy another single or dual tuner card (from another manufacturer I think too). Not the best customer servicer.

Anyway, taking out one of the Black Gold cards got the other to work.

Performance

Initially, performance was pretty shabby. So I turned off a lot of unnecessary Windows 7 stuff to get some speed back. This page has some good information on this. More detail on the services can be found from Black Viper.

In essence I turned off a lot of services and switched off Aero (which although many people say this makes little difference – it’s a shite graphics card! – and Media Center doesn’t use Aero anyway).

In the process, I accidentally turned off the Human Interface Service which killed much of the Remote Control. So undid that. Also – it does need the Windows Search service.

Having done that – performance was much better and the media center UI is perfectly responsive.

Things get a bit more sticky once you start watching live telly – it does take a bit longer than MCE 2005 to get itself initialised and going – and is prone to the odd starting playback stutter – but once running it’s solid.

Similarly playing back pre-recorded video whilst recording another channel seems to work well without glitch in the recorded stream. Again playback startup is a bit slow.

Because of the problems with the Black Gold drivers – I was unable to test recording two streams simiultaneously whilst playing back a third.

The only significant lockup was when using the back button on live tv, it took me back to the guide (which is fine) but then got stuck taking me back to the main menu. Odd. Pressing the green button seems to fix this most of the time.

The one signifcant difference in hardware between the XP and Windows 7 setup’s was the Hard Drive – because I’m using my fast 320GB drive for my live MCE 2005 system, I had to use a slower 80GB Western Digital drive for the Windows 7 test.
This may well be significant and explain some of the stutters – I can’t prove that at the moment though. Certainly the faster drive can only improve things.
The Seagate manages 63.05 MB/s and has a 16MB cache whilst the Western Digital only manages 43.47 MB/s and has an 8MB cache.

Migration of Existing Recordings

Although Windows 7 MCE uses a new storage format for recorded TV, it seems to playback dvrms files transfered across from MCE 2005 just fine.

But then, there is XVID.

Oh dear. XVID.

I encode a lot of stuff to XVID. Movie’s and home Camcorder stuff. Playing any of this, even from the local hard drive was grindingly slow. Playback was quaerter speed, audio normal speed and the UI is completely unresponsive. Installing XVID in the hope that it would take over from Microsoft’s codec’s didn’t help either. Some other config required here perhaps. But I haven’t yet googled a way how (and I ain’t smart enough to work it out for myself!)

Again, looking at the Green Button website – this seems to be a common problem. Here’s hoping it gets sorted by the October release. Certainly decoding XVID’s usually doesn’t require much processing power at all – so it seems odd.

Then there is the aspect ratio of the XVID’s on screen – which displayed just fine in MCE 2005, but are completely wrong in Windows 7 being stretched height wise. Ugh.

Some further research shows that the XVID’s play fine in Media Player. Weird.

Conclusion

There is no doubt that at the moment the system does perform better where TV is concerned when running MCE 2005 – but the performance in Windows 7 is certainly not unuseable by a long shot.

And there’s a lot to like in the new UI with all the downloading of artwork for movies etc… plus the general reorganisation of the UI. It all seems to work well, logically and is responsive. Support for features such as fasr forward/revwind in XVID’s and other Video file types is much improved. And the extra digital buttons we get in the UK (“press the red button now for etc”) actually seem to work which they never did in MCE XP.

It would also have to be said that my MCE2005 install is no longer that stable and is likely to crash if left by itself for a week. It remains to be seen how stable Windows 7 MCE is by comparison.

So in short – when Windows 7 comes out for real – I’m definately going to try to move over to it with this hardware.

Even if XVID playback is screwed – someone will work out a fix for that!

Mind you, you’re never going to be watching HD on this system! 🙂

Building a Windows MediaCentre PVR from (some) reused parts 0

Posted on April 16, 2009 by danny

I’m a big fan of reusing old kit from the loft (ie tight fisted!) and we’d been wanting a PVR for quite a while. Windows Media Centre PVR’s are often specced to be high performance pieces of kit that can handle the latest games etc… However the actual TV part of the requirement needs next no grunt at all. The spec below is more than capable of recording 2 channels simultaneously whilst playing back a third pre-receorded show – and the heart of it, was recycled from the loft…

Reused bits:

  • Soltek 75DRV2 Motherboard (circa 2002)
  • AMD Athlon XP 1600+
  • 1.0 GB Ram (can run on 512MB – but gets sluggish once you have many recordings to index)
  • NVidia Gforce FX5200 Video card (fanless) with TV output (cost £20 when new).

Additional Hardware:

  • Big Slow Spinning fan to keep it cool quietly (cost about £15 if I remember correctly).
  • Similarly, quiet PSU bought (do you really want a noisy PC in your living room? Nah!)
  • A single Seagate Barracuda drive for storage (again quiet) £50
  • Twin Black Gold TV cards to encode DVB-T (Freeview) signals £50 each.
  • A Silver fronted DVD drive (£20).
  • A nice case. To make it a simple build, the normal PC case height. A Silverstone LC17 – this wasn’t that cheap (almost £100).
  • You will also need a Remote Control and an IR receiver for MCE. These can be found on ebay.
  • If you are going to want to store (or process) the recorded files on other machines, then buy a gigabit LAN card if you don’t have one (£10) so that you can move the files around quickly (they are huge!) – if you opt to do this over wireless you may contemplate suicide.

Software:

You will need a copy of Microsoft Media Centre for XP which you probably can’t buy new anymore. Its quite likely that the Vista version may not run on a machine this low spec as Vista is rather more hungry. But the XP version can be found easily on ebay. Would be interesting to see if the equivalent Windows 7 MCE is efficient enough to run on this when that comes out though…
Read the rest of this entry →

What to do with Camcorder DV Video? 0

Posted on March 27, 2009 by danny

Overview

(or Batch Two Pass Encoding of DV Video (AVI) with XVid and VirtualDub)

So you’ve taken hours of video of the kids, you’ve got used DV tapes lying around in piles that you can’t arsed to watch yet strangely don’t want to erase and generally don’t know what to do with them all. Short of playing dominoes with the cassettes – what do you do?

Further, if you have a family and own a camcorder you’ll know that at first you shoot quite a lot of video and then as the tapes start to build up and you don’t get around to watching them – you shoot less and less until you’re shooting practically nothing at all. And still don’t get around to watching what you have.

It’s pretty amazing that the camcorder manufacturers don’t do a better job of pointing you in the direction of some half decent software to process the results – but heh ho! They don’t – so I will try to instead.

These pages outline the resolution to the problem that I came up with for home use.
Read the rest of this entry →



↑ Top