Friday, November 16, 2012

First Guide Post



Welcome to yet another MythTV Setup Guide

Just wanted to capture my experiences in writing to help everyone else out
This is the result of about 50 person hours, hopefully it takes you less!


Software/Hardware chosen:

Case
Inwin BP655 mITX Case
TV
Existing RCA 42" TV with HDMI input

Motherboard
Asus AT5IONT-I (onboard NVidia card)
180$ from NCIX

Memory
Kingston Value Ram
2 x 2GB of KVR1333D3S9/2G
30$ for 2 from NCIX

Tuner
Hauppauge HVR-2250 board only
120$ from NCIX

Hard drive
Seagate Barracuda 80GB Drive 7200 RPM
0$ from inventory

Remote
ATI Remote Wonder II
0$ from inventory

Software
Mythbuntu 12.04 with MythTV 0.25 with fixes

Video Feed
Regular old analog cable - digital is coming at a later time

Assembly
There were no challenges to assembling the computer, everything fit well and plug and play. I connected the Mythbuntu computer to the TV using the HDMI output of the video card. I also connected the coaxial cable from my cable feed into the HVR-2250.

Getting Setup Started
I loaded the Mythbuntu 12.04 iso image onto a 1 GB USB stick using LinuxLive USB Creator. I plugged that into the computer, pressed F8 to get the boot options for my BIOS to select boot from USB, and from there I was brought to the setup of MythBuntu.

Setting up Mythbuntu
During setup, if using an NVidia card, it will ask what Video driver to use, select the NVidia Proprietary Driver. This allows further configuration especially with resolutions.
Install the bootloader to the drive itself (/sda, not /sda1)

Booted into Mythbuntu
When it boots it will load to the MythFrontend. Exit Mythtv by pushing Escape and configure the following:

Go to Applications, System, NVidia XServer settings, go to Display Configuration, change the resolution to whatever it is you like, in my case I chose 1920x1080, refresh rate stayed at Auto.

First I setup some stuff to allow me to play videos from my network
In Mythtv frontend:

Go to Setup, Video, Playback, Playback Profiles (3/8), change the Playback Profile to VDPAU High Quality (this allows smooth playback of 1080p content, without this change the system is unusable, extremely choppy)

Go to Setup, Media Settings, Video Settings, General Settings and add the directory that you want in the "Directories that hold videos" using a semicolon after the existing entry. For example "/var/lib/mythtv/videos;/mnt/luc-computer/Video/Folders/Video Workshop", no quotes

When browsing Videos in the Video Gallery, press the Menu key (m) and go to File Extension Settings, add in new Ignore entries for mta, cos2, scn

Go to Setup, Audio, change the Audio Output device to ALSA:dmix:CARD=NVidia,DEV=7 (may differ for your use, this is likely motherboard specific)

I tried using djmount to watch videos through DLNA/upnp from Serviio on my Windows machine. I found the djmount + Serviio combination to be unstable and just resulted to regular SMB shares, works great.

Setting up the Hauppauge HVR-2250
The only thing that needs to be done to get the Hauppauge HVR-2250 working is to supply the firmware file. The name of the file is NXP7164-2010-03-10.1.fw

At the time of writing this it can be found here: http://www.steventoth.net/linux/hvr22xx/firmwares/4019072/NXP7164-2010-03-10.1.fw

Place the file in /lib/firmware/<current kernel> and reboot. Devices /video0 and /video1 will be created and MythTV will detect them. Use uname to figure out your "current kernel" directory, in my case there are two directories, so I needed to know which one was currently running.

They need to be added as Capture Cards as MPEG-2 Encoders, not V4L2 Devices. There's a lot of discussion on forums about creating input groups and putting one digital and one analog in each, etc... I never had to do that, it worked right out of the box so to speak.

One very key thing is that when using an analog input, don't bother trying to scan for channels in mythbackend-setup. Instead, in the Channel Editor, don't click "Scan for channels", it is of no use, click "Fetch channels from listings source". If you do try to scan for channels it won't find anything and you'll scratch your head and recompile the v4l2 drivers like I did. So to fetch channels, you need a listings source! You'll need to add that first using the previous menu item and SchedulesDirect. I wasted a significant amount of time troubleshooting why it would not scan for channels, only to discover that it won't.

When I watched Live TV or Recordings, the volume sounded as though it was being played on very crappy speakers. Turns out that the volume on the card was set way too loud. I created a script called volume.sh and placed it in /usr/bin. Then, in mythbackend-setup, go to System Events and under "Master Backend Startup", type in /usr/bin/volume.sh... This way, the script will be ran when the backend starts. Make sure to do a "chmod +x volume.sh" that file otherwise it will not be executable.

The contents of this script is:
***************************************

