Project

General

Profile

Comprehensive Tvheadend, XBMC, HDHomerun How To

Added by M B almost 13 years ago

The purpose of this post is to document how after much trail and error I was able to get XBMC to play live TV from my HdHomerun via Tvheadend. I hope it is useful for someone else. I make no claims that it is the only or even the best way to go about accomplishing the goal, only that it worked for me. Please note that this is a complete summary according to the best of my recollection. With this in mind further note that it is not beyond me to possibly have omitted some steps that I either forgot or consider so obvious that they do not need mentioned. Please provide feedback if you feel some added steps ought to be included and I will do my best to update the OP accordingly.

Install XBMC with TV/DVR Support:
sudo apt-add-repository ppa:alexandr-surkov/dharma-pvr
sudo apt-get update
sudo apt-get install xbmc

Install Hdhomerun software:
sudo apt-get install hdhomerun-config hdhomerun-config-gui

Make sure the HDHomerun is found:
hdhomerun_config discover

Output should read something like:
hdhomerun device 103194EA found at x.y.z.a

If it doesn't check your firewall(s).

Install tvheadend:
sudo apt-get install tvheadend

Make sure tvheadend web UI works and set up users:
open browser go to: http://tvheadendserver:9981/
click "Configuration" tab, click "Access Control" tab;
set up 1 admin user (all rights);
set up 1 xbmc user (all rights except admin);
optionally limit access to local host by setting both prefixes to 127.0.0.1/32.

Stop tvheadend:
sudo service tvheadend stop

Install other needed stuff (dvbhdhomerun driver):
sudo add-apt-repository ppa:tfylliv/dvbhdhomerun
sudo apt-get update
sudo apt-get install dvbhdhomerun-dkms dvbhdhomerun-utils
sudo service dvbhdhomerun-utils start

Set kernel module to load on boot:
sudo echo dvb_hdhomerun >> /etc/modules

Config dvbhdhomerun:
sudo nano /etc/dvbhdhomerun
change settings to fit your config as described in file.

Restart:
sudo reboot

Start all the little helpers:
sudo userhdhomerun -f
sudo service dvbhdhomerun-utils start
sudo service tvheadend restart

Finish tvheadend config:
open browser, go to: http://tvheadendserver:9981/
click "Configuration", click "TV Adapters"
Select an adapter in dropdown list;
Check Autodetect muxes and Idle scanning;
optionally change the adapter name;
click save;
Click Add DVB Network by Location and select yours;
The Status display will now change to show how many Muxes there are and how many more need scanned;

Set up XML Grabbing:
While the muxes scan go to: http://www.schedulesdirect.org/ and register for an account;
Log in, click "Add a new lineup" and follow the prompts;
Sign out;

sudo /usr/bin/tv_grab_na_dd --configure
follow the prompts

sudo cp ~/.xmltv /home/hts/
click the "XML TV tab";
Click "Enable debug output" (the little gear at the bottom right);
Select "North America (Data Direct)";
set desired grab interval;
check "Enable grabbing";
hit save;
wait for the XML Grabber to do its thing (about 2 minutes), you will be notified it is done in the debug window;
go back to "TV Adapters", with any luck your muxes awaiting initial scan will now be down to 0;
if so, continue below, if not have a cup of coffee or something and wait till theyre done;

Map DVB Services:
Click Map DVB services to channels
Click the "Channels" tab;
for each channel double click in the XMLTV source column and match the channel to the corresponding source;
Save your changes and close the browser.

Config XBMC:
Start XBMC;
go to System -> Settings -> Addons -> Installed Addons -> PVR Clients -> Tvheadend HTSP Client -> Configure;
Make changes to suit your setup;
hit ok;
hit enable;
escape to main settings screen;
select Live TV;
check enabled;
escape to XBMC main screen;
select Live TV and verify it works;
you are done.

