Thursday, December 08, 2005

Getting MythVideo to use 16:9 aspect ratio

When I last left off, MythTV was using my 61MD10 61" HDTV in full 1280x720, but MythVideo was stretching my HDTV .avi files too wide and showing black bars on the top and bottom. As it turns out, mplayer isn't able to autodetect the 16:9 aspect ratio.

Thanks to this post, I found that I needed to supply this information in the MythVideo playback settings.

Here's my new mplayer command:

mplayer -monitoraspect 16:9 -fs -zoom -quiet -vo xv -ao esd %s

Wednesday, December 07, 2005

My 720p xorg.conf

# /etc/X11/xorg.conf (xorg X Window System server configuration file)

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/CID"
FontPath "/usr/share/X11/fonts/100dpi"
FontPath "/usr/share/X11/fonts/75dpi"
# paths to defoma fonts
FontPath "/var/lib/defoma/x-ttcidfont-conf.d/dirs/TrueType"
FontPath "/var/lib/defoma/x-ttcidfont-conf.d/dirs/CID"
EndSection

Section "Module"
Load "GLcore"
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" "ImPS/2"
Option "Emulate3Buttons" "true"
Option "ZAxisMapping" "4 5"
EndSection


Section "Device"
Identifier "NVidia"
Driver "nv"
VendorName "nVidia Corporation"
BoardName "NV28 [GeForce4 Ti 4200 AGP 4x]"
BusID "PCI:1:0:0"
EndSection

Section "Monitor"
Identifier "HDTV"
VendorName "InFocus"
ModelName "61MD10"
VertRefresh 30-90
HorizSync 20-150
# No clue if this is a good ModeLine to use
ModeLine "ATSC-720-59.94p" 74.176 1280 1320 1376 1650 720 722 728 750
EndSection

Section "Screen"
Identifier "HDTV Screen"
Device "NVidia"
Monitor "HDTV"
DefaultDepth 24
SubSection "Display"
Viewport 0 0
Depth 24
Modes "1280x720"
EndSubSection
EndSection

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

Section "DRI"
Mode 0666
EndSection

MythTV in 720p

I'm setting up my Myth box to use my new Infocus 61" 61MD10 HDTV, and having a much smoother time than I expected. I was going to get a PCHDTV3000 card to record HDTV, but later learned that it can only record over-the-air (OTA) broadcasts, not encrypted HDTV that comes over the cable lines.

Considering that our HDTV formats are still in flux, and might go towards cablecard in the next year, I'm going to just be happy with big, fuzzy regular TV recordings on a big screen. I think I'm okay with that. I decided that if I could get X working in full 720p resolution, that I could at least play HDTV recordings that I happen to find elsewhere.

So, I put in my NVidia video card with DVI output. I have a DVI->HDMI cable which I used to plug my Myth box into the tv. I was very surprised that my original xorg.conf file that the Ubuntu install created worked the first try with the DVI output!

TV playback is working great, but my HDTV playback with mplayer is stretching the videos width-wise, so I gotta look into why that's happening.

In any case, I found some good (?) Modelines here

I'll post my end xorg.conf in the next post.

Thursday, December 01, 2005

Annoying myth backend problems

Occasionally I run into a problem where I can't delete a show, and the frontend hangs because of it. I restart the backend and frontend, then all systems are go. It looks like when the backend gets in this state that no shows are recorded either.

I just looked through the mythbackend logs to look for anything out of the ordinary. I found one line this morning that looked interesting:

/var/log/mythtv/mythbackend.log.1:2005-12-01 02:58:36.786 unknown socket


There's not too much information there, so I looked for that same error across the archived logs, and found a bunch:

/var/log/mythtv/mythbackend.log:2005-12-01 07:57:30.304 unknown socket
/var/log/mythtv/mythbackend.log.1:2005-11-30 07:40:11.621 unknown socket
/var/log/mythtv/mythbackend.log.1:2005-12-01 02:58:36.786 unknown socket
/var/log/mythtv/mythbackend.log.2:2005-11-29 07:40:24.165 unknown socket
/var/log/mythtv/mythbackend.log.2:2005-11-30 02:55:11.343 unknown socket
/var/log/mythtv/mythbackend.log.3:2005-11-28 07:38:55.313 unknown socket
/var/log/mythtv/mythbackend.log.3:2005-11-29 02:53:19.537 unknown socket
/var/log/mythtv/mythbackend.log.4:2005-11-27 07:38:47.522 unknown socket
/var/log/mythtv/mythbackend.log.4:2005-11-28 02:49:52.655 unknown socket
/var/log/mythtv/mythbackend.log.5:2005-11-26 07:39:36.989 unknown socket
/var/log/mythtv/mythbackend.log.5:2005-11-27 02:47:05.457 unknown socket
/var/log/mythtv/mythbackend.log.6:2005-11-25 07:39:38.032 unknown socket
/var/log/mythtv/mythbackend.log.6:2005-11-26 02:43:37.770 unknown socket
/var/log/mythtv/mythbackend.log.7:2005-11-24 07:40:56.346 unknown socket
/var/log/mythtv/mythbackend.log.7:2005-11-25 02:40:18.666 unknown socket


What's unusual is that these all happen at two times: 2:40am and 7:40pm. I'm not sure these messages have anything to do with this problem, but it's interesting nonetheless. I don't have any crontabs scheduled, but I'm wondering if this is when the backend is looking for new tv listings.

