RaspbmcCrystalbuntu

Post Reply 
 
Thread Rating:
  • 2 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Live TV on Pi with Tvheadend (all running on one Pi) Updated - 24/9/12
09-06-2012, 08:13 PM (This post was last modified: 01-15-2013 03:16 AM by Dilligaf.)
Post: #1
Live TV on Pi with Tvheadend (all running on one Pi) Updated - 24/9/12
TVHEADEND IS NOW INCLUDED IN RASPBMC OUT OF THE BOX, AS SUCH MUCH OF THIS TUTORIAL IS OBSOLETE.

Hi all. Just thought I'd let everyone know details about my setup. After being re-tweeted by Sam I've had various people ask me about how to get live TV working on the pi without a separate TV server.

About my setup
-----------------
My Pi is running Raspbmc and Tvheadend. It can play and record live TV as well as stream live TV to other devices on my home network.

Here is a quick video of it all running... I apologize for how crap and shaky it is. http://www.youtube.com/watch?v=rHQQvvFONs4
New, better, less shaky video coming soon!

Note: My Pi is overclocked (but not overvolted). It has arm_freq=900 & sdram_freq=450. I have tested with no overclock at all (arm_freq=700) and it all still works, although it is a bit slow in the menus and changing channel. So if you can overclock it is probably a good idea.

As a side note, my pi is also running samba and, with my 3Tb hard drive, I'm using it as a NAS too. This all seems to work fine together with tvheadend and xbmc.

Required Hardware & Software
------------------------------
Raspberry Pi - Obviously

TV Tuner - I'm using K-World UB499-2T Dual DVB-T USB Tuner (available in the UK from Maplin HERE) but other tuners may work as long as drivers are available. For information on tuners see the linuxtv.org wiki. Best bet would be to find a tuner that has drivers in the 3.2 (or earlier) linux kernel.
This site has good information on that - http://linuxtv.org/wiki/index.php/Hardwa...nformation

I would recommend a good powered usb hub. From what I've seen TV tuners can be quite power hungry and the Pi may struggle to supply sufficient power, especially if you have other usb devices connected.

Raspbmc - Other OSes for the Raspberry Pi should work but I prefer Raspbmc over OpenELEC or Xbian (and raspbian is a little to general for my liking). And the PVR support in the Raspbmc nightlies simplifies things quite a bit. I did have to upgrade the kernel to get my TV tuner to work but Sam has provided tools and scripts to help with this. RC5 will not require a kernel upgrade as it is already running a 3.2 kernel.

Tvheadend - Again, other backends would probably work but I've only tested Tvheadend and it seems to have all the functionality I need.

Codecs - I have the Mpeg2 and VC-1 codec licenses. I think at least the Mpeg2 license will be required for TV in most countries but I may be wrong.

Optional: An external harddrive to record to - I have a 3Tb Buffalo Drivestation. Or alternatively you can use a NAS or network share on another system.


How to set it all up
----------------------
The first step is to setup Raspbmc. I'll not go into details of this here as there is plenty of info on this on the website and on these forums. This would be a good time to add the codec licenses.

My next step was to build and install a new kernel. Raspbmc RC4 has a 3.19 based kernel and so didn't have drivers for my TV tuner. (Update: It looks like the default RC4 kernel doesn't have any DVB drivers in it so a new kernel will be needed even if your tuner had kernel support in 3.19 or earlier) However the 3.2 linux kernel does have the drivers and the raspberry pi foundation have released the source for 3.2. If you don't want to try and build the kernel yourself (or can't be bothered to wait for it to build, it can take a while) you can use my build. If so, move on to the next step otherwise you can build the kernel yourself now. I used Sam's guide from HERE to build the new kernel.

To install a new kernel (and to setup other things) on your Pi you will need to run some commands on the pi. Easiest way to do this is with an ssh client like putty. Again there is already plenty of info on this so I won't give details.

To install my build run the following commands
Code:
sudo -s
cd /
wget http://goo.gl/jFh9x -O rootfs.tar.gz
tar -xzf rootfs.tar.gz
cd /boot
wget http://goo.gl/Xj3IR -O vfat.tar.gz
tar -xzf vfat.tar.gz
reboot

If you have built the kernel yourself copy kernel-rootfs-latest-hardfp.tar.gz to the root of the SD card and kernel-vfat-latest-hardfp.tar.gz to /boot and then run the following, otherwise skip this part
Code:
sudo -s
cd /
tar -xzf kernel-rootfs-latest-hardfp.tar.gz
cd /boot
tar -xzf kernel-vfat-latest-hardfp.tar.gz
reboot

Next set is to download and install some required packages. Run the following
Code:
sudo apt-get update
sudo apt-get install unzip libcurl4-openssl-dev pkg-config git build-essential dvb-apps

