Other things on this site...

MCLD
music
Evolutionary sound
Listen to Flat Four Internet Radio
Learn about
The Molecules of HIV
MCLD
software
Make Oddmusic!
Make oddmusic!

MythBuntu/MythTV: A week of tweaks

Getting to grips with MythBuntu: an edition of Ubuntu tailored specifically for providing MythTV, the so-called "mythical convergence system" - a combination of TV, video recorder, media player, and computer.

MythTV has loads of good features. For example, it provides a webpage so you can remotely browse the TV schedules, then you can even remotely tell it to record a programme (or the whole series). You can even watch recorded programmes over the web.

The great thing is because it's Linux it's eminently tweakable - unlike a Sky Plus box you can download or even create extra plugins to make the box do exactly the things that suit you. For example, I've added and tweaked the MythNetTV plugin to add podcasts, which is brill cos we now have TV progs and YouTube and podcasts/vodcasts on an even footing.

OK but because it's Linux you also need to find your way around tweaking it. There are many options buried in the capacious menus (a bit unwieldy to be honest, since there are so many layers of menus in the MythFrontend), and despite the very good graphical interface, it does still help if you can find your way around the command-line to do some extra fiddling.

Luckily I'm not the first down this path. I found Von's MythBuntu MythTV Tweaks page contains some really useful tips, including how to set up advert-skipping and how to add extra functions for your remote-control buttons.

