Freevo Media Center

From Knowledge76

Jump to: navigation, search

Contents

Overview

This howto details configuring a Koala Mini Performance PC as a Freevo media center home theater system connected to an HDTV. When done, the computer will automatically boot into a fullscreen Freevo display. All interaction with the PC will be through menus via an infrared remote. Remote SSH shells and VNC desktops are still possible, or you can keep a keyboard+mouse and switch from Freevo to Gnome via ctrl+alt+f7/f8.

"Freevo is an open-source home theatre PC platform based on Linux and a number of open-source audio/video tools. MPlayer and/or Xine can be used to play audio and video files in most popular formats. Freevo can be used both for a standalone PVR computer with a TV+remote, as well as on a regular desktop computer using the monitor and keyboard." http://freevo.sourceforge.net

Hardware

System76 KOA-P1 Koala Mini Performance PC http://system76.com/product_info.php/cPath/2/products_id/169

Westinghouse LTV-37w2 HD 37" LCD HDTV http://www.westinghousedigital.com/details.aspx?itemnum=53

Western Digital WDXC3200JB Extreme Lighted External 320GB Hard Drive http://www.westerndigital.com/en/products/products.asp?DriveID=153

Evation Irman Infrared Receiver http://www.evation.com/irman/

Keyspan USA-19W USB High Speed Serial Adapter http://www.keyspan.com/products/usb/usa19hs/

Sony RMV302 5-in-1 Universal Remote Control http://www.sonystyle.ca/commerce/servlet/ProductDetailDisplay?storeId=10001&productId=165198

PFU Happy Hacking Lite 2 USB Keyboard http://www.pfu.fujitsu.com/en/hhkeyboard/

Logitech MX500 Optical Mouse http://www.logitech.com/index.cfm/products/details/US/EN,CRID=3,CONTENTID=4998

Boston Acoustics BA635 Computer Speakers http://www.bostonacoustics.com/

Ubuntu Linux Update

Please note that I executed most of these commands remotely via ssh into the machine as root, but any way you can get to the command line is fine.

First we update our Ubuntu Dapper LTS apt sources.

/etc/apt/sources.list:

deb http://us.archive.ubuntu.com/ubuntu/ dapper main restricted universe multiverse
deb http://us.archive.ubuntu.com/ubuntu/ dapper-updates main restricted universe multiverse
deb http://us.archive.ubuntu.com/ubuntu/ dapper-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu dapper-security main restricted universe multiverse
deb http://planet76.com/repositories/ ./
deb http://ubuntu.geole.info/ dapper universe multiverse


Get the freevo repository key.

# wget http://www.geole.info/fileadmin/data/misc/geole.info-apt-key.gpg
# apt-key add geole.info-apt-key.gpg

And now update our system.

# apt-get update
# apt-get dist-upgrade

Custom Kernel Build

We need to rebuild the kernel to support the usb to serial converter firmware, which is disabled in the stock Ubuntu/Debian kernels.

# apt-get install build-essential kernel-package initrd-tools libncurses5-dev
# cd /usr/src
# wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.17.6.tar.bz2
# tar xjvf linux-2.6.17.6.tar.bz2
# cd linux-2.6.17.6
# cp /boot/config-2.6.15-23-686 .config
# make menuconfig # enable keyspan firmware
# make-kpkg clean
# INITRD_OK=1 make-kpkg --initrd --revision=mcpc.1.0  kernel_image
# cd ..
# dpkg -i kernel-image-2.6.17.6_mcpc.1.0_i386.deb
# reboot

The Ubuntu framebuffer usplash isn't there on mine any more. Did I miss something when building from a vanilla kernel?

HDTV Widescreen Display

My LCD HDTV has a "PC" input in the form of a VGA / HD15 / D-Sub connector. You can use a DVI to HD15 cable to connect. There is also an HDMI input, which does work with a DVI to HDMI cable.

To configure the Intel 945GM inegrated graphics to our target resolution for the HDTV, we need the 915resolution tool

# apt-get install 915resolution

My particular HDTV manual recommends an optimal 16:9 display of 1366x768 at 60Hz. After playing around, I was only able to configre the 945GM to 1360x768 with 915resolution.

add to the bottom of /etc/init.d/bootmisc.sh before the exit statement:

# hdtv resolution
# /usr/sbin/915resolution 58 1360 768 32

and edit /etc/default/915resolution:

MODE=58
XRESO=1360
YRESO=768
BIT=32