The next step is to get the firmware for your tuner. Not all TV tuners require firmware, But many do. I have made a pack with all the firmware files I could find. To install this run the following:
Code:
cd /lib/firmware
sudo wget goo.gl/xZSPH -O dvb_firmware.tar.gz
sudo tar -xzf dvb_firmware.tar.gz
Alternatively you can check the linuxtv.org wiki for info on firmware for your tuner. If you need the get_dvb_firmware script you can download it from http://landspike.com/Raspbmc/

Now to build and install Tvheadend. This is done on the Pi and will take a little while to complete. RC5 will include Tvheadend.
Code:
cd ~
git clone https://github.com/tvheadend/tvheadend
cd tvheadend
./configure
make
sudo make install

Now to make Tvheadend start with xbmc
Code:
cd /etc/init    
sudo wget http://goo.gl/TzqJn -O tvheadend.conf

Next you will need to configure Tvheadend. First step is to start it up. Run this command
Code:
tvheadend -C
That will start Tvheadend with the default blank username and password

All config of Tvheadend is done through a web interface. You will need to connect to it with a web browser. On a default install of Raspbmc you can type http://raspbmc:9981 in the address bar of a computer on the same network, otherwise you will need to know the IP address of the Pi and can enter http://<IP of Pi>:9981 when it asks for a username and password just click ok.
Now setup a real username and pass, use the tabs and go to 'Configuration' -> 'Access Control' then edit the default blank user. double click on a field to edit it, chose a username and password and click 'Save Changes'.
Next click on 'General' and enter /usr/share/dvb into the 'DVB scan files path:'. You can now go to the 'TV Adapters' tab and setup your tuners.
Select your tuner from the dropdown box. Then click 'Add DVB Network by location' and select you location. This will add the mux details from a database. Check Idle scanning and click save.
Now wait for Tvheadend to finish it's initial scan ('Muxes awaiting initial scan' will have 0 beneath it when done).
Once complete click 'Map DVB Services to channels'. This can take a little while but channels will start appearing under the 'channels' tab.
You will need to repeat this for any additional tuners.

You will also need a PVR build of XBMC. This is available in the Raspbmc Settings menu as a nightly build. Once installed you will need to go to the settings menu and under 'Live TV' select 'Enable'. This will prompt you to pick a PVR plugin. Select 'Tvheadend HTSP Client', then select 'configure', enter the username and password that you set for Tvheadend and click 'ok'. Next Click 'Enable'.

That's it! You should now be able to watch live TV on your Pi.


Kernel headers & older kernels are available here: http://landspike.com/Raspbmc/


Troubleshooting
------------------
If you are in the UK and having trouble with tuning channels on freeview it may be that the mux database used by tvheadend is out of date. You can get details of the muxes to add manually from ukfree.tv, or post here with the name of the transmitter you are on and I'll try make a guide for you.

If you can't find details of the muxes for your area you can do a full scan with a tool called w_scan. Info here: http://wirbel.htpc-forum.de/w_scan/index_en.html
w_scan is available in the raspbian repositories, run:
Code:
sudo apt-get install w-scan

IT9135 ver 2 Devices
I am currently working on building updated drivers for these devices, I'll update when I have more info.


Streaming to other devices on the network
-------------------------------------------
To stream to another Pi install Raspbmc and a PVR build of XBMC from the Raspbmc Settings menu. Again go to the settings menu and under 'Live TV' select 'Enable'. This will prompt you to pick a PVR plugin. Select 'Tvheadend HTSP Client', then select 'configure', enter the username and password that you set for Tvheadend and enter the IP address of the Pi with the tuner(s) and then click 'ok'. Next Click 'Enable'.

To stream to PC I use XBMC PVR avalible here:http://xbmc.opdenkamp.eu/ or here:http://www.scintilla.utwente.nl/~marcelg...build.html
use the 'Tvheadend HTSP Client', then select 'configure', enter the username and password that you set for Tvheadend and enter the IP address of your Pi.

To stream to my Android devices I use TVHGuide and BSPlayer. Both are available free in the play store. And are simple to use. In TVHGuide go to settings the enter the IP of your Pi under hostname and enter your Tvheadend username and password under username and password.


Feel free to ask questions, I'll try to answer asap.
--
7/9/12 - Updated guide
9/9/12 - Minor update
10/9/12 - Added w_scan info and Android and PC playback info
13/9/12 - Updated with new info gained from my experiences running all this and helping others with it.
16/9/12 - New kernel
20/9/12 - Updated guide, fixed some spelling errors.
Find all posts by this user
Quote this message in a reply
09-06-2012, 10:44 PM
Post: #2
RE: Live TV on Pi with Tvheadend (all running on one Pi)
Hello mate, with regards to the get_dvb_firmware. did you find and download that script after you built and installed the Kernel? i.e. run the script on the RPi. Also when you built the kernel by downloading and running the sh file. what files did you copy to your RPi? I don't know if I should copy all the files from the following locations (as listed in the wiki page):