Something to look into..

Has anyone else out there had the delete problem, or any idea what these messages are?

Tuesday, November 29, 2005

Watching "Dirty Jobs" from my bathroom!

That's right, I'm so excited about MythTV that I'm blogging from the crapper, and am damn proud of it. Right now, I'm on the toilet, running MythTV frontend on my laptop which is wirelessly connected to my MythTV backend. And yes, the bathroom door is shut :D

I wasn't able to get this working well with my last MythTV setup, so I figured that with 1 hour shows being 1.1GB, that it must have been a network problem. Well, it's working great with my new backend server, so as it turns out, the poor performance must have come from the backend machine itself.

My Hardware:
My last backend box was a 733MHz P3; my new one is a 2.4GHz P4. My laptop frontend is a 1.73GHz Centrino with plenty of power.

My Network:
802.11g WPA. I'm upstairs from my DLink wireless router (I used to use a LinkSys, but found it had awful range) with the door closed.

My Performance:
I'm a code monkey Linux geek, and honestly, I have no idea how I'm getting this kind of performance over a wireless network. This 1-hour-long show I'm watching is takes up more than 1GB of disk space, and I'm able to start watching the video, and jump through it quickly. The menus are a little sluggish, and it takes about 2-3 seconds to start up a recording, but once it starts up, the video is running really well. Even FFWD/RWD is responsive, only giving me about a 1 second lag.

To compare, I tried running a mplayer on this file through a remote X ssh shell. I was able to see about 1 frame a second. Again - it's amazing how great the MythTV frontend/backend connection works.

Conclusion:
I'm super-impressed - it looks like I won't have to run CAT5 cables throughout my house afterall. In fact, it might be a fun project to try to setup diskless computers around the house to network-boot linux and act as MythTV fronends. Of course if I get around to it, I'll post my results!

Way to go, MythTV team -- the client/server architecture holds up across a WPA wireless network!

Monday, November 21, 2005

What to Expect in Future Posts...

I have so much I need to post here, and wanted to give you a heads up so you know what to expect. I'm planning on posting the following (and then some):

* A description and schematic of the wiring for my setup. It includes 2 TV cards and three TV inputs

* My mplayer setup in MythVideo and how I'm dealing with audio/video sync problems

* Information on how I'm using Samba to dump videos and mp3s from other boxes into MythVideo and MythMusic

* A re-hash of my IRBlaster script that changes the channels on my Comcast Digital TV

* An explanation of my script that generates an iTunes-ready XML RSS Podcast for mp3s I drop in a specific directory -- useful for podcasts you need to manually grab

* The script I modified/wrote that transcodes tv shows to mpeg4 videos that are viewable by my "iPod with Video"

* Photos of my setup, and hopefully a video screenshot of my mythbox in action (if I can figure out how to do that)

* A loving and persuasive write-up about Ubuntu Linux

* The problems that my recent upgrade has overcome from my build a year ago

*** Answers to questions anyone might have for me -- please posts comments and I'll respond as soon as I can. This isn't an easy project, but once completed, you'll feel bad for your friends with Tivos!

Please offer feedback!

If this site was at all helpful, please let me know by leaving comments or emailing me at: "blake (NO SPACE) caldwell **AT** gmail DOT com"

Please also let me know if anything here was inaccurrate or if you'd like to elaborate on something I skimmed by quickly.

LIRC (Continued some more)

Create your lircd startup script:

#------------------------------------------------------
# /etc/init.d/lircd
echo "Setting up and starting LIRC"
modprobe lirc_i2c lirc_dev
/usr/local/sbin/lircd --device=/dev/lirc0
#------------------------------------------------------


Then set it to start automatically:
ln -s /etc/init.d/lircd /etc/rc5.d/S99lircd


Now, to test your lirc setup, first start the daemon by running "/etc/init.d/lircd start". Then, test it by running the command "irw". If you get "connection refused" or similar, then nope, this didn't work. If not, try hitting some buttons on the remote. If you see key codes printed out to your console, then you're in business and can stop reading this post.

Okay, you're still having problems? Assuminig you have more than one Hauppauge TV card in your box, try this for your /etc/init.d/lircd and repeat the above paragraph


#------------------------------------------------------
# /etc/init.d/lircd
echo "Setting up and starting LIRC"
modprobe lirc_i2c lirc_dev
/usr/local/sbin/lircd --device=/dev/lirc1
#------------------------------------------------------

Set your MySQL Password for mythconverg database

I believe mythbackend will create the mythconverg database and mythtv user, but I'm not sure the password it'll create for that user. Come up with a password, change it (I like to use webmin to do simple database stuff -- if you do too, remember to install it using Synaptic), then save the password in your /usr/share/mythtv/mysql.txt file so mythbackend knows what to use for the password:

#-------------------------------------------
# /usr/share/mythtv/mysql.txt
DBHostName=localhost
DBUserName=mythtv
DBName=mythconverg
DBPassword=mythtvpassword

Start MythTV-Frontend on login

You'll have to set mythfrontend to start automatically when you login as user mythtv, you'll need to add it to your startup session. I did it graphically, but I think you can do it by editing /home/mythtv/.gnome2/session-manual:

