Xbox Frontend on Xebian stable

From MythTV Official Wiki
Revision as of 01:16, 2 May 2010 by Wagnerrp (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Time.png Outdated: The Xbox has too little memory to be recommended or supported as a frontend.


Lastest Updates:
25/02/08 - Volume Control, kill the mouse-remote, flicker filter script and more video filter / setup stuff, all under Tweaks.


Installing an Xbox Frontend on Xebian Stable

Alex Fisher has recompiled Christian Marillat's mythtv 0.20 source package against debian stable and optimised for Pentium 3.

The advantage with this configuration is that you do not need to upgrade any part of your Xebian from stable (sarge) to unstable (sid).

The following will end you with a ratpoison window manager and autostarting mythfrontend, with information taken from mycampus' Xebian And Mythtv-frontend HOWTO and the xbox-linux MythTV on Xebian wiki, combined together and a few steps clarified / added.

Assumptions

1. Xbox has been modded (either soft or hard, following assumes Krayzie's Ndure) and boots to a modded dashboard of some kind.

2. You are NOT using HDTV output. Composite is fine, RGB works only on pre-1.6 boxes (green image only on 1.6s), others you may have to try additional things to get working.

3. You know what size drive is in your xbox (open it up and look, or install XBMC and check product IDs in there).

4. Mythbackend 0.20.2 is installed somewhere else on the network.

5. Xbox has access to the network, with an IP in the same subnet as your mythbackend PC.

6. Make sure your mythbackend is configured with an IP not the default 127.0.0.1. You change this in mythsetup.


Install Xebian 1.1.4

Download Xebian 1.1.4-xbox, named dist-1.1.4-xbox.tar.gz at http://sourceforge.net/project/showfiles.php?group_id=54192 then extract and burn the ISO to disc using the slowest available speed and Track-At-Once if available. AS the xbox's dvd drive has compatibility issues, you may have to try burning to a different DVDR/W or CDR/W until one works. note If you burn to dvd you should be successful, there are some cdr/w disks which may be compatible (depending on drive and xbox version) but most if not all dvd's will work and will be cheaper. The cdrw route came about when DVD burners were rare and expensive.

Before booting Xebian, connect all devices you wish to use to the xbox via USB to Xbox converter cables if needed, inc. mouse, keyboard, remote and Xbox control pad. This may or may not help with correct drivers being loaded during install, but it don't hurt to make sure does it?

Insert the disc in to the xbox, and depending on your mod method it may just run, or with the Ndure mod, power off the xbox with disc in drive, power back on and Xebian should just start to boot. If not, try another disc.

Now follow the Xebian And Mythtv-frontend HOWTO pdf, steps 4.1 through 4.5. They're reproduced below incase the PDF ever goes awol.

If no keyboard is available, open xvkbd from the Apps > Tools menu available when pressing B on the xbox controler.

Now start a bash shell from Apps > Shells and, using the virtual keyboard if necessary, type:

su
xebian
cd /etc/network
nano interfaces

Edit the "iface eth0 inet static" line to read

iface eth0 inet dhcp

and save / exit nano by using Ctrl-X, hit Y, and enter. Now restart your ethernet interface using:

ifdown eth0
ifup eth0

Ignore any messages about eth0 not existing when you ifdown, and you should see printout confirming the assignment of a correct IP / gateway / subnet after ifup.


Now SSH in to the xbox, either via a Linux command line or using Putty on a Windows PC. On linux, this is:

ssh root@(xbox ip)

And on windows just type the ip in to the first box in putty and connect. Click or type yes to any key queries, and use "xebian" as the password (and "root" as login in putty).


Now install Xebian using the following command:

XBOXLinuxInstall

You have a few options now; check the pdf for more but if you have a 10GB Seagate hard drive in you box, you'll probably want to install to the unused 2GB hard drive space (or F:/ partition) as it seems quicker than installing on E:. If you only have an 8GB Western Digital drive, you'll have to install to E: (check the pdf for instructions), otherwise:

Choose the 2nd Install to free space option. Change the swap size to +512M (may or may not make much difference from 256M but it can't be bad) then wait about 8 minutes as the OS is installed.

When asked for IP / Netmask / Gateway, enter the xbox's current IP / Netmask / Gateway (that's the IP you're using to access over ssh, and your backend's netmask / gateway should be the same). Use whatever hostname you like but I kept default. Local network domain should proabably left at local.localdomain unless you know better. And that should be about it, once install is done you should see the text "Happy penguin" and you can type "shutdown -h now" to shutdown. Now power on with the eject button, remove the CD and boot in to your old dashboard.

You can boot xebian using the default.xbe file in E:/debian, which you should be able to access via your dashboard, in XBMC it's under Programs (you may have to add E:/debian as a source and chose the 2.3GB Linux program). Section 4.6 in the PDF gives more details on adding dashboard buttons to quick load the thing. Either way, it should take aprox 55 seconds to boot from F, and look identicle to the live CD.

First thing you should do when you boot up is SSH in again and make sure the time is set correctly. Run:

tzconfig

Type y and enter if the timezone wrong, and follow the easy steps to enter the correct one which should then list the correct time.

Update Xebian

This is where I went a little wrong, but it worked and from my experience using Linux updates, doing anything different may mean it doesn't work, so best you do the same...

After logging in via SSH again, firstly change /etc/apt/sources.list to look like the following (using "nano /etc/apt/sources.list", Ctrl-X, Y, enter to save), basically all you need to do is add the final two lines:

deb http://ftp.at.debian.org/debian stable main contrib non-free

deb http://non-us.debian.org/debian-non-US stable/non-US main contrib non-free
deb-src http://non-us.debian.org/debian-non-US stable/non-US main contrib non-free

deb http://security.debian.org stable/updates main contrib non-free
deb-src http://security.debian.org stable/updates main contrib non-free

deb http://alexfisher.me.uk/debian sarge main
deb http://debian-multimedia.fx-services.com/ sarge main

The other links should be *left* using the *stable* repos. Now, update Xebian using the following command, which includes installing the joe text editor as it a) is what I did (and it worked) and b) ensures your updates are working as they should:

apt-get update
apt-get install joe
apt-get update
apt-get upgrade

The joe installation will print out a readme file, just type :q (colon, Q) to exit it, ignore the errors about log file permissions, then choose Y to install glibc now and Y to restart services.

After the upgrade hit :q again to exit the readmes, then chose No for the portmap stuff, N to keep the current /etc/issue and /etc/issue.net. Once upgraded you'll be dumped at a normal command prompt and just type "shutdown -r now" to reboot, then start up again from the dashboard.

Update Sources

SSH in again, and again edit your sources.list to change all "stable" links to "sarge". The resulting sources.list file will look like this:

deb http://ftp.at.debian.org/debian sarge main contrib non-free

deb http://non-us.debian.org/debian-non-US sarge/non-US main contrib non-free
deb-src http://non-us.debian.org/debian-non-US sarge/non-US main contrib non-free

deb http://security.debian.org sarge/updates main contrib non-free
deb-src http://security.debian.org sarge/updates main contrib non-free

deb http://alexfisher.me.uk/debian sarge main
deb http://debian-multimedia.fx-services.com/ sarge main 

If you do not do this, you will get dependency errors when trying to install mythtv-frontend.

Install MythTV

Due to a possible bug in the installer, make and chmod a mythtv folder yourself:

mkdir /etc/mythtv
chmod 777 /etc/mythtv

Now run the following commands to install mythtv-frontend 0.21:

apt-get update
apt-get install mythtv-frontend

This should install all needed dependencies for you. If not, you probably have the /etc/sources.list file wrong - make sure that all links contain "sarge" instead of "stable". When asked for confirmation, hit Y and enter and when asked for the MySQL server host, enter your myth backend machine's IP.

You may also want to install aditional plugins for mythfrontend at this point, though I left it til later just to make sure all was working beforehand. Whenever you want to install, just type:

apt-get update
apt-get install mythvideo mythmusic mythtv-themes

Add or remove whichever plugins you want, and note that without mythtv-themes you'll only have the default GANT or some yucky blue theme available.

I'm told this next bit poses security issues, though there's probably so many on mine I'll just have to make do if my oap neighbours hack in to my WPA2 network and rm -rf my ass. The potential smoother video playback is more than worth it imo, so let's give mythfrontend sudo id root acces:

chmod -s /usr/bin/mythfrontend

You'll also want to enable realtime priority threads in the frontend setup to make use of this.

Xbox Remote Key Bindings