Noticed that I have commented out the DRI and GLX modules to increase video memory available to xv X-Video. If I don't disbale DRI, I end up receiving a insufficient memory error when playing hdtv resolution content. I am also allowing no keyboard or mouse so the X server doesn't error out when they are not connected.

/etc/X11/xorg.conf:

Section "Files"
       FontPath        "/usr/share/X11/fonts/misc"
       FontPath        "/usr/share/X11/fonts/cyrillic"
       FontPath        "/usr/share/X11/fonts/100dpi/:unscaled"
       FontPath        "/usr/share/X11/fonts/75dpi/:unscaled"
       FontPath        "/usr/share/X11/fonts/Type1"
       FontPath        "/usr/share/X11/fonts/100dpi"
       FontPath        "/usr/share/X11/fonts/75dpi"
       FontPath        "/var/lib/defoma/x-ttcidfont-conf.d/dirs/TrueType"
EndSection

Section "Module"
       Load    "i2c"
       Load    "bitmap"
       Load    "ddc"
       #Load   "dri"
       Load    "extmod"
       Load    "freetype"
       #Load   "glx"
       Load    "int10"
       Load    "type1"
       Load    "vbe"
EndSection

Section "InputDevice"
       Identifier      "Generic Keyboard"
       Driver          "kbd"
       Option          "CoreKeyboard"
       Option          "XkbRules"      "xorg"
       Option          "XkbModel"      "pc104"
       Option          "XkbLayout"     "us"
EndSection

Section "InputDevice"
       Identifier      "Configured Mouse"
       Driver          "mouse"
       Option          "CorePointer"
       Option          "Device"                "/dev/input/mice"
       Option          "Protocol"              "ExplorerPS/2"
       Option          "ZAxisMapping"          "4 5"
       Option          "Emulate3Buttons"       "true"
EndSection

Section "Device"
       Identifier      "Intel Corporation Mobile Integrated Graphics Controller"
       Driver          "i810"
EndSection

Section "Monitor"
       Identifier      "S/T 97B/96B"
       Option          "DPMS"
       HorizSync 30-50
       VertRefresh 60
EndSection

Section "Screen"
       Identifier      "Default Screen"
       Device          "Intel Corporation Mobile Integrated Graphics Controller"
       Monitor         "S/T 97B/96B"
       DefaultDepth    24
        SubSection "Display"
               Depth           24
               Modes "1360x768"
       EndSubSection
EndSection

Section "ServerFlags"
       Option  "AllowMouseOpenFail"
       Option  "AllowKeyboardOpenFail"
EndSection

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

You can hit ctrl+alt+backspace or reboot at this point to get your new resolution.

The xvinfo command reports "maximum XvImage size: 1440 x 1080", so we have room to grow.

Freevo Install

Use apt to install all the required software packages, video players, codecs, etc. As of my last check, this will install freevo version 1.5.4-0ubuntu0.

# apt-get install freevo lirc rungetty xvattr unclutter xine-ui libxine-extracodecs libdvdread3 mplayer regionset w32codecs aumix

Let's set up the DVD drive

# /usr/share/doc/libdvdread3/examples/install-css.sh
# regionset /dev/hdb

LIRC Config

We must configure our remote to work. I have attached the IRman remote sensor to the Serial to USB converter.

set your hardware type and device by editing /etc/lirc/hardware.conf:

DRIVER="irman"
DEVICE="/dev/ttyUSB0"

make a config file for lirc:

# cd /etc/lirc
# /etc/init.d/lirc stop
# irrecord -H irman -d /dev/ttyUSB0 lircd.conf
# /etc/init.d/lirc start

you can then see the mappings when pushing remote buttons with this command:

# irw

make an lirc config in /etc/freevo/lircrc mapping buttons to freevo commands, Eg:

begin
   prog = freevo
   button = ch_up
   config = CH+
   repeat = 2
end

you can then see the mapped freevo commands when you press buttons with this tool:

# ircat --config=/etc/freevo/lircrc freevo

needed commands: POWER CH- CH+ VOL- VOL+ 0-9 DISPLAY ENTER DOWN UP LEFT RIGHT FFWD REW PAUSE PLAY STOP REC EJECT TITLE

Freevo Config

We will configure Freevo fullscreen 16:9 . It will use Xine for DVD playback, and MPlayer for everything else.

/etc/freevo/freevo.config excerpts:

display = x11
geometry = 1360x768

Here are some of my essential setting.

/etc/freevo/local_conf.py excerpts:

CONTROL_ALL_AUDIO   = 0
MAJOR_AUDIO_CTRL    = 'PCM'
MAX_VOLUME          = 100
DEFAULT_VOLUME      = 60
plugin.remove('mixer')
plugin.activate('ossmixer')