/opt/vc
boot partition components, such as start.elf and bootcode.bin.
kernel modules (/usr/lib/)
and of course, the kernel itself
Find all posts by this user
Quote this message in a reply
09-06-2012, 10:55 PM
Post: #3
RE: Live TV on Pi with Tvheadend (all running on one Pi)
I ran get_dvb_firmware on the pi just after installing the new kernel.
For the kernel the sh file takes a long time to run but at the end it gives you 2 .tar.gz files. Copy kernel-rootfs-latest-hardfp.tar.gz to the root of the sd card and kernel-vfat-latest-hardfp.tar.gz to /boot then run
Code:
cd /
sudo tar -xzf kernel-rootfs-latest-hardfp.tar
cd /boot
sudo tar -xzf kernel-vfat-latest-hardfp.tar
That will set you up with the new kernel and new firmware.

If you don't want to wait for the kernel to build I've uploaded the .tar.gz files (as well as get_dvb_firmware) to my webhost http://landspike.com/Raspbmc/
Find all posts by this user
Quote this message in a reply
09-07-2012, 09:52 AM
Post: #4
RE: Live TV on Pi with Tvheadend (all running on one Pi)
Thank you very much indeed. Can't wait to get home and try that this evening. I had a feeling it would be possible to do XBMC and tvheadend on the RPi.
Find all posts by this user
Quote this message in a reply
09-07-2012, 10:38 AM
Post: #5
RE: Live TV on Pi with Tvheadend (all running on one Pi)
Hi,

this link might help others as well: https://www.lonelycoder.com/redmine/issues/1018
Find all posts by this user
Quote this message in a reply
09-07-2012, 05:28 PM (This post was last modified: 09-07-2012 05:48 PM by thecrater.)
Post: #6
RE: Live TV on Pi with Tvheadend (all running on one Pi)
Just tried running your get_dvb_firmware.sh and got the following:

get_dvb_firmware.sh: 21: get_dvb_firmware.sh: use: not found
get_dvb_firmware.sh: 22: get_dvb_firmware.sh: use: not found
get_dvb_firmware.sh: 24: get_dvb_firmware.sh: Syntax error: "(" unexpected

Sorry I assumed it was an sh file

For those who, like me, don't know:

copy the file over to your RPi
find out the actual chipset used in your device
you may also need to install unzip by running
apt-get install unzip

call the file using:
perl get_dvb_firmware xxx (xxx being your chipset) for example "perl get_dvb_firmware.txt af9015"

Let it download the fw file(s)

Follow the instructions when the script finishes to
"either /usr/lib/hotplug/firmware or /lib/firmware"

Reboot
Find all posts by this user
Quote this message in a reply
09-07-2012, 07:51 PM
Post: #7
RE: Live TV on Pi with Tvheadend (all running on one Pi)
yeah, sorry. get_dvb_firmware is a perl script. I'll go into more detail about it and how to use it when I post the full guide later tonight.
and on the pi the firmware files need to go in /lib/firmware
Find all posts by this user
Quote this message in a reply
09-07-2012, 09:01 PM
Post: #8
RE: Live TV on Pi with Tvheadend (all running on one Pi)
Nice work! Been waiting in a post like this!
I've got a question about get_dvb_firmware though. Doest it only work with the chipsets listed at the @compenents part of the script? Or should it work with others too? I want to know if the TechnoTrend TT-Connect CT-3650 will work, because I need dvb-c decoding, and this one seems to be compatible Linux.
Find all posts by this user
Quote this message in a reply
09-07-2012, 09:10 PM (This post was last modified: 09-07-2012 09:17 PM by Quonith.)
Post: #9
RE: Live TV on Pi with Tvheadend (all running on one Pi)
I've updated the first post with some more info and what i have written of my guide so far. Will update again later.

@gekkegerrit101 - as far as I know it only works with tuners with the chipsets listed in the @compenents section. That tuner may not even require firmware. Looking on the linuxtv.org wiki (HERE) it doesn't look like it does.
Find all posts by this user
Quote this message in a reply
09-07-2012, 10:10 PM
Post: #10
RE: Live TV on Pi with Tvheadend (all running on one Pi)
Are there any special instructions for using an HDHomeRun with this set up? I'm assuming there is no firmware that needs to be updated (on the RasPi's end anyway).
Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 3 Guest(s)

Sponsored Advertisement