Penguin

FreeView|HD and MythTv, setup notes

(GerardSharp, October 2009) This has been very difficult to get this far, requiring quite a lot of fiddling and surfing past several dozen websites to garner pieces of clues; so I want to write it all down and hopefully save someone else some of the pain.

I've now moved my back-end onto a "real" server (with actual disk space) and set up another front-end using these instructions, so I hope they are helpful to other people too.


Overview

FreeView|HD is a DVB-T, Terrestrial Digital TV using UHF. In Hamilton this signal comes from Te Aroha and good frequencies are

  • 674 MHz = TVNZ
  • 690 MHz = MediaWorks? (TV3, C4, etc)
  • 706 MHz = Kordia (Prime, Parliament TV, Radio, etc)

I'm going to use the Hauppauge HVR-2200; supported since about May 2009. This is a regional variant of the HVR-2250 (US version), and the same driver works for both. I followed instructions from the Ubuntu Forums, and the official homepage for the driver is here
Also consider getting VDPAU to work your GPU and save your CPU; requires an nvidia card and their binary blob, alas.
I'm going to use mythbuntu 9.04 and JYA's patches to get VDPAU and h.264 working, here


Installation

The magic CD had some issues with my monitor, causing the bottom of the screen with the back/okay/next/cancel buttons to be cut off; this caused me some problems with disk formatting, but otherwise I proceeded by the magical trick of "guessing" where the button might be.
Didn't see options for disk-encryption or LVM; might need these on a more serious backend; but ext3 is fine for my play-around box


Slog

Installed, aptitude run to get updates, installed new editor (Insert ReligiousWar here)
You also need to grab

  • "mercurial" (command line version is "hg"), a revision control system some of the tools use
  • "dvb-apps" from http://www.linuxtv.org/wiki/index.php/LinuxTV_dvb-apps
  • "dvbtune" is very good for telling you the signal strength and thus how good your aerial is. sudo apt-get install dvbtune
  • Any non-free software you need. JYA's repository rebundles the nVidia driver with VDPAU support. Handy.
  • Kernel Headers, maybe even kernel sources
  • Medibuntu has a nice repository of Media-related things for Ubuntu. Note, again, not all of this is Free.

HVR-2200 is the NZ(/EU?) version of the HVR-2250 (US). Same driver. I got it working following instructions from http://www.linuxtv.org/wiki/index.php/Hauppauge_WinTV-HVR-2200
Every time you update your kernel, you have to re-run the make / make install. Check when you update your kernel that this make is actually running against the new kernel, not the old one

"dvb-apps" from http://www.linuxtv.org/wiki/index.php/LinuxTV_dvb-apps
dvb-apps lets you check your signal and even pipe TV to mplayer / vlc. Good for getting signal strength numbers.
dvb-apps can't access the tuner / card if mythbacked-setup has been configured to use it; so stop the backend first.

the util "scan" can be fed a file from /usr/share/dvb/dvb-t/, and it will look for channels on those frequencies. Check out the one I added for TeAroha? at the bottom of this page.
scan will give you a channels.conf file as output, mine is at the bottom of this page. This file can be put in /etc/channels.conf, /etc/mplayer/channels.conf, mythtv/.mythtv, ...
vlc can be run with channels.conf and it will load it like a playlist. This can be used to check your card works; but only locally to the machine with the tuner - vlc doesn't work over ssh -X
Note that TVNZ is using the h.264 codec for their channels; this requires a new codec to play as well as good signal strength (or the player dies with segfaults and the like)

Running dvbtune to check signal.
(qam, gi, cr, bw, tm are properties of the DVB-T signal, values here from channels.conf are good for freeview nz)

dvbtune -f 674000 -I 0 -qam 64 -gi 16 -cr 3_4 -bw 8 -tm 8 -m 1
FE_STATUS: FE_HAS_SIGNAL FE_HAS_LOCK FE_HAS_CARRIER FE_HAS_VITERBI FE_HAS_SYNC
Signal=65535, Verror=100, SNR=252dB, BlockErrors=11, (S|L|C|V|SY|)
Signal=65448, Verror=123, SNR=230dB, BlockErrors=15, (S|L|C|V|SY|)

