Saturday, June 12, 2010

MythTV on an EeeBox

As many other geeks, I've spent considerable time in my life setting up MythTV and trying really hard to set it up for the perfect media center experience. I'm still struggling with some points, but I've got it working pretty decently, so I thought I'd post the result of my process, along with the still quirky points. Then hopefully somebody can use it for setting up a decent media center, and if I'm really, really lucky, some of you über geeks may have a few tips to share in the comments, so I can iron out the last weird issues.

Please note: I live in Denmark, so certain points in this post may not be relevant to you (especially the XMLTV guide). For that, you'll have to consult other blogs or - shiver! - some actual documentation.

What I bought
To get up and running, I bought the following hardware:
  • EB1012 (an Asus EeeBox with the ION graphics chipset, no optical drives)
  • Anysee EC30 Combo Plus DVB-C/T (a USB tuner supporting both DVB-C and DVB-T, and it comes with a remote control)
Apart from that, I bought an antenna splitter and the shortest, cheapest HDMI cable I could find.

Characteristics of the system
There are thousands of possible setups for running MythTV, and many people have "enterprisey" setups with a monster back-end and several front-ends. So why did I choose this simple setup?
  • Decent power consumption. With everything plugged in and running, expect an average power consumption of about 22W (excluding your TV and other stuff, of course).
  • Discrete. The EeeBox is very quiet, and it hides nicely behind my TV. The Anysee tuner "peeks out" from below, exposing the IR receiver.
  • Enough CPU and GPU power to easily play back all the contents I need to play, including HD content.
  • HDMI, separate digital optical audio (note: the EeeBox comes with a converter to plug into the jack plug at the back of the computer, so you don't need to buy one), enough USB ports, card reader, 802.11n wireless (and gigabit ethernet if you want), eSATA, ...
  • MythTV has a lot of nice features, and Ubuntu lets you fiddle with everything.
The EeeBox "only" has a 250GB harddisk, which may be too small for you. For me, it works, since I like to delete old, watched recordings anyway (and delete the ones I accept that I won't see anyway).

MythTV isn't for the faint-hearted, which this guide should make clear. I expect you to have basic Linux skills, otherwise this guide is probably useless, and in that case you should go for something simpler like EyeTV on a Mac or Windows Media Center on a Windows box.

Installation
Get Mythbuntu 10.04 from mythbuntu.org. Put it on a USB key, and make this USB key bootable.

Well, that's just not as easy as I thought it would be. There are lots of blogs out there telling you how to do it, but the only way I got it working, was with the help of a little Windows program called "Linux Live USB Creator" (http://www.linuxliveusb.com/). It does not recognize Mythbuntu directly, but it supposes it's an Ubuntu variant, which is correct.

Anyway, when you have your bootable USB key ready, put it in one of the USB ports on the EeeBox, and power on the EeeBox while holding down the F8 key on the keyboard.

How you choose to partition your hard disk is entirely up to you. I chose 20GB for the root partition, 5GB for swap, and the rest mounted as "/data". Other values will probably fit your needs better.

When prompted, choose having a combined front-end and back-end.

Update!
When your new MythTV box has booted for the first time, open "Mythbuntu Control Centre", go to the "Repositories" page, and select updates from "0.23 fixes". After that, run Update Manager, install all updates, and reboot.

Without this step, several components of MythTV didn't work properly for me.

Storage paths
Before you start using MythTV for real, remember to adjust the paths in MythBackend that define where recordings, live-tv, etc. go. It's under "Storage Directories". If, like me, you've mounted most of the EeeBox harddisk under "/data", you probably want values such as "/data/mythtv/recordings", "/data/mythtv/livetv", etc.

You should also create these directories in the file system, and remember to give proper rights to the mythtv user. I've just set all these directories to the mythtv user, the mythtv group, and given all rights possible. Perhaps that's a bit too much, but I don't want to spend time fiddling with this.

Drivers
Open "Mythbuntu Control Centre" again, go to the "Graphics Drivers" page, click "Launch Restricted Drivers Manager", and select both "Firmware for DVB cards" and "NVIDIA accelerated graphics driver". You'd think you didn't need the firmware for DVB cards, but without it, you cannot make the Anysee remote control work later.

Tuner in DVB-C mode
(I'm not sure if this first step is necessary - I'll check it out next time I re-install from scratch). Run this from a terminal:

modprobe dvb_usb_anysee delsys=0

Unfortunately, there is both a DVB-C driver and a DVB-T driver recognizing the tuner, so you'll still have trouble using the tuner after this. To fix this, you have to blacklist one of the drivers. In this case, we want to blacklist the DVB-T tuner. Add the following lines to /etc/modprobe.d/blacklist.conf:

# Force Anysee tuner into DVB-C mode
blacklist zl10353

If you want to run in DVB-T mode instead, you have to blacklist "tda10023" instead.

Setting up the tuner in MythTV
The card type must be set to "DVB DTV capture card (v3.x)", and the DVB Device Number should be set to "/dev/dvb/adapter0/frontend0". The next line should then tell you that "Frontend ID" is "Philips TDA10023 DVB-C Subtube DVB-C".

I've set my "Signal Timeout" to 5000ms and "Tuning Timeout" to 20000ms.

Channel search and setup
It's somewhat of a circus setting up channels, since subsequent, identical searches can yield different results. My only advice is to try a few times and then hope you can stitch together your channel setup. Try setting "Signal Timeout" and "Tuning Timeout" high (as I've done - see above).

I use a Danish provider called Stofa, and I can find all of their channels on frequency 346000000, modulation QAM64, symbol rate 6900000. This is probably different for your setup.

Sometimes MythTV tells me it has found a number of "off-air channels". I've no idea what that means, but typically they are channels already found as regular channels anyway.

XMLTV
In Denmark, the main national TV provider, DR, has a service that lets you grab the program information of the most used channels. You can use a grabber like "http://niels.dybdahl.dk/xmltvdk/index.php/DR_2009_grabber".

The XMLTV Perl package is installed by default in Mythbuntu, but you need to install "libparse-recdescent-perl". Then you can put the grabber script in your home directory and create the following script:


#!/bin/bash
LOGFILE=/home/me/mythfilldatabase.log
source /home/me/.profile
mv /var/log/mythtv/tvgrabbed.xmltv.1 /var/log/mythtv/tvgrabbed.xmltv.2
mv /var/log/mythtv/tvgrabbed.xmltv /var/log/mythtv/tvgrabbed.xmltv.1
cd /home/me/
./tv_grab_dk_dr_2009.mgr --days 10 --output /var/log/mythtv/tvgrabbed.xmltv > ${LOGFILE} 2>&1
/usr/bin/mythfilldatabase --file 1 /var/log/mythtv/tvgrabbed.xmltv >> ${LOGFILE} 2>&1

Then set up a Cron job: Run "crontab -e", define a line like:

00 06 * * * /home/me/mythfilldatabase.sh

Additionally, you ned to start "mythtv-setup" and define a new "Video Source" with the name "dr-xmltv" and "No grabber" as "Listings grabber". Under "Input Connections", this video source must be connected to the tuner.

Finally, run your new script. Then in MythWeb you can insert the right XMLTV IDs on the corresponding channels. Run the script again, and you get a proper channel listing in MythWeb.

Sound via HDMI or TOSLINK
If you want sound through the HDMI cable, create the file /etc/asound.conf with the following contents:


pcm.!default {
  type hw
  card 0
  device 3
}


If instead you want sound through the optical digital out, specify device 1.

Start "alsamixer" from a terminal and unmute "S/PDIF 1" by clicking M on it.

Picture quality
Turn on VDPAU in the "Setup -> TV Settings -> Playback", otherwise the EeeBox doesn't stand a chance when playing HD content.

Enable "OpenGL Vertical Sync" under "Setup -> TV Settings -> Playback". Otherwise you get "tearing" in the picture (i.e., the content is updated in the middle of the picture, so you have one part of the picture showing the previous frame, and the rest is playing the next frame).

Still, playback isn't always perfect, since the refresh rate on your TV doesn't necessarily match the refresh rate of the played material. To fix this, you need to do two things: First, go to "Setup -> Appearance", and on the "Video Mode Settings" page, check "Separate video modes for GUI and TV playback". Just choose "Any" as the rate for the GUI, and don't change the values in the "Overrides for specific video sizes" section.

Secondly, open nvidia-settings and uncheck the "Force Full GPU Scaling" on one of the pages. Voila! Playback is now perfect! (At least on my setup :-) )