Closing note:
I have to repeat the "Start all the little helpers:" step after each reboot. Yes, they could be included into some sort of startup script but no, I could not be arsed to find out how. If anyone cares to share, please enlighten me :)

For reference, I am running the following specs:
Acer Revo 1600 stock, except upgraded to 2gb ram
HTS Tvheadend 2.13
Dvbhdhomerun 0.0.9-2
Lubuntu 11.10
XBMC Pre-11.0


Replies (28)

RE: Comprehensive Tvheadend, XBMC, HDHomerun How To - Added by Raymond Paulsen almost 13 years ago

Hi Nice guide you have put togheter here. thanks
but noticed that you use tvheadend 2.13

isnt the latest version possible to get 2.12.99
or am i worng here?

RE: Comprehensive Tvheadend, XBMC, HDHomerun How To - Added by M B almost 13 years ago

The alexandr-surkov/dharma-pvr PPA has version 2.13.

RE: Comprehensive Tvheadend, XBMC, HDHomerun How To - Added by Hein Rigolo almost 13 years ago

There is no official version 2.13 and using a 2.13 already will cause upgrade problems when it is officially released.

Hein

RE: Comprehensive Tvheadend, XBMC, HDHomerun How To - Added by M B almost 13 years ago

Ah, ok, did not realize that. Although I'm thinking that as long as you keep the alexandr-surkov/dharma-pvr PPA it should be OK since it will update from there, no?

RE: Comprehensive Tvheadend, XBMC, HDHomerun How To - Added by Joshua Welch almost 13 years ago

I changed my rc*.d to:
/etc/rc2.d/S99tvheadend
/etc/rc3.d/S99tvheadend
/etc/rc4.d/S99tvheadend
/etc/rc5.d/S99tvheadend

and that fixed it where i do not have to boot stuff up on restart. Just restarts.

RE: Comprehensive Tvheadend, XBMC, HDHomerun How To - Added by Jeremy C almost 13 years ago

Could you please elaborate on how you changed rc*.d as described? I've got it all working (thanks!!!) but must run the "little helpers" after reboot.

RE: Comprehensive Tvheadend, XBMC, HDHomerun How To - Added by Joshua Welch almost 13 years ago

Absolutely!

it is actually really easy. I changed the NAME of each of the start up processes, I believe they were S20tvheadend, and I changed them to be S99tvheadend. It is important to note that you should NOT change the K20tvheadend, just the ones that start with S.

I only changed the name. After it boots up, wait about a minute and check the web interface, should be up and running. I would suspect you could turn it down from 99 to 70 or so and get it pretty smooth, but I haven't tried that.

RE: Comprehensive Tvheadend, XBMC, HDHomerun How To - Added by Hein Rigolo almost 13 years ago

the number in the name determines the order in which the services are started. so 99 means that tvheadend is started as the last service when the machine is started. the same is true for the "K" files. They are used when the machine is shutdown and determines the order in which the services are stopped (in reversed order)

Hope that explains these numbers ... but on "modern" systems you can actually set dependencies on the startup scripts (like tvheadend depends on hdhomerun to be started etc)

Hein

RE: Comprehensive Tvheadend, XBMC, HDHomerun How To - Added by Joshua Welch almost 13 years ago

Thanks for clearing that up Hein. Do you know how to do it in a "modern" way specifically for the hdhomerun?

RE: Comprehensive Tvheadend, XBMC, HDHomerun How To - Added by Jaime Vazquez over 12 years ago

http://forum.xbmc.org/showthread.php?tid=127803

After going through the above tutorial, I found this additional script from the XBMC forums especially helpful. Obviously it's specific to the HDHomerun tuner, but it shows an example of a script to get all of the driver loading and services to load in an automated way.

RE: Comprehensive Tvheadend, XBMC, HDHomerun How To - Added by Fabian Rodriguez about 12 years ago

Thanks for the great guide, I was about to write this from scratch!