#--------------------------------------------------
# /home/mythtv/.gnome2/session-manual

[Default]
num_clients=1
0,RestartStyleHint=3
0,Priority=50
0,RestartCommand=mythfrontend
0,Program=mythfrontend

Set user mythtv to automatically log on after boot

You'll probably want to avoid the annoying login step every time you reboot your mythbox, so edit /etc/gdm/gdm.conf to do so. Look for your Automatic Login section, and make sure it looks like this:

[daemon]
# Automatic login, if true the first local screen
# will automatically logged
# in as user as set with AutomaticLogin key.
AutomaticLoginEnable=true
AutomaticLogin=mythtv

LIRC (Continued)

Here's my lirc config file for the user mythtv, located in /home/mythtv/.lircrc

#------------------------------------------------------
# ~/.mythtv/lircrc
#
# MythTV native LIRC config file for
# the grey Hauppauge remote
#
# By Jarod Wilson, 2003/12/21
# Amalgamated from Jeff Campbell's,
# .lircrc, the mythtv.org docs, and
# a few touches of my own. :)
#

# Channel Up
begin
prog = mythtv
button = CH+
repeat = 3
config = Up
end

# Channel Down
begin
prog = mythtv
button = CH-
repeat = 3
config = Down
end

# OK/Select
begin
prog = mythtv
button = OK
config = Space
end

# Play
begin
prog = mythtv
button = PLAY
config = Return
end

# Stop
begin
prog = mythtv
button = STOP
config = Esc
end

# Escape/Exit/Back
begin
prog = mythtv
button = BACK/EXIT
config = Esc
end

# Power Off/Exit
begin
prog = mythtv
button = OFF
config = Esc
end

# Red means stop!
begin
prog = mythtv
button = RED
config = Esc
end

# Pause
begin
prog = mythtv
button = PAUSE
repeat = 3
config = P
end

# Mute
begin
prog = mythtv
button = MUTE
repeat = 3
config = F9
end

# Fast forward (30 sec default)
begin
prog = mythtv
button = Rewind
repeat = 3
config = Left
end

# Rewind (10 sec default)
begin
prog = mythtv
button = Forward
repeat = 3
config = Right
end

# Skip forward (10 min default)
begin
prog = mythtv
button = SKIP
repeat = 3
config = PgDown
end

# Skip backward (10 min default)
begin
prog = mythtv
button = REPLAY
repeat = 3
config = PgUp
end

# Record
begin
prog = mythtv
button = RECORD
repeat = 3
config = R
end

# Delete
begin
prog = mythtv
button = BLANK
repeat = 3
config = D
end

# OSD browse
begin
prog = mythtv
button = GREEN
repeat = 3
config = O
end

# Display EPG while in live TV,
# View selected show while in EPG
begin
prog = mythtv
button = MENU
repeat = 3
config = M
end

# Scroll up
begin
prog = mythtv
button = VOL+
repeat = 3
config = Right
end

# Scroll down
begin
prog = mythtv
button = VOL-
repeat = 3
config = Left
end

# Bring up OSD info
begin
prog = mythtv
button = GO
repeat = 3
config = I
end

# Change display aspect ratio
begin
prog = mythtv
button = FULL
repeat = 3
config = W
end

# Seek to previous commercial cut point
begin
prog = mythtv
button = YELLOW
repeat = 3
config = Q
end

# Seek to next commercial cut point
begin
prog = mythtv
button = BLUE
repeat = 3
config = Z
end

# Numbers 0-9

begin
prog = mythtv
button = 0
repeat = 3
config = 0
end

begin
prog = mythtv
button = 1
repeat = 3
config = 1
end

begin
prog = mythtv
button = 2
repeat = 3
config = 2
end

begin
prog = mythtv
button = 3
repeat = 3
config = 3
end

begin
prog = mythtv
button = 4
repeat = 3
config = 4
end

begin
prog = mythtv
button = 5
repeat = 3
config = 5
end

begin
prog = mythtv
button = 6
repeat = 3
config = 6
end

begin
prog = mythtv
button = 7
repeat = 3
config = 7
end

begin
prog = mythtv
button = 8
repeat = 3
config = 8
end

begin
prog = mythtv
button = 9
repeat = 3
config = 9
end


### MPlayer lirc setup

# Show OSD
begin
prog = mplayer
button = MENU
repeat = 3
config = osd
end

# Pause playback
begin
prog = mplayer
button = PAUSE
repeat = 3
config = pause
end

# Skip ahead a minute if playing
# If paused, resume playing
begin
prog = mplayer
button = PLAY
repeat = 3
config = seek +1
end

# Stop playback and exit
begin
prog = mplayer
button = STOP
repeat = 3
config = quit
end

# Mute
begin
prog = mplayer
button = MUTE
repeat = 3
config = mute
end

# Seek back 10 seconds
begin
prog = mplayer
button = Rewind
repeat = 3
config = seek -10
end

# Seek forward 30 seconds
begin
prog = mplayer
button = Forward
repeat = 3
config = seek +30
end

# Quit
begin
prog = mplayer
button = BACK/EXIT
repeat = 3
config = quit
end

# Seek forward 10 minutes
begin
prog = mplayer
button = SKIP
repeat = 3
config = seek +600
end

# Seek backward 10 minutes
begin
prog = mplayer
button = REPLAY
repeat = 3
config = seek -600
end