The remote control
First and foremost you need to open "Mythbuntu Control Centre", go to the "Infrared" page, and check "Enable a Remote Control". Choose "Linux input layer (/dev/input/eventX)". If you cannot find this, it's because you didn't install the proprietary drivers - see above!

Run "cat /proc/bus/input/devices" from a terminal. Near the bottom of the output you'll see something like this:


I: Bus=0003 Vendor=1c73 Product=861f Version=0100
N: Name="IR-receiver inside an USB DVB receiver"
P: Phys=usb-0000:00:04.1-6/ir0
S: Sysfs=/devices/pci0000:00/0000:00:04.1/usb1/1-6/input/input6
U: Uniq=
H: Handlers=kbd event6
B: EV=3
B: KEY=148fc010 2353041 0 0 0 800 108000 4080 304801 9e0000 0 0 ffc

From the "H:" line, you can see that the remote control exists on "/dev/input/event6" - it is probably different on your system, since it depends on which USB port your tuner is in, and which other peripherals you have attached to your EeeBox.

Edit "/etc/lirc/hardware.conf", change the line

REMOTE_DEVICE="/dev/lirc0"

to

REMOTE_DEVICE="/dev/input/event6"

Then you can restart lirc with "sudo service lirc restart".

There is one real downside to doing this: Each time you reboot your EeeBox, you must have the same peripherals attached, otherwise your remote control will appear as another path. I haven't fixed this, but it should be fixable by doing this: Create "/etc/udev/rules.d/60-anysee.rules" (owner root, group root, "-rw-r--r--", just like the other files in that directory) with contents:

ATTRS{name}=="IR-receiver inside an USB DVB receiver", SYMLINK+="input/dvb-ir"

Now the remote control (also) appears as "/dev/input/dvb-ir", so you can set REMOTE_DEVICE in the lirc hardware.conf file to that. However, lirc refuses to use it, and even worse, as long as the udev rule exists, it even refuses to use "/dev/input/event6". So, I need to attach my keyboard and mouse each time I reboot my EeeBox...

Key bindings for the remote control
The remote control's "|<<" and ">>|" buttons are not "mapped" to anything in MythFrontend. I've chosen to let them work as "rewind" and "fast forward", respectively. You do this by opening "~/.lirc/mythtv" and insert the following lines:


begin
  remote = devinput
  prog = mythtv
  button = KEY_NEXT
  config = Right
  repeat = 0
  delay = 0
end

begin
  remote = devinput
  prog = mythtv
  button = KEY_PREVIOUS
  config = Left
  repeat = 0
  delay = 0
end

Playback in MythWeb
A really nice "gimmick" in MythWeb is the Flowplayer media player, which gives a YouTube-like interface to your recordings. In MythWeb, click the "MythTV:" link (upper left corner), select "Settings -> MythWeb -> Video Playback", and select "Enable Video Playback".

Securing MythWeb
There are several guides "out there" that tell you how to fiddle with stuff in /etc/apache2, /etc/httpd, etc. None of those guides seem to work... but that doesn't matter, since you just have to open "Mythbuntu Control Centre" (start it as root), go to the "Plugins" page, and enable password protection.

Start/end of recordings
It's nice to start recording e.g. 2 minutes before the official starting time, and end recording e.g. 5 minutes after the official ending time. In MythWeb, you can alter the setting "DefaultStartOffset" and "DefaultEndOffset". Both are specified in minutes, so I've set them to 2 and 5, respectively. This implies that the default values of the fields "Start Early" and "End Late" in the recording dialog page will be set to 2 and 5 minutes.

Issues still not sorted out
My daily Cron job doesn't always run. However, it successfully runs often enough that I don't have problems with my channel listing.

When I reboot the EeeBox, I need to have my keyboard and mouse attached, otherwise the remote control won't work. It seems like udev and lirc don't like each other.

Update (25th of August 2010): My setup has been working quite badly the last month or so, since the back-end sometimes takes 30 to 40 minutes to change the channel. I've borrowed another Anysee tuner from a friend, but that didn't fix the problem, so either my cable provider is sending a poorer signal (which would be weird, since my TV has no problem), or a bug has been introduced either in MythTV or the kernel driver. At around the same time, the 0.23-fixes branch was ended, and no Mythbuntu updates switched to the 0.23.1-fixes branch. I've switched to the 0.23.1-fixes branch by executing this from the command-line:

sudo add-apt-repository ppa:mythbuntu/0.23.1
sudo apt-get update

I haven't updated MythTV yet (it takes proper planning in a busy household...), so I've yet to see if this helps.

References
Helping me get this far required a number of resources on the net. In all fairness I'll list them here:

63 comments:

  1. Does you Anysee Remote still works fine with Mythbuntu 11.04?

    I'm only able to use the number keys for switching channel and the volume keys.

    ReplyDelete
  2. Oh, sorry about the late reply... don't know if I can configure Blogger to send me an e-mail when comments are added.

    I think it worked fine after I upgraded to Mythbuntu 11.04, but I have ditched the Anysee tuner + remote in favour of a HDHomeRun box and a decent remote. I've described the HDHomeRun change here: http://olefriis.blogspot.com/2010/12/hd-homerun-mythtv-dvb-c.html

    I haven't documented how to make the remote work, simply because it was mostly "plug'n'play". I bought this remote, but other MCE remotes probably work just as well: http://www.opencompany.dk/products.php?showvariant_id=9342

    All you have to do to get the remote working is to choose "Windows Media Center Tranceivers/Remotes (all)" as "Remote Control" in Mythbuntu Control Center and check "Generate dynamic button mappings". At least, this should work in LIRC 0.8.7 and newer.

    In my opinion it's worth the extra money, since the Anysee remote is quite crappy compared to e.g. the Foxconn remote.

    ReplyDelete
  3. After seeing your article I want to say that the presentation is very good and also a well-written article with some very good information which is very useful for the readers....thanks for sharing it and do share more posts like this.
    python training in pune
    python online training
    python training in OMR

    ReplyDelete
  4. Really nice experience you have. Thank you for sharing. It will surely be an experience to someone.
    Blue Prism Training Course in Pune

    Blue Prism Training Institute in Bangalore

    ReplyDelete
  5. Good Post, I am a big believer in posting comments on sites to let the blog writers know that they ve added something advantageous to the world wide web.
    angularjs-Training in sholinganallur

    angularjs-Training in velachery

    angularjs Training in bangalore

    angularjs Training in bangalore

    angularjs Training in btm

    ReplyDelete
  6. hank you for benefiting from time to focus on this kind of, I feel firmly about it and also really like comprehending far more with this particular subject matter. In case doable, when you get know-how, is it possible to thoughts modernizing your site together with far more details? It’s extremely useful to me 

    devops online training

    aws online training

    data science with python online training

    data science online training

    rpa online training

    ReplyDelete
  7. java
    Very good information. Its very useful for me. We need learn from real time examples and for this we choose good training institute, we need to learn from experts . So we make use of demo classes . Recently we tried java demo class of Apponix Technologies.
    https://www.apponix.com/Java-Institute/Java-Training-Institute-in-Bangalore.html

    ReplyDelete
  8. Definitely a great post. Hats off to you! The information that you have provided is very helpful.

    Data Science Bangalore

    ReplyDelete
  9. Very nice post here and thanks for it .I always like and such a super contents of these post.
    date analytics certification training courses
    data science courses training

    ReplyDelete
  10. I am really enjoying reading your well written articles. It looks like you spend a lot of effort and time on your blog. I have bookmarked it and I am looking forward to reading new articles. Keep up the good work.data science course in dubai

    ReplyDelete
  11. I just got to this amazing site not long ago. I was actually captured with the piece of resources you have got here. Big thumbs up for making such wonderful blog page!data science course in dubai

    ReplyDelete
  12. If you have Natural Curls or Curly Hair, you are just blessed. You can experiment with many Hairstyles which will Look Stylish here we tell about top best and easy Curly Hairstyles

    ReplyDelete
  13. This is a wonderful article, Given so much info in it, These type of articles keeps the users interest in the website, and keep on sharing more ... good luck.
    machine learning course malaysia

    ReplyDelete


  14. thanks for your information really good and very nice web design company in velachery

    ReplyDelete
  15. I Love your website i am ready your all website article 먹튀검증

    ReplyDelete
  16. Really nice post. Thank you for sharing amazing information.
    ccc exam related all full forms

    ReplyDelete
  17. Very Nice and Great i was lucky to find a good language school near berlin where i live.

    I took some private language lessons and was really suprised how much better i picked up the language 우리카지노

    ReplyDelete
  18. After reading your article I was amazed. I know that you explain it very well. And I hope that other readers will also experience how I feel after reading your article.

    digital marketing course

    ReplyDelete
  19. 이러한 최고의 노치 팁으로 비즈니스의 SEO 개선에 도움을주십시오!

    웹 사이트의 각 카테고리별로 높은 게재 위치를 달성하는 방법을 이해하는 것은 문자 그대로 성공적인 비즈니스와 실패한 벤처의 차이입니다. 비즈니스 거래에 성공하려면 아래에 제공된 검색 엔진 최적화 팁을 읽으십시오.

    URL에서 관련 키워드를 사용하여 최대 검색 엔진 순위에 맞게 웹 사이트를 설정하십시오. 키워드가 페이지의 다른 곳에 나타나는 한 검색 엔진은 URL에 사용 된 용어에 상당한 가중치를 부여합니다. 사이트에 사용 된 도메인 이름을 제어 할 수없는 경우에도 페이지 이름은 귀하에게 달려 있습니다.

    사이트 SEO를 설정할 때 사이트의 URL을 잊지 마십시오. 도메인을 설정하면 하위 도메인보다 도메인이 더 좋습니다. 또한 약 10 단어를 초과하는 URL은 스팸으로 분류 될 위험이 있습니다. 도메인에서 약 3-4 개의 단어를 원하고 페이지 이름에서 6 또는 7을 넘지 않아야합니다.

    웹 사이트에 권한이 있는지 확인하십시오. 검색 엔진 최적화는 고객 및 / 또는 고객이 브랜드를 신뢰하는 경우에만 성공할 수 있습니다. 기억하기 쉬운 전용 도메인 이름은 사람들이 웹 사이트 체크 아웃을 마치고 오랫동안 기억할 수있는 브랜드를 구축하는 첫 번째 단계입니다.

    검색 엔진 결과 페이지 상단에 도달하는 확실한 방법 중 하나는 훌륭한 콘텐츠를 보유하는 것입니다. 흥미 롭거나 재미있는 정보를 지속적으로 제공하면 사람들이 자연스럽게 귀하의 사이트로 돌아 가기를 원할 것입니다. 훌륭한 콘텐츠를 만들기 위해 노력하는 경우 전문 작가를 고용하는 것이 좋습니다.

    이러한 아이디어 중 일부를 바로 사용할 수 있지만 다른 아이디어는 장기적으로 효과적 일 수 있습니다. 귀하의 사이트를 더 잘 인식하려면 다음 정보를 현명하게 사용하십시오 구글상단대행.

    ReplyDelete

  20. Really awesome blog!!! I finally found a great post here.I really enjoyed reading this article. It's really a nice experience to read your post. Thanks for sharing your innovative ideas. Excellent work! I will get back here.
    Data Science Course in Marathahalli
    Data Science Course Training in Bangalore

    ReplyDelete
  21. Very useful blog thanks for sharing very nice 아바타배팅

    ReplyDelete
  22. i think you are very nice person because your website is very great 코인카지노

    ReplyDelete
  23. When someone writes an paragraph he/she retains the image of
    a user in his/her brain that how a user can be aware of it.

    So that's why this post is outstdanding. Thanks!thanks a lot.
    Ai & Artificial Intelligence Course in Chennai
    PHP Training in Chennai
    Ethical Hacking Course in Chennai Blue Prism Training in Chennai
    UiPath Training in Chennai

    ReplyDelete
  24. If you have the proficiency in these fields, you will have an added advantage over other professionals. Once you become an expert, you can demand a higher pay. 360DigiTMG data science course in hyderabad

    ReplyDelete
  25. I like your post. Everyone should do read this blog. Because this blog is important for all now I will share this post. Thank you so much for share with us.



    AWS Training in Hyderabad

    ReplyDelete
  26. "Thanks for the Information.Interesting stuff to read.Great Article.
    I enjoyed reading your post, very nice share.data science training"

    ReplyDelete
  27. Awesome post.Really nice blog, i enjoyed your infomations. Thank you and i will expect more in future..keep it up!!
    Amazon Web Services Training in Chennai

    ReplyDelete
  28. This is CRM software which contains tools your sales team is going to use for the proper and well management of your company. Salesforce training in India

    ReplyDelete
  29. Shop Repair & Buy Mobiles Online At best prices in India only at https://rshop.in/location/anand-nagar-hublidharwad/

    ReplyDelete
  30. Thanks for posting the best information and the blog is very good. ethical hacking training in kolkata

    ReplyDelete
  31. If You Are Looking For A Reliable Fx Broker, Don't Rush And Read This XM REVIEW Review First. This Is A Serious Warning Against The Broker's Illegal Activities.

    ReplyDelete
  32. Become a data science expert by joining AI Patasala’s Data Science Training in Hyderabad program, where you can learn data science advanced topics with real-time knowledge.
    Data Science Course Training in Hyderabad
    Data Science Training Institute in Hyderabad

    ReplyDelete

  33. Fudxcoin deals in selling and purchasing of crypto currency. It deals in blockchain technology.

    Crypto currency is the digital currency or virtual currency with is used as a medium of exchange where individual ownership records are stored in computer.There are many types of Crypto currency like Bitcoin,Ethereum,Ripple Etc

    The rate of crypto current going in market varies day to day.Crypto currency can be purchased from coin base and different sites like Fudxcoin(www.Fudxcoin.com)
    Block Chain Technology is the method of keeping record of sale and purchase of crypto currency.


    contact@fudxcoin.com
    +1 209-921-6581

    ReplyDelete
  34. Wow! Such an amazing and helpful post this is. I really really love it. It's so good and so awesome. I am just amazed. I hope that you continue to do your work like this in the future also.
    full stack web development course in malaysia


    ReplyDelete