All the letters in brackets refer to the FE_ line above; all is good, some missing = bad signal
The scale on the Signal and SNR columns seems a bit .. weird. Must be my card.
Ideally, Verror should be as small as possible. 10000 or higher upsets MPEG2, 5000 or higher upsets h.264
Ideally, BlockErrors should be as small as possible.

I found by removing a splitter, I could go from trashy high Verror, no TVNZ and only just TV3/4 to working TVNZ. I then found that adding a mast-head amp would get me nice low Verror, zero BlockErrors. The mast-head amplifier can only really compensate for cable losses. You still need to point the aerial at the transmitter to get good signal.
Roofs are dangerous, scary places, so be careful! (or hire someone who isn't afraid of heights to do it for you!)


MythTV

What A Mess. the EIT (over-the-air TV guide) only has "now" and "next"; no 8-day forecast.
Most of the EPG sites and latest.xml offerings on the internet have *gone*
Including that freeware windows-only (mono!) one mentioned in FreeViewMythTvSetup. They ask a "donation" now and the demonstration version don't work no more.
I eventually found a forum thread which lead me to http://nice.net.nz/scripts/tv_grab_nz-py
(This script is currently broken but only requires a minor change. On line 27 under sources replace nzepg.org with epg.org.nz)
Download it, put it in a system path and run mythtv-setup. "3. Video Sources" option will let you pick this script as your grabber. When selected as your grabber it has to be configured in the terminal that started mythbackendsetup, so I hope you ran it from a terminal! (mythbuntu spawns a terminal using a tiny font and runs the setup from that; so you're okay). My configuration comprised of picking which channels I wanted (freeview) and which I didn't (sky); so it will work with DVB-S (satellite) as noted over in FreeViewMythTvSetup. I called my Video Source "freeview".

While we're in mythtv-setup, play with the rest of the settings. Under "4. Input Connections", you can assign your tuner(/s, HVR-2200 has Dual tuners) to the "freeview" video source you just created. Also you can scan for the transmitted channel to populate the channel list with the "EIT channels".

When you leave mythtv-setup, it will ask to run mythfilldatabase. You probably don't want to run this automatic version, as you may want to run it by hand with the --manual option as noted below, to populate the channel list with the "XMLTV channels".

Now, I found that the EIT channels and the XMLTV channels promptly "fight" and the "watch tv" option in the front-end don't work anymore. Great.
I solved this by going into the Channel editor and disabling the XMLTV channels - giving them no channel number and unmarking the "visible" flag.
Then, use the Channel editor on each of the EIT channels, fix the channel number (Prime on 10? really?) and add the XMLTV ID field; it'll be something like tv3.freeviewnz.tv. You can "cheat" and pull the XMLTV ID out of ~/.mythtv/freeview.xmltv, after you have run the grabber setup as noted above.

  • the XMLTV-found channels have good XMLTV ID, so they get "what's on" information correctly; but have incorrect Callsign / Channel details; so the Tuner can't tune to them
  • the EIT-found channels have good Callsign / Channel details, so you can tune to them; but they have no "what's on" information, so mythfrontend refuses to watch them / record them.

Once all the channels are good and real, run mythfilldatabase. Maybe with the --manual like the xmltv_grabber suggested.

Subsequent to all of this, I have built a second backend, and I have learned that if you:

  • setup the grabber
  • setup the EIT channels
  • assign each EIT channel an appropriate channel number (up to you, I like Prime on 5 myself) and the correct XML ID (look in ~/.mythtv/freeview.xmltv)
  • delete the channel number and mark not Visible any channel you don't want to see
  • quit mythtv-setup and run mythfilldatabase --manual - Now all the discovered channels will have correct details filled out, and you won't get "XMLTV channels" and "EIT channels" and life is good.

Once you have a program guide ("what's on" information) and a valid channel list, you can fire up mythfrontend and try to "Watch TV". If Watch TV does nothing / goes blank briefly and kicks you back to the menu:

  • the default channel (Backendsetup) might be illegal,
  • the default channel has no program guide - no "what's on" information.
  • the mythtv-backend might be unable to write to the Storage Directories
  • Fiddle with your setup a lot; re-run mythfillbackend; fiddle some more.

In the case where write permissions are incorrect, you will also be unable to schedule a recording; which might be possible in the first two cases.


Appendices

My /usr/share/dvb/dvb-t/nz-TeAroha?:


# TeAroha, Waikato NZ
#
# Channel allocation details for NZ can be found at
# http://www.rsm.govt.nz/cms/policy-and-planning/current-projects/broadcasting/digital-television-2007-frequency-plan
#
# T freq bw fec_hi fec_lo mod transmission-mode guard-interval hierarchy

# Multiplex DA?
T 674000000 8MHz 3/4 NONE QAM64 8k 1/16 NONE
# Multiplex DB?
T 690000000 8MHz 3/4 NONE QAM64 8k 1/16 NONE
# Multiplex DC?
T 706000000 8MHz 3/4 NONE QAM64 8k 1/16 NONE

My channels.conf:


TV ONE:674000000:INVERSION_AUTO:BANDWIDTH_8_MHZ:FEC_3_4:FEC_AUTO:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_16:HIERARCHY_NONE:260:310:1200
TV2:674000000:INVERSION_AUTO:BANDWIDTH_8_MHZ:FEC_3_4:FEC_AUTO:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_16:HIERARCHY_NONE:261:311:1201
TVNZ 6:674000000:INVERSION_AUTO:BANDWIDTH_8_MHZ:FEC_3_4:FEC_AUTO:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_16:HIERARCHY_NONE:262:312:1202
TVNZ 7:674000000:INVERSION_AUTO:BANDWIDTH_8_MHZ:FEC_3_4:FEC_AUTO:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_16:HIERARCHY_NONE:263:313:1203
Zinwell SSU:674000000:INVERSION_AUTO:BANDWIDTH_8_MHZ:FEC_3_4:FEC_AUTO:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_16:HIERARCHY_NONE:0:0:1250
TV3:690000000:INVERSION_AUTO:BANDWIDTH_8_MHZ:FEC_3_4:FEC_AUTO:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_16:HIERARCHY_NONE:450:400:1300
C4:690000000:INVERSION_AUTO:BANDWIDTH_8_MHZ:FEC_3_4:FEC_AUTO:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_16:HIERARCHY_NONE:451:401:1301
TV3 PLUS1:690000000:INVERSION_AUTO:BANDWIDTH_8_MHZ:FEC_3_4:FEC_AUTO:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_16:HIERARCHY_NONE:452:402:1302
Maori Television:706000000:INVERSION_AUTO:BANDWIDTH_8_MHZ:FEC_3_4:FEC_AUTO:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_16:HIERARCHY_NONE:550:600:1400
Parliament TV :706000000:INVERSION_AUTO:BANDWIDTH_8_MHZ:FEC_3_4:FEC_AUTO:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_16:HIERARCHY_NONE:551:601:1401
Test Channel:706000000:INVERSION_AUTO:BANDWIDTH_8_MHZ:FEC_3_4:FEC_AUTO:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_16:HIERARCHY_NONE:552:602:1402
ChineseTV:706000000:INVERSION_AUTO:BANDWIDTH_8_MHZ:FEC_3_4:FEC_AUTO:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_16:HIERARCHY_NONE:553:603:1403
PRIME:706000000:INVERSION_AUTO:BANDWIDTH_8_MHZ:FEC_3_4:FEC_AUTO:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_16:HIERARCHY_NONE:554:604:1404
Reserved 6KSD:706000000:INVERSION_AUTO:BANDWIDTH_8_MHZ:FEC_3_4:FEC_AUTO:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_16:HIERARCHY_NONE:555:605:1405
Freeview | HD:706000000:INVERSION_AUTO:BANDWIDTH_8_MHZ:FEC_3_4:FEC_AUTO:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_16:HIERARCHY_NONE:556:606:1406
Radio NZ National:706000000:INVERSION_AUTO:BANDWIDTH_8_MHZ:FEC_3_4:FEC_AUTO:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_16:HIERARCHY_NONE:0:620:2000
Radio NZ Concert:706000000:INVERSION_AUTO:BANDWIDTH_8_MHZ:FEC_3_4:FEC_AUTO:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_16:HIERARCHY_NONE:0:621:2001
BaseFM:706000000:INVERSION_AUTO:BANDWIDTH_8_MHZ:FEC_3_4:FEC_AUTO:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_16:HIERARCHY_NONE:0:622:2002
tvCentral:706000000:INVERSION_AUTO:BANDWIDTH_8_MHZ:FEC_3_4:FEC_AUTO:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_16:HIERARCHY_NONE:560:610:1408