# Toggle full-screen
begin
prog = mplayer
button = FULL
repeat = 3
config = vo_fullscreen
end

### Xine lirc setup

begin
prog = xine
button = PLAY
repeat = 3
config = Play
end

begin
prog = xine
button = STOP
repeat = 3
config = Stop
end

begin
prog = xine
button = OFF
repeat = 3
config = Quit
end

begin
prog = xine
button = PAUSE
repeat = 3
config = Pause
end

begin
prog = xine
button = CH+
repeat = 3
config = EventUp
end

begin
prog = xine
button = CH-
repeat = 3
config = EventDown
end

begin
prog = xine
button = VOL-
repeat = 3
config = EventLeft
end

begin
prog = xine
button = VOL+
repeat = 3
config = EventRight
end

begin
prog = xine
button = OK
repeat = 3
config = EventSelect
end

begin
prog = xine
button = BACK/EXIT
repeat = 3
config = Menu
end

begin
prog = xine
button = FFW
repeat = 3
#config = SpeedFaster
config = SeekRelative+60
end

begin
prog = xine
button = REW
repeat = 3
#config = SpeedSlower
config = SeekRelative-60
end

begin
prog = xine
button = FULL
repeat = 3
config = Volume+
end

begin
prog = xine
button = BLANK
repeat = 3
config = Volume-
end

begin
prog = xine
button = MUTE
repeat = 3
config = Mute
end

begin
prog = xine
button = MENU
repeat = 3
config = RootMenu
end

begin
prog = xine
button = SKIP
repeat = 3
config = EventNext
end

begin
prog = xine
button = REPLAY
repeat = 3
config = EventPrior
end

begin
prog = xine
button = GO
repeat = 3
config = OSDStreamInfos
end

begin
prog = xine
button = RED
repeat = 3
config = Quit
end

begin
prog = xine
button = RED
repeat = 3
config = Quit
end

Setting up Lircd remote control for your Hauppauge 350's TV Remote

Get the latest stable version of LIRC (Linux Infrared Remote Control) here. At the time of this writing, it is 0.7.2. Do the usual to install it: "./configure; make; make install"


Here's my /etc/lircd.conf:


#----------------------------------------------------------
#/etc/lircd.conf

#
# this config file was automatically generated
# using lirc-0.5.5pre8 on Sun Apr 18 11:43:45 1999
#
# contributed by Jens Leuschner
#
# brand: Hauppauge
# model:
# supported devices: WinTV primo; WinTV pci; WinTV radio
#
# This config file will work with both homebrew receivers and
# original Hauppauge TV cards !!!
#

begin remote

name Hauppauge
bits 13
flags SHIFT_ENC
eps 30
aeps 100

one 950 830
zero 950 830
plead 960
gap 89584
repeat_bit 2

begin codes
TV 0x000000000000100F
RADIO 0x000000000000100C
FULL_SCREEN 0x000000000000102E
CH+ 0x0000000000001020
CH- 0x0000000000001021
VOL- 0x0000000000001011
VOL+ 0x0000000000001010
MUTE 0x000000000000100D
SOURCE 0x0000000000001022
1 0x0000000000001001
2 0x0000000000001002
3 0x0000000000001003
4 0x0000000000001004
5 0x0000000000001005
6 0x0000000000001006
7 0x0000000000001007
8 0x0000000000001008
9 0x0000000000001009
0 0x0000000000001000
RESERVED 0x000000000000101E
MINIMIZE 0x0000000000001026
end codes

end remote


#
# this config file was automatically generated
# using lirc-0.6.6(animax) on Tue Apr 15 19:50:27 2003
#
# contributed by
#
# brand: Hauppauge
# model no. of remote control:
# devices being controlled by this remote: PVR 2/350
#

begin remote

name hauppauge_pvr
bits 13
flags RC5|CONST_LENGTH
eps 30
aeps 100

one 969 811
zero 969 811
plead 1097
gap 114605
toggle_bit 2


begin codes
Power 0x00000000000017FD
Go 0x00000000000017FB
1 0x00000000000017C1
2 0x00000000000017C2
3 0x00000000000017C3
4 0x00000000000017C4
5 0x00000000000017C5
6 0x00000000000017C6
7 0x00000000000017C7
8 0x00000000000017C8
9 0x00000000000017C9
Back/Exit 0x00000000000017DF
0 0x00000000000017C0
Menu 0x00000000000017CD
Red 0x00000000000017CB
Green 0x00000000000017EE
Yellow 0x00000000000017F8
Blue 0x00000000000017E9
Ch+ 0x00000000000017E0
Ch- 0x00000000000017E1
Vol- 0x00000000000017D1
Vol+ 0x00000000000017D0
Ok 0x00000000000017E5
Mute 0x00000000000017CF
Blank 0x00000000000017CC
Full 0x00000000000017FC
Rewind 0x00000000000017F2
Play 0x00000000000017F5
Forward 0x00000000000017F4
Record 0x00000000000017F7
Stop 0x00000000000017F6
Pause 0x00000000000017F0
Replay 0x00000000000017E4
Skip 0x00000000000017DE
end codes

end remote