plugin.remove('tv') # Sorry, I don't like broadcast tv.
plugin.remove('shutdown')

plugin.activate('headlines', level=45)
HEADLINES_LOCATIONS = [
("Top Stories", "http://rss.news.yahoo.com/rss/topstories"),
("Most Emailed", "http://rss.news.yahoo.com/rss/mostemailed"),
("Word of the Day", "http://www.dictionary.com/wordoftheday/wotd.rss"),
("Digg", "http://digg.com/rss/index.xml"),
("Slashdot", "http://slashdot.org/index.rss"),
("Anime BitTorrents", "http://www.downloadanime.org/torrentrss.php") ]

plugin.activate('weather', level=45)
PLUGIN_WEATHER_LOCATIONS = [ ("12345") ]

plugin.activate('idlebar')
plugin.activate('idlebar.clock',   level=50)

plugin.activate('image.apod', args=('/home/freevo/apod',))

START_FULLSCREEN_X  = 1

EVENTS['video']['1'] = Event(VIDEO_SEND_MPLAYER_CMD, arg='switch_audio')
EVENTS['video']['4'] = Event(VIDEO_SEND_MPLAYER_CMD, arg='sub_select')
EVENTS['video']['7'] = Event(VIDEO_SEND_MPLAYER_CMD, arg='sub_remove')

EVENTS['video']['2'] = Event(VIDEO_SEND_MPLAYER_CMD, arg='speed_incr +.10')
EVENTS['video']['5'] = Event(VIDEO_SEND_MPLAYER_CMD, arg='speed_incr -.10')
EVENTS['video']['0'] = Event(VIDEO_SEND_MPLAYER_CMD, arg='frame_step')

EVENTS['video']['3'] = Event(VIDEO_SEND_MPLAYER_CMD, arg='panscan +.05')
EVENTS['video']['6'] = Event(VIDEO_SEND_MPLAYER_CMD, arg='panscan -.05')

EVENTS['video']['8'] = Event(VIDEO_SEND_MPLAYER_CMD, arg='switch_ratio 1.33334')
EVENTS['video']['9'] = Event(VIDEO_SEND_MPLAYER_CMD, arg='switch_ratio 1.77778')

VIDEO_ITEMS = [ ('Video Archive', '/media/video'),
               ('Downloads',     '/dl') ]

AUDIO_ITEMS = [ ('MP3 Collection', '/media/mp3') ]

IMAGE_ITEMS = [ ('Eyecandy Archive', '/media/eyecandy') ]
 
MPLAYER_VERSION = 0.9
MPLAYER_ARGS = { 'dvd'    : '-cache 8192 -monitoraspect 16:9 -af volnorm=2 -vf pp=fd',
                 'vcd'    : '-cache 4096 -monitoraspect 16:9',
                 'cd'     : '-cache 1024 -cdda speed=2',
                 'mkv'    : '-cache 5000 -idx -alang jpn,ja -slang eng,en,En -framedrop -monitoraspect 16:9 -af volnorm=1',
                 'ogm'    : '-cache 5000 -aid 1 -sid 0 -monitoraspect 16:9',
                 'tv'     : '-nocache',
                 'ivtv'   : '-cache 8192',
                 'avi'    : '-cache 5000 -monitoraspect 16:9 -af volnorm=1',
                 'mpg'    : '-cache 5000 -monitoraspect 16:9 -af volnorm=1 -vf pp=fd',
                 'rm'     : '-cache 5000 -forceidx',
                 'rmvb'   : '-cache 5000 -forceidx -monitoraspect 16:9',
                 'webcam' : 'tv:// -tv driver=v4l:width=352:height=288:outfmt=yuy2:device=/dev/video2',
                 'default': '-cache 5000 -monitoraspect 16:9 -af volnorm=1'
                 }

XINE_ARGS_DEF = '--no-lirc --deinterlace'

GAMES_ITEMS = [
               ('Atari 2600', '/media/atari', ('GENERIC', '/usr/games/stella', '-zoom 4 -fullscreen -hidecursor -sound 1 -video soft', ' ', [ 'bin' ] ))
]

For some reason, the main volume control only adjusts the built-in speaker of the Mini PC. I had to edit some code to force Freevo to use PCM2 to adjust the "Headphone" jack volume I plug my speakers into.

