Tuesday, August 21, 2007

Recording Standard Definition TV from DirecTV with MythTV

In a followup to my note to myself on playing live TV from my satellite box using mplayer, this is about integrating a pcHDTV 3000's s-Video input into my MythTV system.

It would, of course, be nice if I could get all the programming I want in unencrypted HD, but sometimes all you can get or afford is old fashioned analog. In my case, I have a D12-300 DirecTV satellite receiver on my desk, this extra receiver costs me $5 a month over the cost for the receiver in the TV room, so it's a fairly good deal. What makes it a better deal is using my MythTV to time shift, skip commercials and watch it anywhere in the house wirelessly onto my MacBook.

Hardware



Most of the hardware I already had. I did purchase the USB to serial adaptor—according to accounts on the web not all adaptors work with DirectTV receivers—and the null modem adaptor.

Hardware setup

I plugged the USB end of the USB to serial adaptor into the DirecTV receiver, and the serial end into the null modem adaptor. I plugged the other end of the null modem into the serial port of my Dell Dimension—tighten those screws. I plugged the s-Video cable into the s-Video output of the satellite receiver, and into the s-Video input of the pcHDTV card. I plugged the RCA jacks of the audio cable into the red/white outputs of the satellite receiver and the mini-jack end into the line in port (2nd from the right) of the AV-710.

Software setup

My previous posting described setting up the system audio to activate the line in port for audio input. I would follow those instructions now, to confirm you can see and hear live TV via mplayer.

As I will be using a script to change channels over the serial port, I want a non-root user account to open up the serial port device, so as root from the command line:
# chmod a+rw /dev/ttyS0

I would test this by running your copy of the directv.pl script. For example:
$ /usr/share/mythdora/directv.pl 231
should bring up the Food network. (Your path will be different, probably.)

I went to my account on (the soon to be discontinued) zap2It labs and setup a listing grabber for DirecTV, limiting it to the 10 or so channels I would conceivably watch.

Then I ran mythtv-setup.
  • Capture Cards
    • Card Type: Analog V4L capture card
    • Video device: /dev/video
    • VBI device: /dev/vbi
    • Audio device: /dev/dsp
    • Audio sampling rate limit: 48000
    • Do not adjust volume: Checked
    • Default input: S-Video
  • Video Sources
    • Video source name: DirectTV
    • Rest of the settings are dependent on your having setup up a listing grabber for DirecTV
  • Input connections - [V4L :/dev/video] (S-Video) -> DirectTV
    • Display Name (optional): DirecTV
    • Video source: DirecTV
    • External channel change command: /usr/share/mythdora/directv.pl (your path will be different)
    • Preset tuner to channel: 231
    • Click on the Fetch channels from listing source
    • Starting channel: 231
    • Input priority: -1


Of course, I kept my pcHDTV's DVB setup to record over the air digital HD programming, although I did change the Recording Options for the Capture Card to only "Open DVB card on demand".
[Update: somewhere along the way, I lost ATSC tuning for the pcHDTV card, and I'm having a hard time getting it back. For me, this is not an urgent matter as I have the two tuners in my HDHomerun, but obviously it would be important to anybody with only a pcHDTV. I'll try to figure this out, but I think it has to do with a conflict between my kernel version and the DVB drivers.] [Update 2: I updated mythtv to the current build to support Schedules Direct and it works again. I apparently can now record off of one of the pcHDTV's outputs at a time (not both at once.)]

At this point, you should run mythfilldatabase.

I then restarted the mythbackend, and opened up the mythfrontend, but before watching any TV, I had to setup my recording profiles.
  • Utilities/Setup
    • Setup
      • TV Settings
        • Recording Profiles
          • Software Encoders (v4l based)
            • Default
              • Enable auto-transcode after recording: Checked
              • Width: 720
              • Height: 480
              • Codec: MPEG-4
              • Codec: MP3
              • Sampling rate: 48000
            • Live TV
              • Enable auto-transcode after recording: Checked
              • Width: 720
              • Height: 480
              • Codec: RTjpeg
              • Codec: Uncompressed
              • Sampling rate: 48000

Conclusion

After finishing all this, I was very surprised that I could watch Live TV both at my MythTV box itself, and over wireless with my MacBook, and I could also schedule recordings and it would all work. I like having a wired connection to the satellite box for changing channels, it should be 100% reliable unlike an infrared blaster arrangement. The video is amazingly ugly compared to the beautiful HD I get from my antenna, but then again, it's going to be a while before Good Eats comes in over the air.

I keep my audio sampling, storing and playback rates at a constant 48000 Hz as it is the standard playback rate for the PCM stereo audio which will eventually go out the optical port to my audio receiver, and I don't see the point of adding another possible failure point in the sampling conversion. My previous MythTV install made 44.1Khz recordings sound high pitched.

I'm just glad I'm done with this, and I hope this saves you some time.

Friday, August 17, 2007

Playing Live TV from Satellite box on Linux

This is more of a note to myself, as I'm sure this involves an unusual set of hardware and software.

I have a standard definition DirectTV satellite box on my desk. I wanted to display its content on my Mythdora Linux box—actually, I want to record standard definition programming with MythTV, but I haven't quite gotten there yet. [Update: This post is about recording]. I have a pcHDTV 3000 capture card in my Linux computer with an s-Video input, and a Chaintech AV-710 audio card with a line level input (it's the second one from the right). I figured I could bring the video in through the s-Video port and the audio in through the line level port via an s-Video cable and an RCA to mini-jack cable, it would just take a little configuration tweaking.

First, I had to use alsamixer to turn on capturing, so I brought up the capture display for the AV-710 by using alsamixer -V Capture and selecting the Line capture item and hitting the space bar and then setting the Capture level item to a moderate value. (Actually, I did a ton of stuff trying to make this work, but I think it boiled down to this.)