#
# this config file was automatically generated
# using lirc-0.7.0(any) on Sun Nov 28 20:25:09 2004
#
# contributed by
#
# brand: Hauppauge 350
# Created: G.J. Werler (The Netherlands)
# Project: Mythtv Fedora Pundit-R www.mythtvportal.com
# Date: 2004/11/28
# model no. of remote control: Hauppauge A415-HPG
# devices being controlled by this remote: PVR-350
#

begin remote

name Hauppauge_350
bits 13
flags RC5|CONST_LENGTH
eps 30
aeps 100

one 969 811
zero 969 811
plead 1097
gap 114605
toggle_bit 2


begin codes
Go 0x00000000000017BB
Power 0x00000000000017BD
TV 0x000000000000179C
Videos 0x0000000000001798
Music 0x0000000000001799
Pictures 0x000000000000179A
Guide 0x000000000000179B
Radio 0x000000000000178C
Up 0x0000000000001794
Left 0x0000000000001796
Right 0x0000000000001797
Down 0x0000000000001795
OK 0x00000000000017A5
Back/Exit 0x000000000000179F
Menu/i 0x000000000000178D
Vol+ 0x0000000000001790
Vol- 0x0000000000001791
Prev.Ch 0x0000000000001792
Mute 0x000000000000178F
Ch+ 0x00000000000017A0
Ch- 0x00000000000017A1
Record 0x00000000000017B7
Stop 0x00000000000017B6
Rewind 0x00000000000017B2
Play 0x00000000000017B5
Forward 0x00000000000017B4
Replay/SkipBackward 0x00000000000017A4
Pause 0x00000000000017B0
SkipForward 0x000000000000179E
1 0x0000000000001781
2 0x0000000000001782
3 0x0000000000001783
4 0x0000000000001784
5 0x0000000000001785
6 0x0000000000001786
7 0x0000000000001787
8 0x0000000000001788
9 0x0000000000001789
Asterix 0x000000000000178A
0 0x0000000000001780
# 0x000000000000178E
Red 0x000000000000178B
Green 0x00000000000017AE
Yellow 0x00000000000017B8
Blue 0x00000000000017A9
end codes

end remote



#----------------------------------------------------------

Using your Hauppauge 350 TV OUT in X Windows

After you're all done installing IVTV and you've rebooted, it's time to setup your X server to use your Hauppauge 350 card's TV out as your video card. To do this, you first need to find out which PCI bus the card is on. Do this by running the command: "lspci -v" from the command prompt (xterm). Scroll up through the output with SHIFT-PGUP until you see a section like this:

0000:02:01.0 Multimedia video controller: Internext Compression Inc iTVC15 MPEG-2 Encoder (rev 01)
Subsystem: Hauppauge computer works Inc. WinTV PVR-350
Flags: bus master, medium devsel, latency 64, IRQ 21
Memory at f0000000 (32-bit, prefetchable) [size=64M]
Capabilities: [44] Power Management version 2

This shows me that the PCI card is at address "0000:02:01.0". As far as X Windows is concerned, we're going to call this "PCI:02:01". Below is the contents of my /etc/X11/xorg.conf. Notice in the "Device" section the line:

BusID "PCI:02:01"

You'll need to format your 350's bus id in this line according to the results you got earlier by the "lspci -v" command.



#-----------------------------------------------------------
# /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/CID"
FontPath "/usr/share/X11/fonts/100dpi"
FontPath "/usr/share/X11/fonts/75dpi"
# paths to defoma fonts
FontPath "/var/lib/defoma/x-ttcidfont-conf.d/dirs/TrueType"
FontPath "/var/lib/defoma/x-ttcidfont-conf.d/dirs/CID"
EndSection

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

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

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

# Your TV
Section "Monitor"
Identifier "Sony TV"
HorizSync 30-50
VertRefresh 60

Mode "720x480"
DotClock 34.564
HTimings 720 752 840 928
VTimings 480 484 488 504
Flags "-HSync" "-VSync"
EndMode
EndSection

# Your Hauppauge 350 TV Card
Section "Device"
Identifier "ivtv"
Driver "ivtvdev"
Option "fbdev" "/dev/fb1"
# Make sure to fill in your PCI bus id for the Hauppauge 350 here
BusID "PCI:02:01"
EndSection

Section "Screen"
Identifier "Screen TV ivtv"
Device "ivtv"
Monitor "Sony TV"
DefaultDepth 24
DefaultFbBpp 32

SubSection "Display"
Depth 24
FbBpp 32
Modes "720x480"
ViewPort 0 0
EndSubSection
EndSection

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

Section "DRI"
Mode 0666
EndSection
#-----------------------------------------------------------

Installing the IVTV driver for the Hauppauge 250 and 350

First, go get the latest IVTV driver. At the time of this writing, it is 0.4.0 - get it here. My last MythTV install used version 0.2.0, which may have been the cause of a lot of my problems -- so make sure you're using the current stable version that's available.

Thanks to Rachel's Knowledge Base Blog for the great advice on how to compile and install IVTV. Make sure to read the "Gotcha" at the bottom.

The one change I made was, I have the following in my /etc/modutils/ivtv file:

#-----------------------------------------------------
# /etc/modutils/ivtv

alias char-major-81 videodev
alias char-major-81-0 ivtv
alias char-major-61 lirc_i2c
options ivtv ivtv-debug=0 mpg_buffers=90
options saa7127 enable_output=1 output_select=0 options tuner type=2
options msp3400 once=1 simple=1 debug=0
add below ivtv msp3400 saa7115 tuner saa7127
add above ivtv lirc_dev lirc_i2c ivtv-fb

