2009/01/05

Making an AppleTV into a MythTV Frontend

The AppleTV makes an excellent MythTV frontend that can play 1080i HDTV. Buying a used one on Ebay is probably the cheapest way to get a HD capable frontend for MythTV.

I was curious about the stock AppleTV software, so I tried it for a few days but found it too restrictive. The picture browsing was only usable for a small number of pictures and the video player could only play a few video formats. The YouTube and Flickr features seemed nice but were not essential features to me. If you like the iTunes store then you might want to keep using the AppleTV software as that's what it was designed for.

But this is about MythTV and it's time to move on to the good stuff.
As this is a followup to my earlier MythTV post you'd already need the MythTV backend setup.

What you need:
  1. an AppleTV
  2. a USB flash drive 1GB or larger
  3. a USB hub, keyboard, and mouse
  4. a programmable universal remote control
    (my Harmony 550 from Newegg is great)
These are the steps:
  1. Connect the AppleTV to your TV/projector with the HDMI cable and whatever audio cables you want to connect.
    I got my cables from MonoPrice (they have HDMI to DVI cables if you need one)

  2. Create a bootable USB flash disk

  3. Backup the AppleTV software

  4. Reformat the internal drive for Linux

  5. Install MythBuntu 8.10 (I have upgraded to 9.04 without any problems)
    you'll need the keyboard and mouse for this
    choose the latest Nvida driver (I used version 177)
    enable VNC during the installation so you won't need the keyboard and mouse later

  6. After installation remember to do the "Post Boot Fixes"
    The ones for "Mythbuntu Hardy" also work for 8.10 (Intrepid)

    In the /usr/sbin/nvidia_hang_fix.sh file I had to use 200,720 for GPU2DClockFreqs instead of the recommended 200,800 (the 177 driver won't allow overclocking above 720).
    This fixes 1080i playback stability (no more green distortion and freezing).

  7. Setup the remote control (follow the instructions from this link)
    These are most of the files and commands you'll need to use.
    /etc/lirc/hardware.conf
    sudo /etc/init.d/lirc stop
    sudo irrecord -H macmini -d /dev/usb/hiddev0 /etc/lirc/lircd-new
    /etc/lirc/lircd.conf
    ~/.lirc/mythtv
    ~/.lirc/mplayer
    irw /dev/lircd
    sudo /etc/init.d/lirc start

    The Apple remote has only 6 buttons, so have your programmable remote "learn" those 6 and then hold the menu and play button for 5 seconds and then the Apple remote will have 6 new codes for your programmable remote to learn.

    If the remote repeats buttons too quickly increase the repeat value in ~/.lirc/mythtv (mine is set to 5 and and the delay is 0)

  8. Edit /etc/X11/xorg.conf and remove all the extra screen resolutions
    (my projector is 1280x720 so I left that one and removed the rest)

  9. Autostart irexec
    Applications -> Settings -> Settings Manager -> Autostarted Apps
    add command "irexec -d"

  10. The AppleTV CPU is not very powerful so you'll want to disable CPU intensive MythTV theme options
    • Setup -> Appearance
      "Use Transparent Boxes" unchecked
      "Popup Background Shading Method" None
    • Setup -> TV Settings -> Program Guide
      "Guide Shading Method" Eco
    • Setup -> TV Settings -> Playback
      "Current Video Playback Profile" CPU--
      "Display thumbnail preview images of recordings" unchecked
      "Display live preview of recordings" unchecked

  11. I setup a rsync cron job to sync my pictures to the AppleTV hard drive
    rsync -rl --delete --size-only --stats -h -e 'ssh -c blowfish' ~/photos/ appletv:/var/lib/mythtv/pictures/

  12. I keep all my video files on my backend with the big hard drive and use NFS to mount them on the AppleTV.
    edit /etc/exports on the backend to share the NFS directory
    edit /etc/fstab on the frontend to automatically mount the NFS shared directory

One caveat is that the TV/projector needs to be turned on when the AppleTV is booted or Xorg won't detect/enable the display and won't startup. If you know how to solve this please let me know.
UPDATE: This is resolved thanks to Will's comments. The forum with the solution is here http://ubuntuforums.org/showthread.php?t=913224, and the concise version is:
  • run xvidtune -show
    edit the /etc/X11/xorg.conf file
    add the output from xvidtune to the "Monitor" section as a "modeline"
    add Option "ExactModeTimingsDVI" "True" to the "Screen" section
    add Option "ConnectedMonitor" "DFP" to the "Screen" section

References:

10 comments:

Peter Schneider said...

Thanks for the post, I am trying to get my system setup and everything I find is one more step to success. In step 6 you note "After installation remember to do the post install fixes
The ones for "Mythbuntu Hardy" also work for 8.10(Intrepid)". I had not come across any post installation fixes, could you elaborate?

Ben said...

I think I meant to link to these post boot fixes. I've updated the original post to include the fixes I needed on Mythbuntu 8.10 for the nvidia 1080i stability, and the remote repeating too rapidly. The only glitch left in my system is slight audio breakup when the OSD pops up during 1080i playback and the CPU get overloaded for a few seconds.

Unknown said...

Thanks for the post. It helped a lot. One issue I ran into: For hours I couldn't get the HDMI video out to work. My TV showed it was getting a signal and showed the correct refresh rate and resolution. It even showed the refresh rate / resolution changing when I changed those settings (using VNC). But the screen was black. Finally, in desperation, I unplugged the HDMI cable and tested the TV with my laptop. When I plugged it back into the AppleTV, the MythTV screen appeared! The only problem now is when I reboot I have to (usually but not always) unplug and plug the HDMI cable to get video out. I always see the boot console messages on the TV but when GNOME starts, the display goes blank. Hope this helps someone else if they have the same problem

Unknown said...

I solved my problem and at the same time figured out how to configure the system so the TV/projector does not need to be turned on when the AppleTV is booted. See my note at the bottom of this page:

http://code.google.com/p/atv-bootloader/wiki/PostMythbuntuHardy

I can share my xorg.conf file or more detailed steps if needed.

Ben said...

Will, thanks for the solution to the display being off during the boot. I think my system is running almost perfectly now. It's really cool!

Ling said...

I assume that you could have chosen to us samba rather than NFS. I am running several xbox/xbmcmythtv setups and I don't want to replace them all at once until I see how this works. Thank for the guide. I am waiting for my appletv to arrive. I decided to buy one to replace my main xbox after reading your guide.

Ling said...

Also, my HD-capable TV does not have HDMI or DVI inputs. With this work with the RGB?

none said...

Thanks for this howto. I'm pretty much a total linux noob, and while it took awhile to work my way through it I now have mythtv working on my appletv. My only real problems came in getting the remote working. I didn't understand that the name for the remote had to be consistent in all the lirc related files. It should have been obvious, but it wasn't to me so I spent some time watching the remote work perfectly in irw and not controling myth before it finally hit me. Lirc setup in the post install fixes had a line calling irrecord that ended up naming the remote in a non-intuitive way if you just copied and pasted as I did, and that name didn't match the name in the lircrc append later in the tutorial. Other than that it went really well, and a big part of that was due to your distillation of the googlecode pages which were (for me) a lot harder to follow. Thanks!

Scott said...

So can I still use the apple TV software? Or is it toast?

Ben said...

In one step you backup the original Apple software, and in the next step you format the drive and replace it with Linux. If you ever want to go back to the stock Apple TV software you would restore it from the backup you made.