There are a few typos/ways to do this shorter/better. I am going through it and double-checking, will post again here before finding a place for it in the wiki.
If anyone wants to pitch in, the working document is here:
http://lite.framapad.org/p/0iZwijvtos

Regarding the HDHomerun setup, specifically, I sumamrized instructions here (I will refer to this in the above steps):
https://www.lonelycoder.com/redmine/boards/4/topics/5969

I've filed this bug report in TVHeadend about not seeing the HDHomerun adapters after reboot:
https://www.lonelycoder.com/redmine/issues/1354

Please comment it/watch it if you are interested in getting it solved.

RE: Comprehensive Tvheadend, XBMC, HDHomerun How To - Added by Richard Leckinger about 12 years ago

The easiest way to sort the failure of tvheadend to detect the hdhomerun after a reboot is to edit /etc/init/tvheadend.conf to make it wait for the dvbhdhomerun-utils daemon to finish, and it's child process userhdhomerun. You must be sudo:

$ sudo gedit /etc/init/tvheadend.conf

Comment out the existing 'start on' line. See comments in my example, with my changes:

#Replaced start line to force wait until dvbhdhomerun-utils has completed
#at which time it emits dvbhdhomerun
#start on (local-filesystems and net-device-up and started udev-finish)
start on dvbhdhomerun
stop on runlevel [!2345]

expect fork
respawn

#Added an extra 30 second wait before starting tvheadend, as the userhdhomerun
#process in dvbhdhomerun-utils needs to finish completely for tuner discovery

script

sleep 30
followed by existing code

end script

Reboot your machine, give it a minute and then check that tvheadend has correctly detected and loaded your hdhomerun device.

This is elegant and doesn't require messing with update rc.d, which has been deprecated by upstart in ubuntu in any case. This file will likely get overwritten when you update or reinstall tvheadend, but it is easy enough to edit again.

Using tvheadend 3.2~precise from adamsutton STABLE PPA

RE: Comprehensive Tvheadend, XBMC, HDHomerun How To - Added by jack jack almost 12 years ago

UBUNTU 12.10
ppa:
https://launchpad.net/~adamsutton/+archive/tvheadend/+index?field.series_filter=

adding the 'sleep 30' breaks reboot. adding 'start on dvbhdhomerun' seems to be fine, but the sleep statement gets me stuck at shutdown at

'Asking all remaining processes to terminate'

for much longer than 30 seconds . I'm really not sure what it is: a bug in upstart, a bug in tvheadend, a misconfiguration but this whole getting tvheadend to start properly at boot is giant disaster. The way it is currently configured has upstart run the scripts at boot once again this starts tvheadend too soon, so the people who were using the start-tvheadend-right.sh solution, I'm not sure how they got it to work. They must be on a distribution which doesn't use upstart, because if they did then upstart would start tvheadend too early and it still wouldn't solve anything.

RE: Comprehensive Tvheadend, XBMC, HDHomerun How To - Added by Anonymous almost 12 years ago

I used a loop in my upstart script that checks /dev/dvb if the adapters are present, if not it sleeps for 1 second. This works really well, it starts tvheadend as soon as the driver is loaded and won't hang on anything for shutdown.

Will post the script asap.

RE: Comprehensive Tvheadend, XBMC, HDHomerun How To - Added by Anonymous almost 12 years ago

/etc/init.tvheadend.conf

# tvheadend - DVB/IPTV streaming server
#
# Tvheadend is a TV streaming server for Linux supporting DVB, ATSC, IPTV,
# and Analog video (V4L) as input sources.

description "Tvheadend DVB/IPTV streaming server" 
author      "Adam Sutton <[email protected]>" 

#start on (local-filesystems and net-device-up and started udev-finish)
start on dvbhdhomerun
stop  on runlevel [!2345]

expect fork
respawn