#-----------------------------------------------------

Installing MythTV 0.18.1

Fortunately, I could install MythTV by using Synaptic, the graphical apt-get installer in Ubuntu. Installing MythTV installs all the prerequisites, such as MySQL, and a bunch of other goodies.

I'm writing this blog from memory -- I'm sure I'm forgetting a few things I had to install - you'll figure it out :)

Ubuntu Linux 5.1 "Breezy Badger"

I replaced my 733MHz CPU with a 2.4GHz Pentium 4 chip, and decided to get away from Fedora Core 3 and use Ubuntu 5.1 "Breezy Badger", which has been really good to me on my laptop.

Make sure to create the user with the login "mythtv" -- this is the user that MythTV expects will be there, so this will save you some time in the next few steps.

As soon as I installed the base system, I replaced /etc/apt/sources.list with the following contents, so that I could install apps from outside the distribution

#----------------------------------------------------------------
#/etc/apt/sources.list

deb http://archive.ubuntu.com/ubuntu breezy main restricted

deb-src http://archive.ubuntu.com/ubuntu breezy main restricted

deb http://archive.ubuntu.com/ubuntu breezy-updates main restricted
deb-src http://archive.ubuntu.com/ubuntu breezy-updates main restricted

deb http://archive.ubuntu.com/ubuntu breezy universe
deb-src http://archive.ubuntu.com/ubuntu breezy universe

deb http://security.ubuntu.com/ubuntu breezy-security main restricted
deb-src http://security.ubuntu.com/ubuntu breezy-security main restricted

deb http://security.ubuntu.com/ubuntu breezy-security universe
deb-src http://security.ubuntu.com/ubuntu breezy-security universe

deb http://archive.ubuntu.com/ubuntu breezy multiverse
deb-src http://archive.ubuntu.com/ubuntu breezy multiverse
#----------------------------------------------------------------

New posts coming soon!

I recently rebuilt my MythTV box, swapping out my 733MHz cpu with a 2.4GHz, upgrading MythTV 0.17 to 0.18.1, ivtv from 0.2.0 to 0.4.0, and the distribution from FC3 to Ubuntu 5.1 -- and, OMG it's 10 times better... Even my wife says so!

I'll update this site soon to reflect my new adventure and the great rewards I've earned through the efforts.

Monday, March 07, 2005

Getting rid of stubborn 0.00GB files

Your MythBox hasn't ever crashed?  Liar.

I've had to hard-reboot a few times now. If there was a show being taped, a lot of the time I'll end up with a zero-byte file that Myth won't let me delete. Well, here's how to get rid of them, without having to dig through the 42,521 mysql tables...

1. Watch the mythbackend log to find out the file that Myth is having problems by running the following command in a terminal window:

tail -f -n 0 /var/log/mythtv/mythbackend.log

(keep this terminal window open)


2. Try deleting the file that MythTV tells you is 0.00GB, through MythTV. If you're having the same problem I've had, nothing happens, the file's still there. But, you should have some new output on the terminal window we opened in step #1. Something like this:

2005-03-07 18:14:31.312 ERROR when trying to delete file: /var/storage/recordings/1020_20050220100200_20050220102200.nuv. File doesn't exist. Database metadata will not be removed.


Ah hah! it's that pesky 1020_20050220100200_20050220102200.nuv file!


3. Create an empty place-holder for this file, using a new terminal window:

touch /var/storage/recordings/1020_20050220100200_20050220102200.nuv


4. Tell MythTV to delete the file again. This time it should work, and it'll disappear from your Recorded Programs list.


Enjoy, and happy cleaning!

- Blake

Tuesday, January 18, 2005

Adding Menu Commands

But I don't know C++!
No problem... MythTV's menus aren't created in code - they're built from XML documents, and if you're familiar with XML, then you can edit your menus, create new ones, etc. I'll briefly discuss how I was able to 'hack' my menus to add a couple commands that I needed. This isn't textbook, it's just the way I've found to do this through looking through some of the code, and tinkering. Cause, isn't that what this project is all about?


How Do Menus Work?
If you'd like to check out the menu-building XML documents, browse through /usr/share/mythtv/*.xml. Start with mainmenu.xml, and branch out from there. Here's a snippet from mainmenu.xml:

----------------* snippet

<button>
<type>MENU_MEDIA_LIBRARY</type>
<text>Media Library</text>
<action>MENU library.xml</action>
</button>

----------------* /snippet

This example is pretty straight forward. Each button/menu item gets a "button" entry.

Menu Themes
Inside, you'll need to include the "type" of button - in this case, it's "MENU_MEDIA_LIBRARY." This is used to determine how to render the page - what image to use and where to put it. In this case, if you look in /usr/share/mythtv/themes, you'll see how each theme implements this button type. For example, in the "blue" theme, in /usr/share/mythtv/themes/blue/theme.xml, this button type is described as:

----------------* snippet

<buttondef name="MENU_MEDIA_LIBRARY">
<image>cd.png</image>
<offset>15,10</offset>
</buttondef>

----------------* /snippet

In that directory you'll find cd.png. I haven't spent any time with the themes, so this is as far as I'll go into themes.