htpc@gallant-HTPC:~$ v4l2-ctl -d /dev/video0 --set-ctrl volume=-10
htpc@gallant-HTPC:~$ v4l2-ctl -d /dev/video1 --set-ctrl volume=-10

nvidia-settings -a '[gpu:0]/GPUPowerMizerMode=1'

***************************************

The nvidia-settings line is to make the GPU not use PowerMizer mode, ensuring it is ready to process video at all times.

Before going into mythtv, you'll want to test your tuner to make sure it works. I had a lot of trouble with this as every time I tried the following command:

mplayer /dev/video0

I would just get a blue screen. You have to tune the tuner to a channel before you can play it. To do this, use this command:

v4l2-ctl -d /dev/video1 --set-freq=55.250

Frequencies are available here: http://en.wikipedia.org/wiki/North_American_cable_television_frequencies#North_America_cable_television_frequencies

To get current settings of your capture card use this command:
htpc@gallant-HTPC:~$ v4l2-ctl -d /dev/video0 -l

To mount Windows and WD MyBook network shares
To mount network shares, for those that aren't Linux experts...:

As super user edit the /etc/fstab file and add in the following content:
//192.168.0.101/Download /mnt/luc-computer/Download cifs username=guest,iocharset=utf8 0 0

At bootup, Mythbuntu will automatically mount the Download share located at //192.168.0.101 and mount it to /mnt/luc-computer/Download. The /mnt/luc-computer/Download directory needs to exist, it can't mount if the directory is not already created.

This is a Windows share for me, and guest viewing is enabled, which is why I use username=guest.

I also have a WD MyBook Live, and to mount one of its shares I added the following entry in the fstab file:

192.168.0.140:/nfs/Recordings /mnt/gallantFatDrive/Recordings nfs rw,hard,intr,nfsvers=3 0 0