script

        while [ ! -d /dev/dvb ]
                do
                sleep 1
        done

  [ -r /etc/default/tvheadend ] && . /etc/default/tvheadend

  [ "$TVH_ENABLED" = "1" ] || exit 0

  ARGS="-f" 
  [ -z "$TVH_USER"      ] || ARGS="$ARGS -u $TVH_USER" 
  [ -z "$TVH_GROUP"     ] || ARGS="$ARGS -g $TVH_GROUP" 
  [ -z "$TVH_CONF_DIR"  ] || ARGS="$ARGS -c $TVH_CONF_DIR" 
  [ -z "$TVH_ADAPTERS"  ] || ARGS="$ARGS -a $TVH_ADAPTERS" 
  [ -z "$TVH_HTTP_PORT" ] || ARGS="$ARGS -w $TVH_HTTP_PORT" 
  [ -z "$TVH_HTSP_PORT" ] || ARGS="$ARGS -e $TVH_HTSP_PORT" 
  [ "$TVH_DEBUG" = "1"  ] && ARGS="$ARGS -s" 

  exec tvheadend $ARGS $TVH_ARGS
end script

RE: Comprehensive Tvheadend, XBMC, HDHomerun How To - Added by jack jack almost 12 years ago

If you are using ubuntu, and the above doesn't work, like me, because it would no longer shutdown/reboot, you can:

1) disable upstart script /etc/default/tvheadend and set TVH_ENABLED=0
2) put the following in /etc/rc.local (update-rc.d like the link above may also work but you KNOW rc.local is the last thing that will load):

while [ ! -d /dev/dvb ]
do
        sleep 2
done
sleep 50
tvheadend -f -u hts -g video
exit 0

This worked for me.

RE: Comprehensive Tvheadend, XBMC, HDHomerun How To - Added by Anonymous almost 12 years ago

I don't see how my script affects rebooting. What version of Ubuntu are you using?

RE: Comprehensive Tvheadend, XBMC, HDHomerun How To - Added by jack jack almost 12 years ago

Yes, it's not always obvious why bugs behave the way they do, if we always knew why, we wouldn't call them 'bugs' ;). I'm not saying that this will always happen, I'm not saying it will even happen to most people, it may be something very particular to my setup or a misconfiguration. But I swear to god and all that is holy that if I comment out the sleep statement it works, but if I keep the sleep statement it doesn't reboot and gets stuck (more info above). My guess is the solution posted by Richard Leckinger will work for most people, and it is indeed the preferred solution, but if not, my solution is there too.

RE: Comprehensive Tvheadend, XBMC, HDHomerun How To - Added by Richard Leckinger almost 12 years ago

Kia ora Frank

Jack Jack is right, the 'bug' I introduced with my recommended script change still exists with your version, at least on my two machines. I didn't know it existed because I never rebooted my machine until I went to replace it this week. :)

I have about a two minute delay when executing a shutdown. I have no idea why this is happening or how to 'fix' it. I'm happy in the knowledge that my tvheadend plays nice with my hdhomerun and I can live with the delay in shutdown until a wiser head recommends something better.

RE: Comprehensive Tvheadend, XBMC, HDHomerun How To - Added by Anonymous almost 12 years ago

Hello Richard,

I have made some further changes to my upstart scripts, I too had a long delay at shutdown after all. Now I have the following:

/etc/init/dvbhdhomerun-utils.conf

# HDHomeRun DVB Driver
#
# The userspace daemon that talks with the SiliconDust HDHomeRun.

description     "HDHomeRun DVB Driver Userspace Daemon" 
author          "Villy Thomsen <[email protected]>" 

start on net-device-up IFACE=p10p1
stop on starting shutdown

expect fork

script
    exec /bin/userhdhomerun -f -d
end script

emits dvbhdhomerun

respawn
respawn limit 2 3600

post-start script
    sleep 8    
    initctl emit dvbhdhomerun
end script