Menu Entry Text
The "text" element describes the text to display on the page. I've found that there is a maxium number of characters you can use, but haven't checked what that number is. You'll notice that the menu supports different languages. I haven't bothered with translations.


Menu Actions
And last and most important, you'll notice the "action" element. This tells MythTV what to do when you select this menu entry. I've found the following to be valid:
* Menu Command
- usage: MENU [some menu xml file]
- purpose: To tell redirect MythTV to another menu. This is useful for subdividing your actions into different, specific pages.
- example (omit the quotes): "MENU library.xml"

* Plugin Command
- usage: PLUGIN [plugin name]
- purpose: I haven't used this yet, but it apparently launches a MythTV plugin
- example (omit the quotes): "PLUGIN mythgame"

* Built-In Actions:
- usage: [SOME ACTION NAME]
- purpose: to launch an action built into MythTV
- example (omit the quotes): "TV_WATCH_RECORDING"

* Execute a Command:
- usage: EXEC [some command path]
- purpose: to launch an external command
- example (omit the quotes): "EXEC /usr/local/bin/mythtv_rip_cd"

I've only really worked with the "EXEC" action. For example, I'm finding it useful to write Perl scripts to handle stuff in the background that normally occupies MythTV's display, such as ripping/encoding CDs to mp3/ogg. I wrote a simple Perl script that rips & encodes a CD off in another process, letting me continue to use MythTV while the CD is being worked on. As I find the time, I'll write several more of these commands, and eventually post them all here on the blog to share.


Menu Dependencies
There's one more element inside a "button" group - "depends." I haven't looked into this, but it seems that this refers to a module. I would imagine if the specified MythTV module isn't loaded, the menu item will not appear, but I'm not yet sure.


Customizing Your Menus
I need to hand it to the MythTV crew - the menuing system seems to have been done really well. I'm impressed that the menus are rendered from XML rather than compiled (you'd be surprised how often that's the case), and this next bit of information impresses me even further... Each user can keep their own copy of the menu XML files.

Rather than edit the files in /usr/share/mythtv/, you can (and I would strongly encourage you to) copy the XML documents that you want to edit into your MythTV user's "~/.mythtv/" directory. If MythTV finds an XML file here, it uses it rather than the ones found in /usr/share/mythtv/.

So, for a little fun, try editing one of the menus:

1. Copy the mainmenu.xml file from /usr/share/mythtv/mainmenu.xml to ~mythuser/.mythtv/
(assumes that "mythuser" is your MythTV user)
2. Edit ~mythuser/.mythtv/mainmenu.xml
3. Replace "Watch TV" with "MythTV Rocks!"
4. Restart MythTV and get a chuckle...
5. When you're all done, remove the overriding XML file to go back to the normal menus

Conclusion
Kudos to the MythTV developers, they've done a great job with the menus! They've given us a way to really make this system our own. It's easy to add and remove commands and menus - we can add anything we need without any worry of screwing up the system, thanks to the home directory menu overriding. Spend a little time playing with this, and you'll think of all sorts of interesting ways to use it. When you do, please let me know what you've come up with!

Wednesday, January 12, 2005

Dual Input Hauppauge 250 PVR Card for Recording Digital & Analog Cable

Recording Digital Cable
I've been using the coaxial cable inputs at Tuner0 on both my Hauppauge 250 and my Hauppauge 350 thus far, but wanted to be able to record my digital cable as well. There's two problems to overcome for this task: getting the audio & video from my digital cable into MythTV, and changing the channel on my Motorola Digital Cable box. I'll start with the latter problem.

Changing the Channel on My Motorola Digital Cable Box
I bought myself a MyBlaster Serial IR Blaster from My.Tv store for $40 (plus tax & shipping). It's a pretty cool little box that I have sitting next to my MythTV box. It plugs into the computer's serial port, and faces the back wall of my family room.

I decided to go with this device rather than a simple short-range IR blaster that I could tape in front of the cable box because this one has a long range and I'd like to be able to control more than just the cable box. The signals are bouncing off of my back wall and back at the entertainment center without any problems.

I downloaded the user-contributed script for the MyBlaster, written by William Munson -- thanks William - excellent script. I made some small mods to it for my purposes -- I think the only changes I made were timing and device settings. The script one of several commands as the first parameter. For example, to turn on the device, use:

/usr/local/bin/IRBlaster_DigitalCable.pl power

or, to change the channel to channel 33:

/usr/local/bin/IRBlaster_DigitalCable.pl 33

So, I had to start by figuring out what my MyBlaster device code was, so I could enter that in William's script. I did some digging around, and found that this box wasn't actually made by Motorola, but by GE (as far as I can remember). The MyBlaster code for my cable box is "0276".

The script works great! I'm able to change channels on my cable box using MythTV without any problems. I'm very happy with my $40 purchase.


The Hauppauge 250's Inputs
This card has three video inputs it may choose from:
   * Tuner0 (coaxial cable)
   * Composite4 (A/V cables)
   * SVideo# (I haven't used this)

Tuner0 on the 250 has been working great to bring in the analog coaxial cable into the MythTV box, but I needed a way to bring the Digital Cable into the MythTV box. My digital cable box has two outputs: one for coaxial cable, and one for composite A/V cables. I did some rewiring so that the coax goes into the TV, and the composite A/V cables go into the Hauppauge 250's composite input. From trial and error, I found that this input is Composite4 (not Composite0, which would seem to make sense).