Then I had to figure out the voodoo to cause mplayer to display the video from the pcHDTV card combined with the audio from the AV-710 card. This ended up being:

mplayer -tv driver=v4l2:device=/dev/video:input=2:outfmt=rgb24:alsa:amode=2:audiorate=48000:forceaudio:immediatemode=0 -vo xv tv:// -vf pp=lb -ao oss:/dev/adsp

Breaking this command line into parts:
  • -tv driver=v4l2:device=/dev/video:input=2 means the Video For Linux framework will grab video from input 2 of the pcHDTV card
  • alsa:amode=2:audiorate=48000:forceaudio:immediatemode=0 means audio will come from the ALSA frameworks default capture device at a sampling rate of 48000 Hz (which is the frequency that my TOSLink output needs)
  • -vo xv tv:// set the video output
  • -vf pp=lb means to use a linear blend deinterlace algorithm
  • -ao oss:/dev/adsp means to output it to what happens to be the optical output of the AV-710

Sunday, August 12, 2007

Mac MythTV Frontend Settings

There are a lot of MythTV settings. Page after page of preferences. In many ways, this is bad design; a refusal by the authors to make decisions about correct and incorrect behavior. But that's the situation, and here are a few settings where I think the value should change.


Utilities/Setup.Setup.General.Audio.Enable AC3 to SPDIF passthrough
If you have your Mac hooked up to a receiver via an optical cable, remember to check this or you will throw away your surround sound. Unfortunately, it doesn't auto-detect the absence of such a cable and fall back to non-passthrough, so you'll end up unchecking this when you move your Mac.
Utilities/Setup.Setup.Apearence.Theme.Theme
If you are using a widescreen Mac, or attaching your Mac to an HDTV, you should try MythCenter-wide as the theme. Non-wide screen themes tend to get their lower buttons cut off in the more complicated preference panels.
Utilities/Setup.Setup.Apearence.Theme.QT Style
The Mac themed buttons are unusable (transparent blue on blue). Use Windows style.
Utilities/Setup.Setup.TV.Playback.General Playback.Deinterlace playback
Unless you have a Mac which can just barely display 1080i content, or your monitor will deinterlace content for you, you should turn this setting on.
Utilities/Setup.Setup.TV.Playback.General Playback.Algorithm
This is something you should investigate for yourself. Run the Activity Monitor application in your /Applications/Utilities folder to determine the performance hit of the various deinterlace methods, and test them for effectiveness. In particular, the BOB method doesn't work well for me, while the Kernel method works but uses more of my CPU. I will try using the One field method.
Utilities/Setup.Setup.TV.Playback.On Screen Display.OSD Theme
The Gray-OSD theme seems the the most tasteful of the bunch.
Utilities/Setup.Setup.TV.Playback.On Screen Display.Always use Browse mode when changing channels
If your channels take as long to change as mine, you'll prefer to see what's on before committing to changing the channel.
Utilities/Setup.Setup.TV.Playback.Mac OS X Video Settings 2/2.Video in the dock
I think this feature is pretty useless and a waste of power.

Sunday, August 05, 2007

Why Can I use MythTV with 802.11g, but not EyeTV?

The Linux box in the basement runs the MythTV backend. I can watch live HDTV wirelessly using 802.11g networking through the Linksys router in my back bedroom to my MacBook. As long as the microwave isn't on, and I stay within 30 feet or so of the router, the picture and sound are typically great.

I have an HDHomeRun networked HDTV tuner right next to the Linksys router, and I cannot watch 5 seconds of TV wirelessly without a skip, big pixilation, or pop using the EyeTV application. Using wired ethernet it's fine, but 802.11g? Forget about it.

I can set the MythTV to grab a stream from the HDHomerun, bring it down to the MythTV via wired ethernet, and then back up the same wire to the router, and out as radio waves, and it still works smoothly. I just watched 20 minutes of 1080i HD golf on CBS without a skip; although twisting the MacBook around will cause the occasional skip at this distance—perhaps 25 feet through a floor and a couple walls.

Why can MythTV do what EyeTV can't in this situation? I don't know; presumably it has more flexibility in buffering at the source, but it still has to average the same bit rate. MythTV might be better at handling lost packets... Again, I don't know. I just know MythTV works better for wireless HDTV.

Thursday, August 02, 2007

New Windows Remote Desktop Beta

The Mac Business Unit at Microsoft released the first beta of Remote Desktop Connection 2. This is good news for me. A perk of my job is that I get to do most of my C++ coding on my Mac, but I do need a PC on my desk for Visual Studio to implement and debug Windows specific objects. As I require cutting and pasting between the two environments, I use Remote Desktop Connection on my iMac to put a full screen PC on a secondary monitor. I can copy and paste text between the two environments, using the same trackball and keyboard; and I can do full compile link cycles while not taking away from my Mac's performance unlike a Parallels virtual machine.


Unfortunately, I was irked by inexplicable slowdowns and unreliable text pasting; and I had no real hope of the situation brightening as I believed Microsoft had abandoned Remote Desktop Connection development, and I would be stuck forever with a PowerPC only, buggy hack. And yet, here out of Redmond comes a beta of a universal binary version 2. Read the blog entry announcing the release. They took use cases like mine into account; I like the easy sharing of a Mac folder as a Windows volume; text pasting seems instantaneous, and GUI performance is fairly snappy on my 20" Intel iMac.


It shows its beta-ness. I crashed it several times trying to bring it up on my second monitor before it stuck. I hope the MacBU will fix the more blatant bugs in short order. Thanks MS.