The loop has been replaced by the sleep 8 before the emit dvbhdhomerun, adjust the 8 to more or less, depending on how fast or slow your boot is. If it is too low, you won't see any adapters in tvheadend.

You have to change the interface name to what you are using, probably eth0 or maybe also p10p1.

I start the driver with -d because I don't want all the logging but you can leave that out if desired.

/etc/init/tvheadend.conf

# tvheadend - DVB/IPTV streaming server
#
# Tvheadend is a TV streaming server for Linux supporting DVB, ATSC, IPTV,
# and Analog video (V4L) as input sources.

description "Tvheadend DVB/IPTV streaming server" 
author      "Adam Sutton <[email protected]>" 

start on dvbhdhomerun
stop  on runlevel [!2345]

expect fork
respawn

script
  exec tvheadend -f -u hts -g video
end script

Let me know if this works better for you as well.

Gelukkig nieuwjaar!

RE: Comprehensive Tvheadend, XBMC, HDHomerun How To - Added by durandal therogue almost 11 years ago

I too had this and tracked it down to it's root cause. I came with the same solution as your final one, Frank, but was not happy with it since it didn't use the config file.

The final solution is, from the original conf file, delete the 'sleep' line and set 'start on dvbhdhomerun'.
I detailed full cause and solution in the other thread:
https://tvheadend.org/boards/5/topics/6655?r=10146

RE: Comprehensive Tvheadend, XBMC, HDHomerun How To - Added by M Anderson almost 11 years ago

I'm attempting to follow this guide using Ubuntu 12.04.3 Server. Almost everything works, but when I attempt to install dvbhdhomerun-dkms and -utils, I always get an error message:

First Installation: checking all kernels...
Building only for 3.8.0-29-generic
Building initial module for 3.8.0-29-generic
Error! Bad return status for module build on kernel: 3.8.0-29-generic (x86_64)
Consult /var/lib/dkms/dvbhdhomerun/0.0.16~precise/build/make.log for more information.
Setting up dvbhdhomerun-utils (0.0.16~precise) ...
start: Job failed to start
invoke-rc.d: initscript dvbhdhomerun-utils, action "start" failed.
dpkg: error processing dvbhdhomerun-utils (--configure):
subprocess installed post-installation script returned error exit status 1
Processing triggers for libc-bin ...
ldconfig deferred processing now taking place
Errors were encountered while processing:
dvbhdhomerun-utils
E: Sub-process /usr/bin/dpkg returned an error code (1)

I've also tried building them from the source and I get error messages there as well.

Can anyone offer me a solution to get this guide working?

RE: Comprehensive Tvheadend, XBMC, HDHomerun How To - Added by Darren Cunningham almost 11 years ago

I'm having the same problem with Ubuntu 12.04.3, you figure anything out?

RE: Comprehensive Tvheadend, XBMC, HDHomerun How To - Added by M Anderson almost 11 years ago

Yes.

Apparently, newer versions of the Linux Kernel are not compiled with something called the "DVB Headers," and DVBHDHomerun needs them.

The solution is to recompile your Kernel with the DVB Headers, or to use an older version of Ubuntu. I don't know how to recompile the Kernel, so I went back to Ubuntu 10.04.4 Server and got it working. However, the TVHeadEnd Repo won't work on Ubuntu 10.04.4, so you'll have to manually add the repo or download the package and install TVHeadEnd manually.

If you or anyone knows how to recompile the Kernel with the DVB Headers in Ubuntu, please post it here. I'm working on a newer complete how-to guide and plan to post it in a couple of days.

For now, there are instructions on how to recompile in Debian, which you can find here:

http://sourceforge.net/apps/trac/dvbhdhomerun/wiki/Building

RE: Comprehensive Tvheadend, XBMC, HDHomerun How To - Added by M Anderson almost 11 years ago

I just posted a complete set-up guide. You can find it here:

https://tvheadend.org/boards/4/topics/10322

(1-25/28)