DataDirect for Digital Cable
Now that I have this new Video Source with several new channels, I have to tell MythTV what those channels are. To do so, I logged back into my DataDirect account, and added the new channel list. I had to unselect the channels I didn't purchase, including the HDTV channels and other premium channels. No reason to let MythTV think it can record a movie, only to tape 2 hours of "Premium Service Channel" error message.


Putting It All Together
I ran mythtvsetup to enter my new DataDirect channel list and map it to my Hauppauge 250. First, I entered the channel list in the "Video Sources" section. I named this new section "DataDirect Digital Cable" (the other was named "DataDirect"). Then, I mapped this new channel list to Composite4 on /dev/video1 (the Hauppauge 250 is my second card. If you only have one card, then you'll map to /dev/video0. If you have two cards, you'll have to figure out if it's /dev/video0 or /dev/video1 -- I think the standard is that /dev/video0 is the card closer to the AGP slot on your board. Here's also where you need to tell MythTV how to change channels using the IRBlaster script. I entered:

/usr/local/bin/IRBlaster_DigitalCable.pl

Since you can't splice digital cable like you can with analog, I'd like the Hauppauge 250 to use the coaxial analog cable whenever it can, and only hit the digital cable when absolutely necessary, so I can still use my digital cable box when it's taping something on network tv. There are two options for this:
* when setting up the DataDirect channel list, only select the channels that aren't on analog tv
* give the analog tv Data Source a higher priority than the digital cable source

I'm too lazy to unselect 78 checkboxes, so I chose the latter solution. If a recording is scheduled on ABC, MythTV will use the coaxial cable input. The preferences will probably also push off digital cable recordings if they're going to repeat on analog cable -- it's a great feature.


I then ran mythfilldatabase to go out and populate the database with the new channels and their line-ups. Last, but not least... I restarted mythbackend. If you don't do that, then the change-channel script won't be called. I'm not sure you'd even have access to the new channels if you didn't restart mythbackend.


Conclusions
Productive night... worth the extra work. I'm sure being able to tape all of my premium movie channels won't help my storage situation though...



** I'll include my IRBlaster_DigitalCable.pl script soon.

Monday, January 10, 2005

Quiet Case & Overheating

Initial Setup
I'll spare the details of my initial setup -- I followed Jarod's amazing HOWTO (thanks Jarod). I'm running Fedora Core 3, with the Linux 2.6.9-1.681_FC3 kernel grabbed from ATRPMS using apt-get.

Antec's Piano Black Quiet Media Case
I decided to get a new case that's not a tower, and looks a little better on top of my entertainment center. Noise is a big factor too - I wanted the box to be very quiet, so I settled on Antec's Piano Black Quiet Media Case. The 380W power supply is absolutely silent. It's even got a washable filter in front of the air intake to keep it clean -- NICE. And, there's two low-voltage power cables inside to power the quiet fans.

The only noise coming from the case was from the 4 hard drives and the processor fan. It was amazingly quiet -- until I started having overheating problems. I decided to give the outtake fan on the right of the box full voltage to bring some of the hot air out, because the processor was getting up over 60 degrees Celcius, and the hard drives could cook a slab of ground beef. I wasn't happy about this, but it was necessary. The box is still pretty quiet.

I bought rounded IDE cables to further help the air flow, since the cables were right in front of the outtake fan.

Hauppauge 350 Card Overheating
Since I've been up and running, I've had two full lockups -- the whole system froze. It's been years since Linux has completely frozen up for me -- it looks like an overheat of the Hauppauge 350 card. The heatsink on the Hauppauge 350 would get extremely hot, almost burning my hand. It's no surprise, I'm using the card for the TV Out for both the mpeg2 TV recordings and for X as my primary graphics card.

So, to bring more air across the heatsink on the 350 I dropped a big fan in the box, blowing air across the PCI cards at low voltage to keep it quiet. So far, so good, but we'll see over the next week if this helps.

Sunday, January 09, 2005

Building the ReiserFS LVM at /var/storage

450GB ReiserFS LVM
When you configure MythTV, you select your folder for storing recordings. That's great if you have one monster hard drive -- or, if you use LVM. In my case, I have both :)

Basically LVM lets you put several drives together, making it look like one drive. You can add new drives to the volume, and even (carefully) remove them. I'd recommend backing up anything you have that you need before trying this. I screwed up and ended up losing some digital camera photos. Since then I was able to rebuild most of the lost data, and retrieve partial images (they're each missing about 1/4 of the image). But, in any case -- backup, backup, backup... then experiment.

I used the LVM HOWTO to setup my drive array. I chose ReiserFS because I read it's much better than ext3, and that there are really good tools for managing ReiserFS drives (which I found out when trying to rebuild lost data). I meant to use ReiserFS version 4, but I think I got 3 -- it's whatever ATRPMS gave me.

My current volume contains three 160GB Western Digital 7200 hard drives which I got at Best Buy each for $30 after the insane rebates on Black Friday. I named the volume VGForMythTVStorage, and mounted it at /var/storage.

So far, it's working great - and, if 200 hours of recording time aren't enough, then I could always add another. Hopefully I'd come to my senses by then, and start cleaning off the old episodes of Three Stooges.