HDTV to DVD: More on Tuning/Storing
The other day, I posted some information about using pcHDTV's HD-3000 card to record High Definition content and eventually converting it into a DVD Format. I didn't really go into the detail about working with the HD-3000 card (tuning for over the air broadcasts or cable). Today, I'll go in to a little bit more detail.
Let's start with the scenario that you are working with Over-the-Air broadcasts, also known as 8VSB (Eight Level Vestigial Sideband Modulation). Again, this is a Kernel version 2.6.12 or later. I'm going to first remove the cx88-dvb module, and reinsert the cx88-dvb module. You may need to remove all cx88- based drivers from the kernel, but for me - I only need to modprobe cx88-dvb. Also note that you'll need to be aware where the dvb-apps I reference below are installed/compiled. I have most of them in my PATH environment variable. Also, you'll need to move from process to process frequently, so I recommend using KDE or Gnome to jump from command shell to command shell.
We'll need to run a script that gathers broadcast information for us. Below I'll be working with my local "Channel 12" as an example. This NBC station digitally markets itself as "12.1" or "12.2" for NBC WeatherPlus. If you go to Antennaweb.org and punch in zip code 85248, you'll see that KPNX-DT is actually assigned to UHF channel 36. UHF channel 36 actually broadcasts near 605MHz - so you'll note the frequencies below don't really jive up with channel numbers that well. Station owners just feel that their older station numbers have more value, so the provision was built into ATSC PSIP.
[root@localhost scan]# rmmod cx88-dvb
ERROR: Module cx88_dvb does not exist in /proc/modules
[root@localhost scan]# modprobe cx88-dvb
[root@localhost scan]# ./atscscan atsc/us-NTSC-center-frequencies-8VSB
scanning atsc/us-NTSC-center-frequencies-8VSB
using '/dev/dvb/adapter0/frontend0' and '/dev/dvb/adapter0/demux0'
>>> tune to: 57000000:8VSB
WARNING: >>> tuning failed!!!
>>> tune to: 57000000:8VSB (tuning failed)
WARNING: >>> tuning failed!!!
>>> tune to: 63000000:8VSB
WARNING: >>> tuning failed!!!
>>> tune to: 63000000:8VSB (tuning failed)
The application cycles through all ATSC frequencies looking for digital data. Eventually, it will find something like...
>>> tune to: 491000000:8VSB
service is running. Channel number: 5:1. Name: 'KPHO HDTV 5.1'
After a while, it will dump information you'll need for an azap.conf file, such as the following.
>>> tune to: 803000000:8VSB (tuning failed)
WARNING: >>> tuning failed!!!
dumping lists (20 services)
KPHO HDTV 5.1:491000000:8VSB:49:52:3
KTVK-DT:533000000:8VSB:49:52:1
[ffff]:545000000:8VSB:0:0:65535
[ff7f]:545000000:8VSB:0:0:65407
KUTP DT:545000000:8VSB:49:52:3
KUTP DT:545000000:8VSB:65:68:4
KSAZ DT:575000000:8VSB:49:52:3
KTVW DT:593000000:8VSB:49:52:3
Telefutura:593000000:8VSB:65:68:4
KPNX:605000000:8VSB:0:0:65535
Weather:605000000:8VSB:65:68:2
KPNX-DT:605000000:8VSB:49:52:1
KASW-DT:683000000:8VSB:49:52:1
KPPX Digital Television:701000000:8VSB:49:52:3
KPPX Pax:701000000:8VSB:65:68:4
KPPX Worship:701000000:8VSB:81:84:5
KPPX FaithTV:701000000:8VSB:97:100:6
KNXV HDTV:725000000:8VSB:49:52:3
KNXV Digital television:725000000:8VSB:65:68:4
KNXV Analog Television:725000000:8VSB:0:0:65535
Done.
[root@localhost scan]#
You need to cut and paste the lines that actually have tuning data into a file. This is generally placed in "$HOME/.azap/channels.conf". Personally, I would clean this list up a little. I'm getting rid of all the "God Channels" and channels where they speak a language I don't understand, and make the names a little more memorable. Note that some stations rebroadcast the old NTSC station (KUTP as below) in their digital broadcast spectrum, along with the new (usually high definition) ATSC signal. Usually, NBC stations will offer NBC WeatherPlus along with traditional high definition content.
KPHO-DT:491000000:8VSB:49:52:3
KTVK-DT:533000000:8VSB:49:52:1
KUTP-DT:545000000:8VSB:49:52:3
KUTP-2:545000000:8VSB:65:68:4
KSAZ-DT:575000000:8VSB:49:52:3
KTVW-DT:593000000:8VSB:49:52:3
KPNX:605000000:8VSB:0:0:0
KPNX-DT:605000000:8VSB:49:52:1
WEATHERPLUS:605000000:8VSB:49:52:1
KASW-DT:683000000:8VSB:49:52:1
KNXV-DT:725000000:8VSB:49:52:3
KNXV-2:725000000:8VSB:65:68:4
Now that you have have this configuration file in the right place, you can tune a channel. Remember, to use the '-r' flag, as this tells Linux to expect video/audio content from the /dev/dvb/adapter0/dvr0 file/device. Also, leave this running for the time being - in a few minutes you'll "control-c" to break out of the process.
[root@localhost scan]# azap -r KPNX
using '/dev/dvb/adapter0/frontend0' and '/dev/dvb/adapter0/demux0'
tuning to 605000000 Hz
video pid 0x0000, audio pid 0x0000
status 00 | signal 3999 | snr cd37 | ber 00000000 | unc 00000000 |
status 1f | signal cd90 | snr f90f | ber 00000000 | unc 00000000 | FE_HAS_LOCK
status 1f | signal cd90 | snr f8c5 | ber 00000000 | unc 00000000 | FE_HAS_LOCK
status 1f | signal cf9c | snr f915 | ber 00000000 | unc 00000000 | FE_HAS_LOCK
status 1f | signal cd90 | snr f8c5 | ber 00000000 | unc 00000000 | FE_HAS_LOCK
status 1f | signal cd90 | snr f8df | ber 00000000 | unc 00000000 | FE_HAS_LOCK
In this example, I'm tuning the channel as a whole. I could have azap -r KPNX-DT to tune the specific subchannel, but I didn't. There's some good information here in the azap output, signal is your signal power (received). ( CD90 / FFFF = about 80% signal). The SNR (signal to noise ratio) is a bit more important. You can be getting a powerful signal, but it can be noisy (static). The signal to noise ratio tells me that of the 80% signal I'm getting, it's about 97% usable. Overall, this is a pretty healthy signal. If these conditions weren't met, the FE_HAS_LOCK indicator may disappear (albeit momentarily and may not impact picture quality).
Now, just for curiosity, let's take a look at what is all being sent in the overall stream for KPNX in Phoenix. The dvbtraffic instruction will keep cycling information. If you see more than a screenful's worth of information with dvbtraffic, you probably have tuned too noisy of a signal.
[root@localhost dvbtraffic]# dvbtraffic
-PID--FREQ-----BANDWIDTH-BANDWIDTH-
0000 10 p/s 1 kb/s 16 kbit
0030 10 p/s 1 kb/s 16 kbit
0031 8969 p/s 1646 kb/s 13489 kbit
0034 312 p/s 57 kb/s 470 kbit
0040 10 p/s 1 kb/s 16 kbit
0041 3063 p/s 562 kb/s 4607 kbit
0044 155 p/s 28 kb/s 233 kbit
1d00 12 p/s 2 kb/s 19 kbit
1e00 18 p/s 3 kb/s 28 kbit
1e80 1 p/s 0 kb/s 2 kbit
1ffb 42 p/s 7 kb/s 63 kbit
1fff 304 p/s 55 kb/s 458 kbit
2000 12913 p/s 2370 kb/s 19422 kbit
The PID (Program Identifier) column is listed in hexadecimal. We can see a lot of data coming through on 0x0031, and some more coming coming in at 0x0034. 0x0031 represents the video data, and 0x0034 represents the audio data. In this case, this is actually the High Defintion channel statistics. You'll also see another pair at 0x0041 and 0x0044 - this is the NBC WeatherPlus station. You'll also occasionally see other audio information (smaller bandwidth size). This is sometimes digital radio or Spanish/Second Audio Program (SAP).
Now, let's move on to cable, or QAM.
It's important to note that you're not going to be able to tune all HD Channels with the the HD-3000 card. I've heard that Comcast is actually pretty good about letting a good number of channels through via QAM, and I know Cox is not. I don't understand this, as you can generally watch basic cable channels like TNT or Comedy Central without a cable box - you should be able to do the same with digital broadcasts. Unfortunately, this is an instance where a cable company doesn't want to let you get away from using a cable box, unless they absolutely have to.
Since I've started dabbling with this technology, a better way of doing this has probably been developed. For now, I'll just explain the way I did this. First, you'll need to download a sample conf file with standard US cable frequencies. I have one available here.
Second, go to the "Local HDTV" section at AVSForum. You'll have to search for a thread about your metropolitan area. In the case of Phoenix, "DoubleDAZ" has graciously provided this content...
76-1 KSAZ-DT (Fox 10) 76-2 KASW-DT (WB 61) 79-1 KNXV-DT (ABC 15) 79-2 KPHO-DT (CBS 5) 81-1 KAET-DT-1 (PBS HD) 81-2 KPNX-DT (NBC 12) 81-3 KAET-DT-2 (PBS Kids until 4pm, then simulcast of the analog KAET-TV) (SD 480i)
So, I'm interested in channels 76, 79, and 81. From the standard frequencies file that I referenced, this is...
C76:537000000:QAM_256:0:0
C79:555000000:QAM_256:0:0
C81:567000000:QAM_256:0:0
The AVSForum.com data gives me the subchannels, so I can azap -r C81. Note that the signal levels are much lower, yet my snr is still pretty high. This is fine.
using '/dev/dvb/adapter0/frontend0' and '/dev/dvb/adapter0/demux0'
tuning to 567000000 Hz
video pid 0x0031, audio pid 0x0034
status 00 | signal aabf | snr fcc3 | ber 00000000 | unc 00000000 |
status 1f | signal 04dc | snr fc8f | ber 00000000 | unc 00000000 | FE_HAS_LOCK
status 1f | signal 0105 | snr fc91 | ber 00000000 | unc 00000000 | FE_HAS_LOCK
status 1f | signal 04dc | snr fc93 | ber 00000000 | unc 00000000 | FE_HAS_LOCK
status 1f | signal 04dc | snr fca1 | ber 00000000 | unc 00000000 | FE_HAS_LOCK
status 1f | signal 0105 | snr fcc7 | ber 00000000 | unc 00000000 | FE_HAS_LOCK
I can then run dvbscan
[root@localhost scan]# ./dvbscan -c
using '/dev/dvb/adapter0/frontend0' and '/dev/dvb/adapter0/demux0'
WARNING: filter timeout pid 0x1ffb
dumping lists (3 services)
[0002] (0x0002) 00: PCR == V V 0x0031 A 0x0034 (eng)
[0001] (0x0001) 00: PCR == V V 0x0021 A 0x0022 ( )
[0004] (0x0004) 00: PCR == V V 0x0043 A 0x0046 (eng)
I can see the video and audio pairs and other information I need from this screen. Eventually, I can wind up compiling all this information to a proper QAM conf file.
CKPNX:567000000:QAM_256:49:52:2
CKAET:567000000:QAM_256:33:34:1
CWEAT:567000000:QAM_256:67:70:4
So, starting out with the information from AVSForum.com, I can see that I have three digital channels on channel 81. Cable Channel 81 is running at 567MHz (567000000 Hz). Tuning and locking on to that frequency, I can run dvbscan to get more PID information. Remember 0x0031 and 0x0034 are hexadecimal values, that's 49 and 52 in decimal, respectively. That means that my cable configuartion for KPNX is CKPNX:567000000:QAM_256_49:52:2
I can also tell you that there are more digital channels coming through on Cox in Phoenix than listed above. Feel free to play around and see what you can find on your cable system. Note that you don't really need any additional service from your cable company, these are generally sent in to your home even if you don't have a device capable of tuning them.
Now that we are able to tune, you can watch or capture. To watch, I generally use mplayer or gmplayer. My monitor runs at 1280x1024, and NBC and CBS run at 1920x1080 (more resolution, less frames per second). For NBC and CBS, I use the following gmplayer command line:
gmplayer -vf scale=960:520 /dev/dvb/adapter0/dvr0
With this setting, I can scale "Full Screen" on my monitor and it looks a bit nicer. ABC and Fox run at 1280x720 (less resolution, more frames per second). I don't scale these, as my monitor can handle the resolution. Though, I do usually add an 'autosync' option because audio can sometimes get out of sync.
gmplayer -autosync 30 /dev/dvb/adapter0/dvr0
Note that a lot of stations haven't putting time or money into mastering HDTV. I've noticed that some Fox Owned and Operated stations don't "package" audio correctly. gmplayer may display "a52: CRC check failed" audio errors. Read this thread http://www.pchdtv.com/forum/viewtopic.php?t=1048, you'll come up on a post about a patch to mplayer that fixes this problem. I personally run with two versions of mplayer because of this issue.
To dump the tuned transport stream into a file,
cat /dev/dvb/adapter0/dvr0 > hdrecord.ts
Note that you can't record and watch at the same time, though you can have gmplayer play the .ts file you are dumping into as you are recording.When you're done viewing, "control-c" to break out of the azap process (this keeps a tuned lock on the station).
As I mentioned in the other post, you may also want to check into inklings's pcHDTVR program. I use it, and recommend it. I'll give some info on this later, but within the next couple of days, I'll move you towards the next step on preserving this content in DVD - "ProjectX".