Note: This section assumes you are using the official Xbox DVD remote kit and that you had it connected during the installation process (it may or may not work if not, check "more /etc/lirc/lircd.conf" for Xbox remote info if you didn't).


You now want to download and copy a key binding file for the Xbox remote to use with MythTV and Mplayer via a Lircrc and mplayer.config file. The Xbox remote should already be working with Lirc so you just need to copy a few files from a mythtv-xbox package. You might wanna check the file is still available for download at bit.blkbk.com first (note: 7/Jan/2009, bit.blkbk.com doesn't exist anymore), and then continue with the install. You can also edit the lircrc file if you so wish / know how to, but you're on your own there.

cd /root
mkdir temp
cd temp
wget http://bit.blkbk.com/mythtv-xbox.0.4.5-beta.tar.gz
gunzip mythtv-xbox.0.4.5-beta.tar.gz
tar xvf mythtv-xbox.0.4.5-beta.tar
cd live
cp lircrc /usr/share/lirc/
cp mplayer.config /usr/share/mplayer

MCE User

Note: a number of the following steps differ from mycampus' pdf. You MUST follow the steps below for the the lircrc and .config files otherwise they will not link correctly, and you should also use the chown steps below to avoid chowning the whole /home directory which causes problems if you want to use any other user in the future.


You can continue to use the default live user if you wish, and keep a nice fluxbox gui, but if you're just gonna be running mythfrontend then there's no need for this as it takes up a little memory which you could better use elsewhere. The below will setup the inbuilt mce user to be logged on by default and run mythfrontend automatically.

First up you need to link the copied lircrc and mplayer.config files to the mce users home directory, but you must also remove any current version of these files from there before you do so, so...

cd /home/mce
rm .lircrc
rm .mplayer/config
ln -s /usr/share/lirc/lircrc .lircrc
ln -s /usr/share/mplayer/mplayer.config .mplayer/config
mkdir .mythtv
ln -s /usr/share/lirc/lircrc .mythtv/lircrc


Database Connection

You also now need to create a mysql.txt file within the .mythtv directory containing the mysql database info for mythfrontend. Without doing this, I found that mythfrontend would not start, and trying to start it via a command line on the xbox showed it had problems connecting to the database. The following steps resolved this for me.

First up, know what to put in mysql.txt. You should see what you need in either /etc/mythtv/mysql.txt or /home/(user)/.mythtv/mysql.txt on your backend, otherwise using the below defaults with the IP address of your backend and password found on the Setup > General page of mythfrontend on your backend machine should work.

cd /home/mce/.mythtv/
nano mysql.txt

Use nano to enter the following (changing what's needed) and Ctrl-X, Y, enter to save.

DBHostName=192.168.1.2
DBUserName=mythtv
DBName=mythconverg
DBPassword=mythtv

Even after this you may have connection problems, so run the following ON YOUR BACKEND MACHINE to allow access. Note that during my attempts to fix my problems, I did each of these three lines for the live, mce and mythtv users. I *think* only mythtv is actually needed (or whatever you used as DBUserName), but if you have problems just repeat the three lines replacing "mythtv" with "live" and "mce". Just hit enter after the first command when asked for password.

mysql -u root -p -h localhost

GRANT ALL PRIVILEGES ON *.* TO 'mythtv'@'192.168.1.3' IDENTIFIED BY 'secretmagicpasswd' WITH GRANT OPTION;
UPDATE mysql.user SET Password = OLD_PASSWORD('secretmagicpasswd') WHERE User = 'mythtv';
SET PASSWORD FOR 'mythtv'@'192.168.1.3' = OLD_PASSWORD('secretmagicpasswd');

Make sure to change 192.168.1.3 to your XBOX's IP and that the secretmagicpasswd to the same as the one used in the mysql.txt file (your nomal mysql password).

Finishing Up

Now you just have two more things to do for the xbox's mce user. SSH back in if you aren't already, and...

nano /home/mce/.xinitrc

Edit the file to read:

exec /usr/bin/ratpoison &
exec /usr/bin/mythfrontend

Basically you just change freevo to mythfrontend. Ctrl-X, Y, enter.


Now, this is another bit that differs from the PDF guide as I'm sure it's wrong in there. You basically just want to chown all the files you just created to belong to the mce user, not root. Do a "cd /home/mce" then "ls -a -l" to see the current permissions, then:

cd /home/mce
chown mce:mce .lircrc
chown mce:mce .mplayer/config
chown mce:mce .mythtv
chown mce:mce .mythtv/mysql.txt
chown mce:mce .mythtv/lircrc
chown mce:mce .xinitrc

Do "ls -a -l" again and you should see all files belong to mce now.


Auto Login

Just one more thing left, and that's to enable auto login.

nano /etc/inittab

What you want to do is change the "live" user in the following line to "mce":

1:12345:respawn:/sbin/mingetty --noclear --autologin live tty1

But while you're at it you should also comment out four or so of the extra teminals as these take up memory and unless you know better you'll never use them. So, edit the file so it looks as follows, then Ctrl-X, Y, enter to save.

1:12345:respawn:/sbin/mingetty --noclear --autologin mce tty1
#1:2345:respawn:/sbin/getty 38400 tty1
2:23:respawn:/sbin/getty 38400 tty2
#3:23:respawn:/sbin/getty 38400 tty3
#4:23:respawn:/sbin/getty 38400 tty4
#5:23:respawn:/sbin/getty 38400 tty5
#6:23:respawn:/sbin/getty 38400 tty6

And that should be it. Type "shutdown -r now" to restart, boot your regular dashboard, run Linux, and you should see the Ratpoison gui load after 55 odd seconds, and Mythfrontend should load around 10 seconds later with no extra configuration needed. You'll probably wanna go through the setup and change things to your liking though, and if you know how there's plenty of stuff like extra optimization (eg. free up some more memory), installing a better remote and altering lircrc key bindings but I've not got that far myself yet so we'll leave that for another day.

Also, you'll notice it's not the fastest frontend ever. Recordings / TV should take around 20 seconds to start up, maybe 5 or so seconds to stop a video, and changing menu options via the OSD will also take 10 or so seconds. Paging will help, so after doing something once it should be quicker, but you'll probably just have to put up with it.

And if you're viewing on a CRT, you probably want to enable Bob(2x) deinterlacing. Unfortunately if you want/need to watch subtitles (like my father) then any live subtitling will either cause Bob to stutter on every word update, or may be barely visible due to constant flickering on and off. Regular (non-live) subtitling seems much better though as it only updates once every few seconds.

And general picture quality seems pretty good (better than XBMC's major contrast issues), if not quite as bold and vivid as my STB, but then I am currently using a composite scart socket and haven't touched display settings, either resolution or contrast/brightness/hue etc.

Tweaks

Make Sound Controls Work

By default, volume control (of any sort) does not work on the Xbox, although actual audio output is fine. This is due to the Xbox having no hardware audio mixer controls so instead we'll have to setup a software mixer to alter the volume levels. If you need to or want to use your TV / Amp / Speaker's own volume control then that's fine, otherwise...

The original Xbox sound guide is here, written by George Nassas so you can all thank him for this (before finding his guide I'd tried every softvol setup I could think of without luck...). Further info on softvol can be found on the alsa wiki here, here and here which should help you trouble shoot if you need to, but you shouldn't if you just follow these steps:

Create the /etc/asound.conf file by typing the following:

nano /etc/asound.conf

now copy and paste this in to the file:

pcm.softvol {
    type softvol
    slave {
        pcm "hw:0,0"
    }
    control {
        name "Master"
    }
}

pcm.dsp0 {
  type plug
  slave.pcm "softvol"
}

This creates an appropriate softvol device so you just need to tell MythTV to use it. Go to the Utilities & Setup > Setup > General > Audio page and change the settings to the following. Note that these will not appear in the drop down boxes, and you have to type then in to the correct box using a keyboard connected to the xbox (the virtual keyboard will not work). There's probably a config file or mysql entry somewhere to edit these over ssh if you can't connect a keyboard directly, but you'll have to search for that info.

Audio output device: ALSA:softvol
Mixer Device: default
Mixer Controls: Master

Type the first two in identically to the above ("ALSA:softvol", that's capital ALSA colon softvol, no spaces, and "default", all without quotes) and select Master from the dropdown. That should be all you need to do. Now open live tv and use your keyboard to check out the new controls.

Note: If you're using the official Xbox remote you'll need to alter the lirc config file to chose which button alters volume control. I'll add a guide for that later on. Also, other programs may still have problems with audio control. See George's original guide for more info on that; I'll update if I have any problems myself.


Enable Shutdown / Restart

As is, the option for "Yes, Exit and Shutdown" on the exit screen will just restart X. Handy if you're testing modelines, not so much if you actually wanna shut down. To fix, you can either run "chmod +s /sbin/halt" as root, or do as I do and add the following line to the end of /etc/sudoers:

mce    ALL=/sbin/shutdown

and change the shutdown command in general setup to:

sudo /sbin/shutdown -h now

Note that -h will shutdown and -r will restart so change to suit your needs.


Kill That Damn Mouse

After about 30 seconds of navigating setup screens with the Xbox remote you'll likely notice something pretty annoying; the remote is functioning as a mouse AND remote leading to clicks in the wrong place, multiple clicks etc...

The fix is simple though, just tell the X Server not to use it as a mouse and just let Lirc do it's thing. Open up the X config file by typing the following:

nano /etc/X11/XF86Config-4-xbox

and edid the file as so. Firstly, comment out the whole InputDevice section for the LIRC-Mouse entry (near the top of the file) as so:

#Section "InputDevice"
#       Identifier  "LIRC-Mouse"
#       Driver      "mouse"
#       Option      "Device" "/dev/lircm"
#       Option      "Protocol" "ImPS/2"
#       Option      "SendCoreEvents"
#       Option      "Buttons" "5"
#       Option      "ZAxisMapping" "4 5"
#EndSection

And finally, edit out the LIRC-Mouse line in the ServerLayout section (near the bottom of the file) so the whole section looks as so:

Section "ServerLayout"
        Identifier      "Default Layout"
        Screen          "Default Screen"
        InputDevice     "Generic Keyboard"
        InputDevice     "Configured Mouse" 
#       InputDevice     "LIRC-Mouse"
EndSection

If you miss out the last bit, the X Server will refuse to start so you'll have to ssh back in and do it properly. Now save using Ctrl-X, Y, Enter and restart X by typing "killall mythfrontend". Tadaa, no more mouse-remote :o) . And any other mouses you connect via use will still work fine.


Change Image Properties

WORK IN PROGRESS - If anyone has experience with xbox video optimisation I'd appreciate your input; most mailing lists haven't been touched for years and anyone who did once know things seems to not have touched their xbox for just as long...

Note: the following only applies to pre 1.6 xboxes. If you have a 1.6, you'll need to use a workaround such as this to correct overscan.

Resolution

I'm still working on this, but basically you wanna edit /etc/X11/XF86Config-4-xbox to add your wanted modeline under the Monitor section and change the "640x480" modes lower down the file to the name of your modeline. These are what I'm using at the moment:

Modeline "768x576" 28.44 768 800 904 936 576 588 593 605 -Hsync -Vsync
Modeline "720x576" 27.000 720 760 824 864 576 599 601 625 -Hsync -Vsync

Note that due to a bug in X, 720xXXX modelines will cause corruption in the MythUI, but do work fine when running video. Because of this, you can use the "seperate vid modes for gui + vid" setting to use a non-720 modeline for the GUI and a 720 modeline for video if you so wish. Also, due to the way the xbox outputs video, all timing information other than the dotclock and resolution in the modeline will be ignored, so you cannot use them to change the positioning of an image, and the xvidtune app will have no affect.

There is no need to use xbv or fbset to change resolutions; these do exactly the same thing.


Overscan

For overscan correction, append the following to the end of the "append" line in linuxboot.cfg, found in E:/debian when running FTP to the xbox (using a modded dashboard) regardless of whether you installed to E: or F:.

video=xbox:hoc=0,voc=0

Change the 0's for horizontal and vertical overscan correction to a number between 0 and 20. These work in percentages, with 0 being no overscan and 20 being 20% overscan. Note that to keep the original aspect ratio of the image, both percentage numbers should be kept the same, eg. hoc=10.voc=10.

You can also use the following command to change overscan on the fly; again with values between 0 and 20 inplace of the two 0s, eg xboxfbctl -o 10,10.

xboxfbctl -o 0,0


Flicker Filter

On 1.0 to 1.3 xboxes (with conexant video chips) the flicker filter defaults to 5, the highest filter setting, to smoothen any flicker that would be visible due to interlacing. Unfortunately this leaves you with an image with much less sharpness to it, and is not really suitable for video playback.

Firstly, use the following command to give printout of your current filter settings, and note you need to be root to do this:

xbv -d

Within the output you should see the flicker filter settings listed like this:

Flicker: DIS_FFILT=0, ADPT_FF =1, DIS_YLPF =1
F_SELY =3, F_SELC =3, Y_ALTFF =0
C_ALTFF =0, Y_THRESH=4, C_THRESH =4
YSELECT =1, FFRTN =1, PKFIL_SEL=0

If you do not see any filter settings (or the command will not run; you did run it as root?) then you should probably avoid doing the following. Otherwise, make a record of the current settings, then try this:

xbv DIS_FFILT 1

This should disable the flicker filter on conexant chips, and the result should be clear on any text or detail in a video. Unfortunately this then means any gui text will look terrible, and may also introduce too much flicker during video playback. You can either put up with it, or compromise with the filter enabled but at a much lower setting.

xbv DIS_FFILT 0 DIS_YLPF 0 Y_ALTFF 2 Y_THRESH 2 PKFIL_SEL 3

After this you can swap back to the original defaults by swapping the values in the line with the original ones from the xbv -d command. Because you can change the commands on the fly, try swapping between defaults with filter disabled, and the last line above with a low filter setting, and see if you can make out the differences. The filtered setting should show a very slight bluring of detailed images during video but not much less flicker, but as the disabled filter cause loads of flicker in the gui you may wish to either continue using the filtered line, or use a script to change between the two depending on whether you're watching video or in the gui.


Script time. Now, as I found the disabled filter too flickery for my eyes (you may be different), the below script uses the enabled but lower filter command. You can edit it to suit your needs, either change the whole xbv DIS... line to just xbv DIS_FFILT 1, or even create nested if loops to change the setting based on resolution (assuming you use different resolution for video and gui), but I'll start with the easy stuff.

First up, ignore all the above commands as you won't need them after this. And note you need to use the script if you want to change the settings at all from default as they'll keep resetting to defaults every time you switch between gui and video (may be something to do with res change...). So... Create the script in /home/mce by typing:

nano /home/mce/flickerchanger

Copy and paste this lot in to it:

#!/bin/sh
# FlickerFilterChanger script by pepsi_max2k
# Version 1.0

# Loop forever
while [ true ]
do
    # Wait 1.5  minutes
    sleep 90;
    # If flicker filter is at defaults
    if [ "`/usr/bin/sudo /usr/bin/xbv -d | grep 'DIS_YLPF =1'`" != "" ]; then
        /usr/bin/sudo /usr/bin/xbv DIS_FFILT 0 DIS_YLPF 0 Y_ALTFF 2 Y_THRESH 2 PKFIL_SEL 3
    fi
done

The above will run indefinately, checking to see if the filter is at default settings and changing them if so, then waiting 1.5 minutes and checking again. It does this because, as I said, the filter reverts to defaults whenever you switch between gui and video (including the Program Guide). At worst, you'll have to watch 1.5 minutes of video before the filter settings are lowered (you probably won't even notice when it does). I didn't want to lower it much more because I don't want it constantly running the xbv command as I've no idea what performance impact that might have (however small), but you can change it if you want.

Anyway, now you need to get it running. First, make the MCE user the owner and make the file executable:

chown mce:mce /home/mce/flickerchanger
chmod 755 /home/mce/flickerchanger

Now ensure that the mce user can actually run the xbv command by altering the MCE line in /etc/sudoers (nano /etc/sudoers) to look as follows:

mce     ALL=/sbin/shutdown, /usr/bin/xbv

And finally add the flickerchanger script to the .xinitrc file (nano /home/mce/.xinitrc)to run it at startup. The whole file should look like this:

exec /usr/bin/ratpoison &
exec /home/mce/flickerchanger > /dev/null 2>&1 &
exec /usr/bin/mythfrontend

And that should be it. Just run xbv -d to check on it and you should see the filter settings change after 1.5 minutes every time they're at defaults.


Slightly more advance stuff - Assuming you're using seperate resolutions for video playback and you want to use seperate flicker modes for gui and video, you can query xdpyinfo for the current resolution setting and run the required xbv command depending on which resolution (representing video or gui) is currently set.

The following script WILL NOT WORK but you can use it as a guide to get your own setup working.

#!/bin/sh
# FlickerFilterResChanger script by pepsi_max2k
# Version 0.1 

FILTER=1

while [ true ]
do
    sleep 5;
    # If video res active, disable filter
    if [ "`xdpyinfo -display :0 | grep '720x576'`" != "" ]; then
        # Don't change FFILT if already disabled
        if [ $FILTER = 0 ]; then
            break
        else
            xbv DIS_FFILT 1
            FILTER = 0
        fi
    # If non-video res active, enable filter.
    else
        xbv DIS_FFILT 0
        FILTER = 1
    fi
done

My aim was to query the display for the current resolution size, change filter settings based on it, and try not to change anything if nothing's changed from the last check. You may have problems if a user other than mce runs the xdpyinfo command but i think there's a way to allow access to mce's display by other users somehow, you'll have to google it. You also may have to add the correct sudo commands and add commands to /etc/sudoers, and also just actually make the loop work as intended. Or just ignore it, that's what I did ;o) .

Video Filters / Colour

By default the video output on my system (using a Hauppauge Nova-T DVB-T card, and RGBs scart to an old CRT) has a slightly washed-out look with faces looking a little too pink. To fix this I did a number of things, the easiest being increase the colour and decrease the brightness and contrast on my TV set.

Secondly you can alter Contrast, Brightness, Colour and Hue settings within Mythfrontend by selecting the "Use Xv picture controls" option from Setup > TV > Playback then pressing F during playback and left/right/enter to change. Personally though I just alter that kind of thing on my TV set.

If you're happy with the image after this, lucky you. I spent a whole week messing around with different filter settings to come up with a single line...

Under Settup > TV > Playback in the Custom Filters line add:

adjust=18:237:1.0:25:230:1.0

This basically slightly darkens the image and brownens up the reds to make it look a little more glossier and less washed out. You may want to try some different settings out for yourself so here's some tips to help you out:

The playback filter documentation contains info on the exact useage of the adjust filter, and some details on a good filter for bttv devices.

adjust=34:253:1.0:23:232:1.0 - This filter is a little dark. adjust=18:237:1.0:35:220:1.0 - This one's a little too pink for flesh colours. Note that my recommended filter above was a combination of the pinker filter's lighter luma settings and what I felt was a good chroma setting inbetween the two above filters.

For permanent mysql based changes (where you can change hue/colour/bright/cont too) you can try these (enter at mysql prompt on backend):

update channel set contrast=23200,brightness=34000,colour=32000,hue=32768;
update channel set videofilters='adjust=18:237:1.0:35:220:1.0';
update channel set contrast=21500,brightness=37500,colour=32768,hue=32768;
update channel set videofilters='adjust=34:253:1.0:23:232:1.0';

Non-Conexant Xboxes

If you are using a PAL CRT and have a 1.4 or 1.5 xbox that uses a Focus video chip, you may be interested in this guide for a suitable modeline setup. I'm also not sure which of the above overscan / filter commands will work, but I'm assuming they all do for now.

If you own a 1.6 Xbox with an Xcalibur video chip, you'll likely have problems with one or more of the above. From what I can tell, the resolution is stuck at 640x480 and you can only use composite output, altering the flicker settings is probably a bad idea (xbv -d runs and lists a connexant encoder which we know isn't there so god knows what altering it's registers will do). As far as I know the linuxboot.cfg overscan corrections don't work either, although the inbuilt mythtv ones do. Check this out for an overscan workaround if you really want it: http://forums.xbox-scene.com/index.php?showtopic=635670

Known/Possible Issues

Jack Lowry has had a problem with his backend (Slackware 10.2, myth .19, mysql to 4.1.4) and his upgrading his xbox (xebian + mythtv 0.18 -> 0.19) with a mysql problem

But now I have a mysql version issue, when myth tries to make a 
connection to the mysql database I get a message in the .xsession-errors 
file that says:
ERROR 1251: Client does not support authentication protocol requested by 
server; consider upgrading MySQL client
I've also tried the mysql client and got the same error message.

It seems newer versions of mysql use a new password scheme that's compatible with the mysql client compiled into myth packages I was using. The following link provides several methods to work beyond this problem. I created a new user for my xbox frontend using the old format password.

http://dev.mysql.com/doc/refman/4.1/en/old-client.html

Another alternative is to check the my.cnf file on the server. It may contain an option to enable old-scheme passwords. Also, if you are unable to connect to the database check the my.cnf file to see if mysql is bound to an actual network address and not 127.0.0.1.

A simpler (MythTV) related solution to this problem can be found at the following link:

http://www.xbox-linux.org/wiki/MythTV_on_Xebian_HOWTO

Bear in mind that MythTV on the X-Box will run under the userid "live" and the instructions in the link above assumes the X-Box MySQL userid is also "live", so make sure you use this userid when configuring via mythtvsetup (runs by default first time) or by editing /home/live/.mythtv/mysql.txt.