After a week or so of getting used to the thing, here (for future reference) is a compilation of the useful tweaks I did (as well as Von's, linked above):

Better fullscreen YouTube

We noticed that YouTube videos (i.e. flash video) worked fine but got a bit stuttery in fullscreen mode. I tried out the tips in this Firefox optimisation page and found that the trick of telling Flash not to worry about validating the GPU worked a treat. It's quite simple:

         sudo mkdir /etc/adobe
         sudo echo "OverrideGPUValidation=true" >> /etc/adobe/mms.cfg

The reason this works is that normally, Flash doesn't trust your graphics chip, meaning the fullscreen video has to be handled by the main CPU, which can then get overloaded and not cope very well. If your graphics chip is capable then this trick allows Flash to offload a lot of work to it and therefore improve graphics performance. But it's a hack: depending on the graphics in your machine, there's a chance that you might get some side-effects onscreen, so if you need to undo it you would remove that file you just created. More about the setting.

Static IP address

On most networks these days, dynamic IP addresses are the norm. I needed the MythBuntu to have a static IP address so that we can consistently refer to it without it having been moved. Various online forums will tell you to edit /etc/network/interfaces but somehow this wasn't working for me (even after rebooting). Instead, I used the "network manager" software (specifically, the tool "nm-connection-manager") to change the address to static and that worked fine.

Plugins: MythNetTV and MythNews

MythNetTV is an add-on which can harvest videos from RSS feeds, so you can automatically download TED Talks and all the other goodness out there on the web. I installed it from the command-line:

    sudo apt-get install mythnettv mythnettv-gui

It has a nice way of working (putting the videos into the main MythTV collection) but there's almost no documentation on how to use it. I think I need to set up a cron job so that the following commands will run, perhaps every day:

    mythnettv update && mythnettv download 2 > /var/log/mythnettv.log 2>&1

Also it's a bit of a shame that it doesn't handle audio podcasts well, only video ones. I tried this podcast patch but it hasn't quite worked: the podcasts appear in the lists but don't play.

MythNews is another plugin (a newsfeed reader) which can kindof handle podcasts/vodcasts. It took me ages to spot how to set up which feeds you're interested in:

Utilities/Setup --> Setup --> Info Center Settings --> News Settings

and then to see the news items you go to

Information Center --> News Feeds

Top MythTV tip: pressing "M" often pops up a menu with useful config options. For MythNews you can press "M" and get options including adding your own newsfeeds to its list.

Using podcasts in MythNews 0.21 is extremely clunky. It's great that it downloads the media file for you, but it doesn't put it into your standard MythTV "media library", instead you click on it from within the "News Feeds" list and the screen freezes while the audio plays back. There's no way to stop the audio playing and the interface is totally frozen (remote control / keyboard has no effect), so there's no way to stop the audio playing - which is a massive pain if you decide you don't want to listen to that one-hour show after all...! (You can stop the audio player the hard way: use the "top" application [or "htop" which I like better] to identify the ''mplayer'' process and manually kill it.)

Import your music collection

MythTV has a "Music" folder. If you have a collection of MP3s you can reasonably just copy or move them into that folder, no bother. What I did what make a symlink from inside MythTV's music folder to my own ~/Music folder.

Then run the MythFrontend option "Utilities/Setup --> Music tools --> Scan for New Music" and the MP3s get noticed. More info on the official wiki

Controlling disk space: XFS quotas

Video files from TV are massive so it's important to be vigilant about disk space. If you're not careful you might fill up your disk and then you can't use the system for anything else, you might not even be able to log in.

Firstly make good use of MythTV's setting for how much disk space it should keep free. It's buried in:

Utilities/Setup --> Setup --> TV Settings --> General

and by default it's fairly small, 1 Gb or something, which is fine for a purely MythTV box but I need to make sure there's enough clear space to make backups and other stuff, so I turned that setting up quite a lot.

Then you can get really clever by using XFS quotas. XFS is a linux filesystem format, and apparently it's well-suited to the kind of use myth makes, so it was the default choice for the big data partition. XFS has some very smooth features for quotas, meaning that you can specify maximum use limits for certain users, groups, or even for certain folders.

First I had to enable quotaing - I edited the file /etc/fstab and added ",usrquota,grpquota" to the options for my data partition. (If you don't understand this bit then '''be really careful''' because if you mess up the file /etc/fstab you might stop your machine from booting. Search the web, there are some useful guides on it.) Then I rebooted (so that the new fstab options are in operation).

I installed the "quota" package...

    sudo apt-get install quota

...which brings a couple of handy tools for editing quotas. Then I can specify the quotas for user "fred" by doing

    sudo edquota -u fred

and editing the text that appears onscreen. This page is a nice guide to XFS quotas which goes into more detail.

Oh and remember to tweak the "grace period". In theory the xfs_quota program can do this but I couldn't get it to accept that, so instead I used

    sudo edquota -t

and pushed the grace period up from 7 days to 30 days, because I don't want to be quite so strict.

Adding new users - remember the LIRC file

Adding new users in MythBuntu is the same as in any ubuntu, any debian.

    sudo adduser fred

But remember that if fred is going to want to use the remote control, you need to copy the "lirc" configuration across:

    sudo cp -R ~/.lirc ~fred/.lirc
    sudo chown -R fred:fred ~fred/.lirc

(LIRC is the Linux Infra-Red Controller program, ysee. If you don't do this then the remote won't work when that person's logged in.)

Adding a SVN service

Most people might not need this, but I added a Subversion service for storing version-controlled files.

      sudo apt-get install subversion

Before starting the service there's a couple of things to tweak. The svn server should really run under its own user ID (so that it can't go crazy and trash other stuff...) so you create a "system user" as follows:

       sudo adduser --system --group --no-create-home svn

Then you establish a folder in which the central subversion repositories will live (in the following I've given /var/svnrepos but that's not neccessarily where you'll be putting it):

       sudo mkdir /var/svnrepos
       sudo chown -R svn:svn /var/svnrepos

Then to start the "svnserve" service, it's similar to these instructions for SVN on Ubuntu.

Adding an Icecast service

Even fewer people might want this one, but we run an Icecast server to create an internet radio stream. In our case we install "ices0" which streams the MP3s to icecast, and "icecast2" which broadcasts that stream to the internet.

        sudo apt-get install ices0 icecast2

As with the svn service above, it's best to create a special user and group for this service.

       sudo adduser --system --group --no-create-home icecast

Now, configuring ices0 to stream your MP3s, and configuring icecast to push the stream out the way you want, are both a bit involved so I won't discuss them here. (Search for icecast config tutorials if needed.)

I wanted icecast+ices to start up at boot, just like with svnserve as described in the linked article above. Unfortunately that was much more tricky - it wasn't just a case of enabling the service, since the "service" really consists of two interdependent processes (ices0 and icecast) which I want to treat as a single unit.

The "official" file to configure for the service is /etc/init.d/icecast2 which uses the standard linux "start-stop-demon" script to safely start and stop services. But I couldn't seem to get that script to start and stop the radio stream in the way I wanted, so in the end I hacked the above-named file: I changed the "start" case to directly invoke icecast and ices (using "sudo -u icecast" to start under the correct user account - make sure that user can read the config files). The "stop" case required less hacking, since "start-stop-daemon" was able to stop the services sensibly.

Actually... I said I ran icecast+ices under the user account "icecast" but it's a bit more complex than that. Icecast has some clever security features that you can configure it to use: on startup, it can automatically put itself into a chroot jail and switch to a specified user ID. So the best thing to do, then, is to configure icecast to chroot itself and to use the user account "icecast", which only works if it is invoked as the superuser. So after configuring icecast correctly, the startup script needs to invoke "sudo icecast" and "sudo -u icecast ices0" (with the appropriate options etc etc).

Saturday 24th October 2009 | linux | Permalink
Comments:
Name: mikal
Website: http://www.stillhq.com
Email: mikal art stillhq dort com
Date: Sunday 25th October 2009 17:21
The MythNetTV documentation is actually quite extensive. Checkout http://www.mythtvbook.com/wiki/Using_MythTV_as_a_Video_Aggregator . Email me if you have things you think I've missed.
Name: joat
Website: http://www.757.org/~joat/wiki/
Email: joat art 757 dort org
Date: Monday 26th October 2009 00:05
I also have Icecast running on the same box as MythTV (and Asterisk and LiquidSoap and SqueezeCenter and Alfresco and PmWiki and...). LiquidSoap and/or SqueezeCenter may be a better choice than Ices.

Add your comments:

Name:
Email:
Website:
Comment:
I am a:
Everything is optional - and email addresses will be marmalised to protect you
Creative Commons License
Dan's blog articles may be re-used under the Creative Commons Attribution-Noncommercial-Share Alike 2.5 License. Click the link to see what that means...