edit /usr/lib/python2.4/site-packages/freevo/plugins/ossmixer.py:

    def setPcmVolume(self, volume):
       self.pcmVolume = volume
       #self._setVolume(ossaudiodev.SOUND_MIXER_PCM, volume)
       self._setVolume(ossaudiodev.SOUND_MIXER_ALTPCM, volume)

   def incPcmVolume(self):
       self.pcmVolume += 5
       if self.pcmVolume > 100:
           self.pcmVolume = 100
       #self._setVolume( ossaudiodev.SOUND_MIXER_PCM, self.pcmVolume )
       self._setVolume( ossaudiodev.SOUND_MIXER_ALTPCM, self.pcmVolume )

   def decPcmVolume(self):
       self.pcmVolume -= 5
       if self.pcmVolume < 0:
           self.pcmVolume = 0
       #self._setVolume( ossaudiodev.SOUND_MIXER_PCM, self.pcmVolume )
       self._setVolume( ossaudiodev.SOUND_MIXER_ALTPCM, self.pcmVolume )


To get the DVD menu button to work, I had to edit some code.

edit /usr/lib/python2.4/site-packages/freevo/event.py:

DVD_EVENTS = {
   'PLAY'      : PLAY,
   'PAUSE'     : PAUSE,
   'STOP'      : STOP,
   #'EXIT'      : STOP,
   'EXIT'      : DVDNAV_TITLEMENU,
   'EXIT'      : DVDNAV_MENU,
   'UP'        : DVDNAV_UP,
   'DOWN'      : DVDNAV_DOWN,
   'LEFT'      : DVDNAV_LEFT,
   'RIGHT'     : DVDNAV_RIGHT,
   'ENTER'     : DVDNAV_SELECT,
   'SELECT'    : DVDNAV_SELECT,
   'DISPLAY'   : TOGGLE_OSD,
   'SUBTITLE'  : VIDEO_NEXT_SUBTITLE,
   'REW'       : Event(SEEK, arg=-10),
   'FFWD'      : Event(SEEK, arg=10),
   #'GUIDE'     : DVDNAV_TITLEMENU,
   'GUIDE'     : DVDNAV_MENU,
   'MENU'      : DVDNAV_MENU,
   'LANG'      : VIDEO_NEXT_AUDIOLANG,
   'SUBTITLE'  : VIDEO_NEXT_SUBTITLE,
   'ANGLE'     : VIDEO_NEXT_ANGLE,
   'CH+'       : NEXT,
   'CH-'       : PREV
   }

While trying out new code and config options, you can restart freevo remotely with this command:

$ sudo rm -f /var/log/autologin ; sudo killall freevo; sudo killall rungetty

Auto Start

We will disable the Gnome GDM login manager, and instead start a bare xsession with only freevo using the entire fullscreen display. Rungetty will autologin freevo on TTY1 and then start X Windows.

first create the freevo user

# adduser freevo
# adduser freevo cdrom
# adduser freevo video 
# adduser freevo audio

Then edit some dot files in freevo's home directory.

add to the end of /home/freevo/.bash_profile:

export SDL_AUDIODRIVER=alsa

if [ "$TERM" = "linux" -a `tty` = "/dev/tty1" ]; then
       startx -- :1 -br ; exit
fi

create /home/freevo/.xsession:

# turn off screen blanking
/usr/bin/X11/xset s off
/usr/bin/X11/xset -dpms

# allow local user access to windows
/usr/bin/X11/xhost +local:

# make blue bars black
/usr/bin/xvattr -a XV_COLORKEY -v 0

# showtime
/usr/bin/X11/xsetroot -solid "#000000" &
/usr/bin/unclutter -idle 1 &
#xterm -font 9x15
/usr/bin/freevo

make sure the .xsession is executable

# chmod +x /home/freevo/.xsession

edit /etc/inittab to start rungetty autologin of the freevo user:

#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
1:345:respawn:/sbin/getty 38400 tty1
7:2:respawn:/sbin/rungetty tty1 --autologin freevo

disable GDM

# mv /etc/rc2.d/S13gdm /etc/rc2.d/O13gdm
# /etc/init.d/gdm stop
# init q

That's it. Not for the faint of heart. Now reboot and enjoy all your snail mail flix and bittorrent downloads!

MPlayer Tweaks

I have tweaked the on screen display font size, and I have also enabled sound normalization with mplayer.

/home/freevo/.mplayer/config:

zoom=yes
fs=yes
monitoraspect=16:9
af=volnorm
subfont-autoscale=1
subfont-osd-scale=5
subfont-text-scale=5


ToDo

- can one recompile _only_ the missing keyspan firmware driver? recompiling the whole kernel for one module firmware is a pain.

- can we force 1366x768? because 1366x768 at 60Hz is the recommended video mode.

Personal tools