(source for the WD Mount (http://community.wdc.com/t5/WD-ShareSpace/WD-ShareSpace-NFS-and-Linux-Here-is-how-it-is-done/td-p/181344)

This corresponds to a Recordings share with anonymous write access.

To test if your fstab entries work, use 'mount -a' and 'umount-a'

I wanted my recordings to record onto my NAS (MyBook), so I removed the /var/lib/mythtv/recordings folder from the Default Storage Group and added /mnt/gallantFatDrive/Recordings

Use the iftop command to monitor network throughput if you're wondering.

I also changed "Max simultaneous jobs on backend" from 1 to 4 (general settings of backend setup) just to allow the backend to process a bit more at a time. 

Setting up the ATI Remote Wonder II
To setup the remote control, I followed rough instructions on these two pages:
http://www.mythtv.org/wiki/ATI_Remote_Wonder_II#MythTV.2C_ATI_Remote_Wonder_II_and_Kernel_Keymap_Modification
http://www.mythtv.org/wiki/Keybindings#Without_the_stickykeys_option_selected

LIRC is not required for this remote with recent kernels.

The remote is essentially plug and play. Once you plug it in (might need a reboot), run the lsmod (lsmode  | grep remote) command to confirm that ati_remote2 has loaded into the modules. It should be there, otherwise use modprobe ati_remote2 to load it in. I did not have to do anything to get it to load at bootup.
In order to map the keys over, put these lines into /etc/rc.local as this script runs as sudo

*************************************
setkeycodes 0x005C 28 0x015C 28 0x025C 28 0x035C 28 0x045C 28    #//this maps the OK key to the enter key
setkeycodes 0x0020 103 0x0120 103 0x0220 103 0x0320 103 0x0420 103   #//this maps the CH+ key to the up key
setkeycodes 0x0021 108 0x0121 108 0x0221 108 0x0321 108 0x0421 108   #//this maps the CH- key to the down key

setkeycodes 0x0030 25 0x0130 25 0x0230 25 0x0330 25 0x0430 25      #//pause key to the letter P
setkeycodes 0x002c 25 0x012c 25 0x022c 25 0x032c 25 0x042c 25     #//play key to the letter P
setkeycodes 0x0031 1 0x0131 1 0x0231 1 0x0331 1 0x0431 1       #//stop key to the letter ESC
setkeycodes 0x0037 19 0x0137 19 0x0237 19 0x0337 19 0x0437 19       #//map the record key to the letter R
setkeycodes 0x000d 67 0x010d 67 0x020d 67 0x030d 67 0x040d 67      #//mute key to F9
setkeycodes 0x0010 87 0x0110 87 0x0210 87 0x0310 87 0x0410 87       #//volume up to F11
setkeycodes 0x0011 68 0x0111 68 0x0211 68 0x0311 68 0x0411 68      #//volume down to F10    ---- Set the mixer device to software so that these controls actually work!!!
#setkeycodes 0x0428 106     #//map the fast forward key to the right key ---- not using this since they only jump around, see below
#setkeycodes 0x0429 105     #//map the rewind key to the left key
setkeycodes 0x0028 52 0x0128 52 0x0228 52 0x0328 52 0x0428 52     #//map the fast forward key to the period
setkeycodes 0x0029 51 0x0129 51 0x0229 51 0x0329 51 0x0429 51     #//map the rewind key to the comma
setkeycodes 0x0054 50 0x0154 50 0x0254 50 0x0354 50 0x0454 50    #// map the menu key to the 'm' (key to the left of the zero button)
setkeycodes 0x00f9 23 0x01f9 23 0x02f9 23 0x03f9 23 0x04f9 23    #// map the i key to the letter I (to the right of the up button)
setkeycodes 0x00be 31 0x01be 31 0x02be 31 0x03be 31 0x04be 31    #//map the question mark key to the S key for bringing up the EPG
setkeycodes 0x00d0 46 0x01d0 46 0x02d0 46 0x03d0 46 0x04d0 46    #//map the hand key to the change tuner button

setkeycodes 0x008e 65 0x018e 65 0x028e 65 0x038e 65 0x048e 65    #//map the ATI button to the terminal (F7 key shortcut)
*************************************

Setting up Mythwelcome
Setting up Mythwelcome sounds a lot worse then it actually is. The wiki makes it seem scary but it is suited for many different situations.

Block the HWClock Save (may not even be required, but just do it unless you feel like testing etc). 
All below instructions copied from http://www.mythtv.org/wiki/ACPI_Wakeup
Disable the exec line in /etc/init/hwclock-save.conf
/etc/init/hwclock-save.conf 
# hwclock-save - save system clock to hardware clock
#
# This task saves the time from the system clock back to the hardware
# clock on shutdown.
description                    "save system clock to hardware clock"
start on runlevel [06]
task
script
    . /etc/default/rcS
    [ "$UTC" = "yes" ] && tz="--utc" || tz="--localtime"
    [ "$BADYEAR" = "yes" ] && badyear="--badyear"
#    exec hwclock --rtc=/dev/rtc0 --systohc $tz --noadjfile $badyear
end script


Manually test the wakealarm using the instructions here (http://www.mythtv.org/wiki/ACPI_Wakeup#Manually_test_wakealarm)
Simple test to wake the machine 5 minutes from now
sudo sh -c "echo 0 > /sys/class/rtc/rtc0/wakealarm"
sudo sh -c "echo `date '+%s' -d '+ 5 minutes'` > /sys/class/rtc/rtc0/wakealarm"
cat /sys/class/rtc/rtc0/wakealarm
Check
cat /proc/driver/rtc
This should return a list of parameters. Check the "alrm_time" is 5 minutes into the future and the "alrm_date" is appropriate (which could be but might not be "today," if now + 5 minutes is the next day UTC).

Shut down your computer and see if it comes back up in ~5 minutes.
sudo shutdown -h now

For the motherboard I used, I did not even need to enable the RTC portion in the BIOS. It stays disabled but the computer still boots itself.

If your computer starts in 5 minutes, then you're good to move on to the last step.

The last step to getting this setup is on the same http://www.mythtv.org/wiki/ACPI_Wakeup website, under the "Mythwelcome users" heading... It takes a bit of effort to filter through it, here's a summary:
Change the system so that mythwelcome is started instead of mythfrontend. In Mythbuntu to start mythwelcome instead of mythfrontend you just need to uncomment the MYTHWELCOME line in /etc/mythtv/session-settings.
Change these mythbackend Shutdown/Wakeup Options (mythtv-setup) options
Block shutdown before client connected : unchecked
Idle shutdown timeout (secs)           : 300 (if using active EIT this may need to be set to a lower value)
Max. wait for recording (min)          : 15 (mythshutdown will ignore values less than 15. If less than
                                         15 minutes to next scheduled recording or wakeup period the shutdown
                                         will always be blocked)
Startup before rec. (secs)             : 300 (make this time long enough to complete the boot & disk check
                                         before the recording should start)
Wakeup time format                     : yyyy-MM-ddThh:mm:ss (Must be this format for mythshutdown)
Command to set Wakeup Time             : mythshutdown --setwakeup $time
Server halt command                    : mythshutdown --shutdown
Pre Shutdown check-command             : mythshutdown --check

MythShutdown/MythWelcome Settings (mythwelcome --setup or F11 in mythwelcome)
Command to set wakeup time             : sudo /usr/bin/setwakeup.sh $time
Wakeup time format                     : time_t
nvram-wakeup Restart command           : (Must be blank)
Command to shutdown                    : sudo shutdown -h now (some systems may need "sudo shutdown -P now"
                                         instead (-h may cause system to restart))
Command to start the frontend          : /usr/bin/mythfrontend
setwakeup.sh with option for bios in UTC or local time.
setwakeup.sh 
#!/bin/sh
#
# set ACPI Wakeup time
# usage: setwakeup.sh seconds
#    seconds - number of seconds from epoch to UTC time (time_t time format)
#
# set UTCBIOS to true if bios is using UTC time
# set UTCBIOS to false if bios is using local time

UTCBIOS=true

if $UTCBIOS
then
    #utc bios - use supplied seconds
    SECS=$1
else
    #non utc bios - convert supplied seconds to seconds from
    #epoch to local time
    SECS=`date -u --date "\`date --date @$1 +%F" "%T\`" +%s`
fi

echo 0 > /sys/class/rtc/rtc0/wakealarm    # clear alarm
echo $SECS > /sys/class/rtc/rtc0/wakealarm   # write the waketime

Setup your /etc/sudoers permissions by running "sudo visudo" and pasting the line at the end of the file.
%mythtv ALL = NOPASSWD: /sbin/shutdown, /usr/bin/setwakeup.sh, /usr/bin/mythshutdown
It might be that sudo is configured to require a real tty to run commands as a user (i.e. mythtv). In this case add this line
Defaults:mythtv !requiretty

Don't do like me and make a typo when creating the wakeup.sh file. I forgot the "e" after wak and troubleshot it for about 4 hours!

Anyway, Mythwelcome works pretty good, the only annoying thing is that you can't bring it in focus when any other windows are open, all other windows must be closed so that you can see what Mythwelcome is saying. Not sure if this is by design, it must be.

Power Consumption
From a power consumption standpoint, this setup is great. I measured it using my ammeter and here's what I get:
Peak power during bootup:                                                       97 W
Power during bootup:                                                               75 W
Power during LiveTV                                                               84 W
Power at idle:                                                                           75 W
Power watching HD Video through the network:                       86 W
Power at rest with computer turned off:                                     5 W (quite surprising)

Random Small Things
This posting hits a lot of the main points in a much more succinct way than I did... http://dreamlayers.blogspot.ca/2012/10/mythtv-notes.html

If you want to add extra keys, use the showkey command and follow the instructions in the two links above.

I also read that the Intel CPU had issues where it would be slow so I found this command and added it to /etc/default/grub. Not really sure if it did anything but the command is still there. Replace existing line with GRUB_CMDLINE_LINUX="intel_idle.max_cstate=0 processor.max_cstate=1"

The commercials aren't really being detected, I haven't investigated that extensively. Maybe 1 in 6 commercials get detected. Strict commercial detection is in fact turned off.

I tried doing the upgrade to 0.26 through Repositories, that did not go well. Luckily I had done a full disc image before trying that, and I was able to revert. Since then I've turned off repo updates but it still keeps bugging me to do it, I have to keep saying no.

In the post in dreamlayers above he mentions turning off all logging in SQL. To do this, edit these files:
/etc/init/mythtv-backend.conf
/usr/bin/mythfrontend
and change all local7 references to none to disable logging.
I did not see any huge improvements from this, maybe I did it incorrectly?

I've had two freezeups when watching recordings, the videos freeze right after starting them. I have not investigated this yet. A reboot is required to resolve the problem.

I messed around trying to get a script working to make thumbnails of my videos on the network so that browsing them would be more visually appealing. If anyone is interested in this let me know.

Satisfaction Level
Overall excellent. Had it not been for a few minor things it would have probably taken me one third the time to set this up.

My only complaint is performance during LiveTV. As everyone else reports, it takes a long time to change channels (maybe 5 seconds), and I read all over that LiveTV is kind of an afterthought, so I just accepted this as is.

The other complaint (I know I said I only had one), is that when browsing up and down through the EPG, the video stutters. These posts describe it well, and I did try doing the SQL improvements, but it did not resolve the problem: http://www.mentby.com/Group/mythtv-users/livetv-stutter-while-in-epgguide.html

Next steps for me
The minute I finished setting up the box (literally), I saw a banner across the TV stating that these analog channels would no longer be working as our cable provider is moving to full digital except for channels 1-13, so I have to get a STB. I've ordered an IRBlaster from Hauppauge and will be setting that up next.

I am aiming to have channels 1-13 still available through coax and the STB through component (red/white/yellow), so that I could record three things at once.

I will probably post details of my progress and if I find anything out along the way. Good luck with your own setup, I hope this post can help at least a little bit!

For any questions please contact me at lucgallant /// gmail///com where the slashes should be replaced with the appropriate symbols. Or, just make a comment in the comments below.

No comments:

Post a Comment