OpenELEC Forum
HOWTO: OpenElec/Raspberry Pi 2/TvHeadend - Printable Version

+- OpenELEC Forum (https://forum.openelec.tv)
+-- Forum: Generic Forum (https://forum.openelec.tv/forumdisplay.php?fid=5)
+--- Forum: PVR + LIVE TV (https://forum.openelec.tv/forumdisplay.php?fid=38)
+--- Thread: HOWTO: OpenElec/Raspberry Pi 2/TvHeadend (/showthread.php?tid=75761)

Pages: 1 2


HOWTO: OpenElec/Raspberry Pi 2/TvHeadend - pleco - 03-04-2015

I just wanted to drop a note for anyone who will be using the Raspberry Pi 2 with OpenElec and TVHeadEnd on how to get it all setup. I spent a couple of days on this and wanted to document it. It is not as straightforward as one would hope (or at least it wasn't for me).

Note that this setup is for US ATSC and all machines are running linux, so I don't have any advice for non-US or Windows.

The first thing you will need to do is purchase an MPG2 license from Raspberry Pi store. It cost about $3 USD. If you don't have this, you will get no video, only audio.
Second, I highly recommend using a powered USB hub. My tuner is the WinTV-HVR-950, and it draws enough power to overwhelm the 5V 2A power supply.

You will need to install the TVHeadEnd server. This is done in OpenElec interface by adding the Unsupported OpenElec repository to the Addons. Once you do this, initiate a refresh of the addons. When this completes, you will see the TVHeadEnd server addon under Services in the Unsupported repository. Install this and then reboot.

After reboot, you will need the access the TVHeadEnd web interface at http://<ip addr of your raspberry>:9981. On this page, choose Configuration Tab, then go to DVB Inputs. You should see your TV Adapter listed here. If you don't, then you need to check to make sure your adapter is supported by TvHeadEnd, etc.

Select the Adapter and Service type. In my case, since I'm in the USA, I wanted the ATSC. On the right hand side, check to enable the device. Also, uncheck Initial Scan and Idle Scan. Click Save.

Now click on the Networks tab. Click Add to create a new network. You will be asked to select a Type; make this the same as the Adapter Service type. In my case, this was the ATSC Network. Now enter a descriptive name. Check Network Discovery, uncheck Skip Initial Scan. Click Save.

Now click on the Muxes tab. Choose the network you just created.

Go back to the TV Adapters tab and select the Adapter/Service. On the right hand side, select the network in the Networks drop down. Click save.

Now reboot the raspberry pi.

After reboot, the tvheadend will start up scan the adapter looking for channels. Connect back to the web page and click on Configuration/DVB Inputs/Networks tab. You should start to see the # Muxes # Sevices numbers start to change. If you click on the Muxes tab you will see the channel frequencies. Notice the SCAN RESULT. If it says OK, a signal was detected on that channel. You wait a few minutes for the scan to complete.

Now click on the Services tab. Click on the Map All button. Then click Map. The channels that were detected will now be displayed. At this point we should be ready to watch TV on the raspberry. I would suggest a final reboot of the Raspberry.

On the OpenElec interface, you will need to install the TVHeadEnd client in the Addons. Once this is installed, go back to the System configuration, select Live TV, and enable it. You should now have a TV option on the main screen (you may need to reload your skin.) You should now be able to selected channels and watch TV!

Now for the EPG. This will be very dependent on your location. In the US, TVHeadEnd cannot grab EPG info from over the air signal, so we must use a third party to download the information and import it into TVHeadEnd. I use http://www.schedulesdirect.org/ which will provide the information for $25 / year with a 7 day free eval.

There are 2 ways to get the info into TVHeadEnd, manual and automatic. Either way, you will need a computer that has XMLTV utils installed. You can download this from http://sourceforge.net/projects/xmltv/files/xmltv, but on my debian machine I installed from apt-get. I assume the Windows version is similar, but my instructions will be linux based.

In my situation, I have a debian based nas server. So I installed xmltv-utils on it. You must configure the grab utility first, so execute this in a terminal:

Code:
tv_grab_na_dd --configure

I took the defaults for all options. I did encounter one issue. A web site it was trying to connect to was timing out. I found a workaround online by editing the /etc/hosts file and putting the following line:

Code:
54.85.117.227 docs.tms.tribune.com webservices.schedulesdirect.tmsdatadirect.com

I then setup a cron job to grab the data from Schedules Direct every day and put the file on my web server. This is done by running the following command:

Code:
tv_grab_na_dd > /path/to/a/file

This will create a file that contains the epg data. You can also run this command manually to create the file.

Now that we have the file, we need to get it over to the Raspberry PC so that TVHeadEnd can process it. Since I am putting my file on an internal web server, I can simply use wget to grab the file and put it on a my Raspberry server, in this case I created a folder in /storage called epg and put the file there. To start things, I ssh into the Raspberry and ran the following command to get the initial file.

Code:
wget http://<webserver/epg.xml -O /storage/epg/epg.xml

Now, back in OpenElec, go to the TVHeadEnd server addon and click Configure. There is a tab to configure the XMLTV. You will want to enable this and specify the location of the file that is on the Raspberry (in my case /storage/epg/epg.xml)

TVHeadEnd uses a simple script to read the contents of the file. It is located in /storage/.kodi/addons/service.multimedia.tvheadend/bin/tv_grab_file. You will want to open this script file in an editor (nano). I added the following 2 lines to the script at the beginnning:

Code:
rm /storage/epg/epg.xml
wget http://<webserver/epg.xml -O /storage/epg/epg.xml

So, everytime TVHeadEnd executes the tv_grab_file script, it will automatically grab the latest file from the web server.

Now, go back to the TVHeadEnd web interface. Click on Configuration/Channel EPG/EPG Grabber. Under General Config check the 3 Update channel info. Uncheck all modules in the Over-the-air grabbers and external interfaces. Click Save. Under Internal Grabber, the Module dropdown may or may not have an additional option besides Disabled at this point. If it does, choose it and click Save again. If it doesn't, you might want to reboot the Raspberry, then come back to this page. After you are able to select the new Module, click save configuration.

If everything is setup correct, TVHeadEnd should now have loaded the EPG data. The last step is to Map the channels to the EPG data. This is done in the Configuration/Channel EPG/Channels tab. You will need to go to each channel, then select the drop down under the EPG Source column and match to the correct EPG channel data. After this is done, I suggest another reboot.

Once Openelec is back up, you should have your EPG data on screen. If you don't, you will need to go back to the TVHeadEnd web GUI and look at the system log to see what errors you may be getting.

I hope this has been helpful. Please feel free to post any comments and corrections. I will try and get screenshots for some of the items soon.


HOWTO: OpenElec/Raspberry Pi 2/TvHeadend - akon - 03-05-2015

pleco post=134179 Wrote:Now, back in OpenElec, go to the TVHeadEnd server addon and click Configure. There is a tab to configure the XMLTV. You will want to enable this and specify the location of the file that is on the Raspberry (in my case /storage/epg/epg.xml)

TVHeadEnd uses a simple script to read the contents of the file. It is located in /storage/.kodi/addons/service.multimedia.tvheadend/bin/tv_grab_file. You will want to open this script file in an editor (nano). I added the following 2 lines to the script at the beginnning:

Code:
rm /storage/epg/epg.xml
wget http://<webserver/epg.xml -O /storage/epg/epg.xml

So, everytime TVHeadEnd executes the tv_grab_file script, it will automatically grab the latest file from the web server.

Now, go back to the TVHeadEnd web interface. Click on Configuration/Channel EPG/EPG Grabber. Under General Config check the 3 Update channel info. Uncheck all modules in the Over-the-air grabbers and external interfaces. Click Save. Under Internal Grabber, the Module dropdown may or may not have an additional option besides Disabled at this point. If it does, choose it and click Save again. If it doesn't, you might want to reboot the Raspberry, then come back to this page. After you are able to select the new Module, click save configuration.

If everything is setup correct, TVHeadEnd should now have loaded the EPG data. The last step is to Map the channels to the EPG data. This is done in the Configuration/Channel EPG/Channels tab. You will need to go to each channel, then select the drop down under the EPG Source column and match to the correct EPG channel data. After this is done, I suggest another reboot.

Once Openelec is back up, you should have your EPG data on screen. If you don't, you will need to go back to the TVHeadEnd web GUI and look at the system log to see what errors you may be getting.

I hope this has been helpful. Please feel free to post any comments and corrections. I will try and get screenshots for some of the items soon.

Thanks, that is a helpful post. I'm a US ATSC user too and I hadnt been able to figure out how to populate the epg. Was much easier on earlier tvheadend versions. The channels were all found and mapped. Xmltv file created and pointed to within OpenElec. Since the internal grabber option is grayed out-disabled for me (was that the case for you before editing the grab file?), I thought I was supposed to use the external grabber at the bottom that would grab the xmltv file from the specified location within openelec's service add on configuration page. That never worked though, always coming up 0 stations etc. I'll try and edit that grab file and hopefully that enables the internal grabber.


Re:HOWTO: OpenElec/Raspberry Pi 2/TvHeadend - steveuk23 - 03-05-2015

Nice guide I could have done with this last week but I managed to get help from someone.
I noticed you've not mentioned how to add your new MPEG-2 licence into your config which I had to google as I'm useless lol


Re:HOWTO: OpenElec/Raspberry Pi 2/TvHeadend - pleco - 03-05-2015

On my system, I had to remount the /flash as read write:

Code:
mount -o remount,rw /flash

then you can edit the config.txt file

Code:
nano config.txt

Scroll to the bottom of the file and look for the MPG license entry. It is commented out. Remove the # and put in the serial that you received in email when you buy the license. Save the changes, and reboot.


HOWTO: OpenElec/Raspberry Pi 2/TvHeadend - pleco - 03-05-2015

One thing I have found is that after setting up the EPG you will still see "Disabled" on the web gui....but if you wait a little while and refresh it will pick up the changes and you can then select it. Also, I ssh into the box and made a backup copy of the config file after I made the change because I have found on reboot TVHeadEnd would "forget" about the change and go back to disabled.

To be honest I have found TVHeadEnd not to be very stable on either the Raspberry or on a PC. I'm considering switching back to PC and running MythTV and repurposing my Raspberry.


HOWTO: OpenElec/Raspberry Pi 2/TvHeadend - jimb137 - 03-08-2015

A Question... I've just recently installed OpenELEC 5.0.5 on a RPi. I've added a bunch of Video Add-ons, and can now watch a variety of programs (Soccer, F1, etc.). Is it possible to record one of these for later viewing? If so, HOW???

Thanks, Jim


HOWTO: OpenElec/Raspberry Pi 2/TvHeadend - chewitt - 03-09-2015

No, and we don't provide support for piracy plugins in these forums.


HOWTO: OpenElec/Raspberry Pi 2/TvHeadend - armueller2001 - 03-10-2015

Pleco, maybe you can help me out. I followed your tutorial and cannot for the life of me get my damn tvheadend to scan for channels from the web interface. I have attached jpegs of my config screens for TV adapter, networks, and muxes to the thread below. Any obvious problems with how I have it set up?

http://openelec.tv/forum/71-pvr-live-tv/75865-problems-with-tvheadend-and-hdhomerun


HOWTO: OpenElec/Raspberry Pi 2/TvHeadend - kphammond9 - 03-30-2015

I recently set up something similar. If you're looking for a free alternative to schedules direct, you can use zap2xml, which is a perl script, to build your xmltv.xml file. You'll need to install perl, obviously. Also, if you cannot get tvheadend to see your tv_grab_file, try dropping it into the /etc/bin directory. Tvheadend is configured to look there by default, I believe. Might also be /usr/bin. I can't remember off the top of my head, but one of those should work.


HOWTO: OpenElec/Raspberry Pi 2/TvHeadend - big_red_frog - 09-26-2015

Just capturing a tip here. I recently tried to enable EPG for my ATSC channels on a terrestrial antenna in Canada.

First off mc2xml which uses the microsoft backend no longer works, although it looks like it does, the data in the xmltv.xml file generated all ends in July!

Moved to zap2xml.pl and at first was mystified as everything seemed to work via the web, but the script failed to log into my account. Apparently linux / the perl script doesn't recognise any $ character in the password, assuming its a perl escape sequence. So you get 3 instances of...

[Attempt 1] Invalid e-mail address/password. Please log in again.

Once I had scratched my head, started shotgun debugging the script and realised this, a quick change to my password, and everything started working.

I now have EPG to the 8 ATSC channels right to all 5 openelec kodi on raspberry pi, from my tvheadend instance on my headless linux box that all my other house services run on...

Next challange is that central record for current programs via kodi->tvheadend works fine, but I can't seem to schedule recordings against the epg for future programs, maybe it is not supported, but seems the obvious feature.