Adding Digital Cable Channels (For ATSC/QAM Tuner Cards -- USA/Canada)
Jason Beck wrote a great writeup to the mythtv-users list on this topic. It's since been the defacto for getting MythTV set up to use your HDTV tuner card to tune QAM digital cable channels.
- Editor's Note: My hope is to update this for the soon to come 0.19 release and perhaps add more information to the process to make it even "easier".
- I've finally finished my initial writeup and have removed the "undergoing major edit" flag. For all those that have gone through this process, please help this article by adding any information you found relevant to the process and correct any errors or absence I may have overlooked. --Steveadeff
This is an early-stage capability; the procedure will necessarily be a little rough at first. Remember that sub-1.0 version number...
If you have successfully executed this procedure, please post your channels.conf file on the Working QAM cable layouts page.
MythTV Database Layout
There are two tables in the MythTV that we are concerned with, the channels table and the dtv_multiplex table. dtv_multiplex stores the frequencies for the channels, channels stores the actual channel information, with a reference to the dtv_multiplex table.
The best method for adding HDTV channels to the db is to populate channels with the channel information from your guide source (Zap2It, etc), then modify the table to add the frequency, etc. information.
You will need to create a channel lineup at labs.zap2it.com containing the digital channels you intend to receive. Do not include analog channels nor any channels which you cannot or do not receive. You may have to go back and modify your lineup after the tests set out below.
Just remember that each channel lineup at labs.zap2it.com is a 'source' and will be associated with a 'sourceid' later on, and that each capture card gets associated with the particular lineup source that it can receive. Multiple cards can be associated with the same source. So make sure that your analog cards are associated with an all-analog lineup, and your digital cards with an all-digital lineup.
Scanning for channels
First a list of the receivable channels must be created. Be sure to have your hardware installed properly with the DVB drivers and firmware loading. Watch your /var/log/messages file for errors as your run these commands and address any problems you find.
- Editor's Note: I have found MythTV's scanner to not do an adequate job of finding the appropriate channels. In order to ensure that all channels you are able to receive are found it is suggested to use the dvb-apps scan utility.
--Steveadeff 23:57, 1 February 2006 (UTC)
Grab the dvb-apps from the linuxtv cvs:
cvs -d :pserver:email@example.com:/cvs/linuxtv login <enter> for blank password cvs -d :pserver:firstname.lastname@example.org:/cvs/linuxtv co dvb-apps cd dvb-apps make
The relevant tools will be:
Run atscscan with the default table as an arguement, for open signals on a cable line, one of these two should work. HRC and IRC are different frequency methods that can be used, its hard to tell which your cable company uses without trying both. You may also not receive any channels this way, and may have to manually run the next step using all frequencies. More on this later. First, lets at least try atscscan,
cd dvb-apps/util/scan ./atscscan atsc/us-Cable-Standard-center-frequencies-QAM256
This process may take considerable time and report alot of tuning failed messages. Let the entire process complete. If you do not find any channels with this freqency list, you can try some of the others like
The output at the end will look similar to:
dumping lists (26 services) KNTV-HD :207000000:QAM_256:65:68:4 NBC Wea :207000000:QAM_256:81:84:5 KBWB-HD :503000000:QAM_256:49:52:3 KBWB-SD :503000000:QAM_256:65:68:4 KGO-DT :533000000:QAM_256:49:52:3 KGO-DT :533000000:QAM_256:65:68:4 KTSF-D2:551000000:QAM_256:49:68:4 KTSF-D1:551000000:QAM_256:49:52:3 KPIX DT:563000000:QAM_256:49:52:1 KQED-HD:569000000:QAM_256:49:52:3 ENCORE:569000000:QAM_256:65:68:4 KMTP Digital Television:587000000:QAM_256:49:52:3 Telefutira:593000000:QAM_256:49:52:3 KCNS-DT:623000000:QAM_256:49:52:3 KKPX Faith:635000000:QAM_256:97:100:6 KKPX Worship:635000000:QAM_256:81:84:5 KKPX Pax East:635000000:QAM_256:65:68:4 KKPX Digital Television:635000000:QAM_256:49:52:3 KCSM-TV:647000000:QAM_256:33:36:2 Jazz-TV:647000000:QAM_256:49:52:3 KBHK-DT:659000000:QAM_256:49:52:1 KTVUHD:725000000:QAM_256:49:52:3 KTVU-DT:725000000:QAM_256:65:68:4 KRON-SD:731000000:QAM_256:49:52:3 KRON-HD:731000000:QAM_256:65:68:4 KTNC DIGITAL TELEVISION:767000000:QAM_256:49:52:3 Done.
You're lucky if you see channel names, it makes life easy, you may not, but thats ok, they can be figured out later.
The format for each channel line in this list is as follows:
- Modulation should be QAM_256
- VID is the decimal equivalent of the hex Video ID
- AID is the decimal equivalent of the hex Audio ID
- PID is the decimal equivalent of the hex Program ID
Important for the MythTV database are the frequency and Program ID.
Now you need to copy the lines with channel data (ignore the "dumping" and "Done." lines) to a file at $HOME/.azap/channels.conf so we can verify channels, and if needed figure out what they are.
Once this is done we can use the dvb-apps's azap utility to tune the different channels.
./dvb-apps/util/szap/azap -r KNTV-HD
replacing KNTV-HD with the first name in your list should output similar to,
using '/dev/dvb/adapter0/frontend0' and '/dev/dvb/adapter0/demux0' tuning to 207000000 Hz video pid 0x0041, audio pid 0x0044 status 00 | signal 3999 | snr cd37 | ber 00000000 | unc 00000000 | status 1f | signal cb84 | snr f8cf | ber 00000000 | unc 00000000 | FE_HAS_LOCK status 1f | signal cb84 | snr f8b3 | ber 00000000 | unc 00000000 | FE_HAS_LOCK
Seeing FE_HAS_LOCK is what you are looking for, it means your card has succesfully tuned to the frequency.
Using another terminal we can watch the tuned channel using mplayer with
mplayer -nosound /dev/dvb/adapter0/dvr0
This will not play audio, its a safe way of testing, we won't have to worry about audio output, feel free to change this. If this fails, an alternative is
mplayer -nosound dvb://KNTV-HD
but you will need a copy of channels.conf in your .mplayer directory
You can use this method to test all the channels in your list, make sure the names are correct, or figure out what channel it is if needed.
I suggest creating a second channels.conf file and filling it with verified channels.
Adding channels to the database
Now that we have a list of working channels, their frequency, and Program ID we are ready to begin entering the data into MythTV's database.
You may have noticed that many of your channels are on the same frequency with different Program ID's (and thus different Video and Audio ID's as well). This is because each frequency has the ability to carry many different streams of data, each is given their own id, with a program id for each channel referencing these video and audio id's. MythTV only needs the frequency and Program ID to properly tune a channel. The dtv_multiplex table is how MythTV keeps track of the frequencies for channels.
You can try using mythtv-setup's channel scan to try and find channels. Many find this won't work properly though. If things work well it should find all, or nearly all the channels you have in your custom channels.conf file. This will also have the added benefit of populating your dtv_multiplex table. If it doesn't work it may populate with non-existant channels and non-useful frequencies.
The final option is to import your custom channels.conf file. This won't work 100% properly and you will still have to edit the channels table, but it should give you a proper dtv_multiplex table.
It is suggested to modify or verify the table manually using [phpMyAdmin], a web based MySQL management tool. The table has 3 fields which we will find important,
- mplexid is the individual id number for the entry. Ideally they will be in numerical sequence, ie 1,2,3,4,5...
- sourceid is the source for which the entry corresponds to, if your HD tuner is source 2 then this would be 2.
- frequency is the frequency. Each frequency needs only be in the table once per source. So if you have 3 channels on the same frequency, it only needs to be in dtv_multiplex once for that source.
- sistandard should be atsc, its default is dvb, so make sure its correct.
- modulation should be qam_256, for North American cable systems.
Now that dtv_multiplex is ready, print or write down what frequencies correspond to what mplexid, we will need these for the channel table.
Now we can modify the channels table. Since we've already populated the table with the channel information for the guide, all we need to do is adjust the entries so that MythTV knows how to tune the channel. This only involves changing two fields, mplexid and serviceid.
In mysql use:
update channel set mplexid='x', serviceid='y' when channum='123';
To see what you are doing, try:
select chanid, channum, callsign, mplexid, serviceid from channel where sourceid='2';
(presuming that your HD3000 is sourceid 2). This will list the details for the 29 or whatever number of usable channels you receive.
You may be asking, "What about chanid, channum and freqid?". Well, none of these really matter when it comes to tuning the channel. chanid is the unique number MythTV gave that channel, it should be the sourceid followed by the channel number. freqid should be the same as channum which should be the channel your cable company assigned.
Now what you will need to do is use the information in your custom channels.conf file to enter the appropriate mplexid for the frequency of the channel from dtv_multiplex into mplexid. The other field, serviceid, is the programid number, the last number in the channel information line of channels.conf.
Lets Watch TV!
Once these two numbers are correct for all the channels associated with the HD tuner source your ready to launch mythbackend and mythfrontend and watch or record some HD channels!
Jason's Original Email
For posterity, I've left Jason Beck's orginal email here since its the guide that got most people going and inspired this article. I may also have made some mistakes in my attempt to clarify and add information to his process. This will allow anyone who finds the error to easily reference his work and fix my mistakes, though hopefully there are none ;-)--Steveadeff 23:57, 1 February 2006 (UTC)
If your provider is not kind enough to send the PSIP info you will have to add the channels manually to the database. I'll try to explain how using you channels.conf as an example. The database tables that need to be modified are channel and dtv_multiplex. dtv_multiplex should be populated by the channel scan and the channel table you will need to modify yourself. Below is an example of how you would setup your NBC (assuming ch#707)channel in Myth. 1.) go to zap2it and build your listing for your local HD broadcast channels. 2.) assign that listing to your dvb 3k in mythtvsetup 3.) go into the channel editor (still in mythtvsetup) select your new listing and do a scan (select type "cable") The scan will take some time. Mostly likely you won't really get anything useful, but what this will do it populate the dtv_multiplex table in your db. You will need this later on. 4.) exit mythtvsetup and run mythfilldatabase. This will now provide you with your xmltvids to callsign mappings. At this point you still will not be able to tune anything yet so don't try. 5.) ***Important*** stop mythbackend. 6.) edit your channels.conf and remove your PSIP values. You don't need them for Myth. So your file will look like this. NBC:561000000:QAM_256:0:0 ABC:561000000:QAM_256:0:0 CBS:567000000:QAM_256:0:0 FOX:567000000:QAM_256:0:0 7.) go ahead and fire up azap and tune a channel. $ azap -r NBC 8.) in a second terminial run dvbscan -c $ dvbscan -c What you need is the serviceid. This is the number in the [000#] at the far left. Your provider will most likely be using the same frequency for multiple channels. So you may have more then one service per freq. In this example your serviceid for NBC would be 2. Example: dumping lists (1 services)  (0x0002) 00: PCR == V V 0x0010 A 0x0011 (eng) Now stop your dvbscan and azap tune. 9.) log into your database. $mysql -u root -p mythconverg To tune the 3k you will need to find the mplexid for you known frequency. 10.) finding the mplexid mysql> select mplexid from dtv_multiplex where frequency = '561000000'; +---------+ | mplexid | +---------+ | 25 | +---------+ 1 row in set (0.01 sec) Write down the mplexid value. For example sake we will say it was 25. 11.) Now you are ready to setup the channel. You have the freqency (561000000),mplexid(25),and the serviceid(2). Assuming that you now have a channel 707 from the previous mythfilldatabase above. mysql> update channel set freqid="561000000" where channum=707; mysql> update channel set mplexid="25" where channum=707; mysql> update channel set serviceid="2" where channum=707; You may want to do a quick check to make sure all looks good. mysql> select * from channel where channum=707; mysql> quit 12.) Start mythbackend 13.) Start up the frontend and test. -- A couple of things I ran across later with the 3k. By default the 3k will be set to record in PS mode. I had wierd fastforward and rewind problems. In mythtvsetup under capture cards-->dvb-->Advanced settings I selected the "Use TS instead of PS" option and the ffw and rew problems went away. Also stopping the backend is only really needed to do the azap tune. So while your there you may just want to run the scan for serviceids for your 4 channels so you only have to do it once. I hope this helps. I just went through this about a week ago and it was not easy to find all of the info. Alot for trial and error. Let me know how it works out for you... -jason