# Tvheadend server



## balanga (Oct 25, 2017)

Is there any way to set up a tvheadend server on a box with a dvb-s2 interface? Am I correct in thinking that tvheadend incorporates a web gui for configuration purposes?


----------



## tingo (Oct 25, 2017)

Not sure about dvb-s2 support. Yes, tvheadend has a web gui, you also do configuration there.


----------



## Phishfry (Oct 30, 2017)

Well I finally got somewhere with a FreeBSD tuner and cx88 driver/port on DVICO Fusion HDTV7 dual express

```
root@TV:~ # w_scan -c US
w_scan -c US
w_scan version 20170107 (compiled for DVB API 5.10)
using settings for UNITED STATES
ATSC
VSB US/CA, DVB-T TW
scan type TERRCABLE_ATSC, channellist 1
output format vdr-2.0
WARNING: could not guess your codepage. Falling back to 'UTF-8'
output charset 'UTF-8', use -C <charset> to override
Info: using DVB adapter auto detection.
   /dev/dvb/adapter0/frontend0 -> TERRCABLE_ATSC "Fusion 7 Dual Express tuner #2": good :-)
   /dev/dvb/adapter1/frontend0 -> TERRCABLE_ATSC "Fusion 7 Dual Express tuner #1": good :-)
Using TERRCABLE_ATSC frontend (adapter /dev/dvb/adapter0/frontend0)
-_-_-_-_ Getting frontend capabilities-_-_-_-_
Using DVB API 5.5
frontend 'Fusion 7 Dual Express tuner #2' supports
INVERSION_AUTO
8VSB
QAM_64
QAM_256
FREQ (54.00MHz ... 890.00MHz)
-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
57000: 8VSB(time: 00:00.122)
63000: 8VSB(time: 00:03.167)
69000: 8VSB(time: 00:06.196)
79000: 8VSB(time: 00:09.223)
85000: 8VSB(time: 00:12.231)
[SNIP]
tune to: 8VSB     f=575000 kHz (0:0:0) (time: 03:36.806)
service is running. Channel number: 10:1. Name: 'WAVY'
service is running. Channel number: 10:2. Name: 'Bounce'
service is running. Channel number: 10:3. Name: 'GET-TV'
tune to: 8VSB     f=581000 kHz (0:0:0) (time: 03:38.909)
        Info: no data from PAT after 2 seconds
        Info: no data from VCT(terr) after 6 seconds
tune to: 8VSB     f=587000 kHz (0:0:0) (time: 03:45.811)
WARNING: received garbage data: crc = 0xb4bba7a6; expected crc = 0x26c0ecd7
increasing filter timeout to 35 secs (pid:8187 table_id:200 table_id_ext:-1).
WARNING: received garbage data: crc = 0x5bcb7400; expected crc = 0xd11178f7
increasing filter timeout to 31 secs (pid:64 table_id:2 table_id_ext:-1).
service is running. Channel number: 33:1. Name: 'WTVZ-HD'
service is running. Channel number: 33:2. Name: 'ASN'
service is running. Channel number: 33:3. Name: 'Comet'
service is running. Channel number: 33:4. Name: 'TBD-TV'
tune to: 8VSB     f=593000 kHz (0:0:0) (time: 03:48.182)
        Info: no data from PAT after 2 seconds
        Info: no data from VCT(terr) after 6 seconds
(time: 03:54.879) dumping lists (16 services)
..
WVEC-HD;(null):213000:M10:A:0:49:52=eng,53=spa;52,53:0:0:1:0:0:0
WVEC-JN;(null):213000:M10:A:0:65:68=eng;68:0:0:2:0:0:0
WVEC-Me;(null):213000:M10:A:0:81:84=eng;84:0:0:3:0:0:0
WHRO-HD;(null):485000:M10:A:0:49:52=eng;52:0:0:3:0:0:0
World;(null):485000:M10:A:0:65:68=eng;68:0:0:4:0:0:0
Kids;(null):485000:M10:A:0:97:100=eng;100:0:0:6:0:0:0
Create;(null):485000:M10:A:0:81:84=eng;84:0:0:5:0:0:0

;(null):539000:M10:A:0:49:52,55,56;52,55,56:0:0:1:0:0:0
WVBT;(null):563000:M10:A:0:49:52=eng,53=spa;52,53:0:0:3:0:0:0
WAVY;(null):575000:M10:A:0:49:52=eng,53=spa;52,53:0:0:3:0:0:0
Bounce;(null):575000:M10:A:0:65:68=eng;68:0:0:4:0:0:0
GET-TV;(null):575000:M10:A:0:81:84=eng;84:0:0:5:0:0:0
WTVZ-HD;(null):587000:M10:A:0:49=2:52=eng;52:0:0:3:0:0:0
ASN;(null):587000:M10:A:0:65:68=eng;68:0:0:4:0:0:0
Comet;(null):587000:M10:A:0:81:84=eng;84:0:0:5:0:0:0
TBD-TV;(null):587000:M10:A:0:97:100=eng;100:0:0:6:0:0:0
Done, scan time: 03:54.879
```
So now its time for tvheadend to see what works.
Trying to build an APU2 headless tvheadend server.
I had to do some twisted things for tuner firmware.(Which I found nowhere online)
hint=It uses this directory for firmware: /usr/local/share/libtuner/
I will write it up when I redo this setup on APU2


----------



## Phishfry (Oct 30, 2017)

Shoot i spent 2 hours trying to find the tvheadend web frontend username and password.
Turns out you need to start tvheadend with the -C option flag on the first run.
This allows the configure screen to come up and you can make your user then.


----------



## Phishfry (Oct 30, 2017)

VICTORY!!!!!!!!!!!!!!!!!


----------



## balanga (Oct 30, 2017)

Did you need to make any changes to multimedia/tvheadend to make it work? I seem to recall that it wouldn't compile straight out of the box...


----------



## PacketMan (Oct 30, 2017)

It installed fine for me, in fact I have never had an issue getting this to go. Will be nice to see someone getting a tuner card to work. Would be nice to see some tuner card manufactures releasing native FreeBSD code/drivers to get put into the ports tree system.


----------



## balanga (Oct 30, 2017)

Were you able to use `pkg install tvheadend` or did you need to build from ports?


----------



## PacketMan (Oct 30, 2017)

I did a `make config` and modify the options (turned on HDHomeRun support), and then used ports-mgmt/synth. I didn't watch the screen but yeah pretty sure Synth compiled it (into its own pkg), since I modified options thus can't use stock pkg from repository.


----------



## Phishfry (Oct 30, 2017)

balanga said:


> Did you need to make any changes to multimedia/tvheadend to make it work?


No I installed from packages.



tingo said:


> Yes, tvheadend has a web gui, you also do configuration there.


I am not arguing this point but realistically if it don't work with w_scan it will not work with the GUI.

Figuring out the proper firmware location was the hardest part.
Also the cx88 Wiki is down so I had to use the wayback machine and google cache.

So for ATSC with cx88 driver there are 3 models that work. Hauppauge HVR-1800, HVR-1850 and Fusion HDTV7 Dual Express.
I could only get the latter working as my HVR-1800 was giving me trouble.


----------



## tingo (Oct 30, 2017)

Phishfry said:


> I am not arguing this point but realistically if it don't work with w_scan it will not work with the GUI.


True, and a good point to keep in mind.


----------



## Phishfry (Oct 31, 2017)

I got my Hauppauge HVR-1800 working tonight.
I only have a small telescoping antenna right now. Here is tvheadend on FreeBSD and my Over-the-Air EPG.


----------



## balanga (Oct 31, 2017)

I have an HP ExpressCard DVB-T TV Tuner which FreeBSD identifies as <Digital TV Yuan> and `usbconfig` shows as


> ugen1.4 <Digital TV Yuan> at usbus1


.

Do I need to do anything within FreeBSD to try and make it work with tvheadend or should tvheadend automatically pick it up?


----------



## PacketMan (Oct 31, 2017)

Phishfry said:


> I got my Hauppauge HVR-1800 working tonight.
> I only have a small telescoping antenna right now. Here is tvheadend on FreeBSD and my Over-the-Air EPG.
> View attachment 4090



Sweet.  Did you have to do any secret saucing to get that card to work, or does it work out of the box as is?  I wonder how some of their newer cards work with FreeBSD?


----------



## balanga (Oct 31, 2017)

I just ran `pkg install tvheadend` but got a number of errors trying to install it:-

```
Creating user 'tvheadend' with uid '984'
pw: user 'tvheadend' disappeared during update
install: unknown user 'tvheadend'
pkg: PRE-INSTALL script failed

# tvheadend
tvheadend: Command not found.
```

I'm running FreeBSD 11.0-RELEASE-p8 i386

What have I overlooked?


----------



## Phishfry (Oct 31, 2017)

balanga said:


> Do I need to do anything within FreeBSD to try and make it work with tvheadend or should tvheadend automatically pick it up?


Yes you need to setup webcamd.
Let me reiterate. tvheadend does nothing to help you. Forget it exists. First you must get the device recognized by FreeBSD.
This includes the /dev/dvb node which is created by the driver subsystem when all is right.
That was why I recommend you get it where `w_scan` can scan the tuner. It is the best indicator of correct setup including the proper firmware.
Then worry about apps like tvheadend. It is just a fluffy frontend to v4l devices. It will configure nothing.

I suggest you start at Linux since FreeBSD is using the v4l stack. Figure out the deets there and work back.
I say that because all the firmware stuff comes from the LinuxTV project.



PacketMan said:


> Sweet. Did you have to do any secret saucing to get that card to work, or does it work out of the box as is? I wonder how some of their newer cards work with FreeBSD?


I can only speak to cx88 devices. It seems their list is quite accurate and all the listed cards actually work.
The author of cx88 is a nice guy and kicked the wiki to get it back up so there is loads of info there.

https://gist.github.com/dreamcat4/d28a6daf78b1ad2ec663
This gives a quick summary of what is needed to load. I did not use kldload like that but used loader.conf instead.

```
cuse_load="YES"
cx23885_load="YES"
cx23885avfw_load="YES"
```
rc.conf

```
cx88d_enable="YES"
```
My pkg command:
`pkg install cx88 w_scan v4l_compat libv4l`


----------



## Phishfry (Oct 31, 2017)

I moved over to the APU3 i want to use for this.

```
root@TV:~ # kldload cuse
root@TV:~ # kldload cx23885
root@TV:~ # kldload cx23885avfw
root@TV:~ # service cx88d start
Starting cx88d.
root@TV:~ # cx88
[cx88 2017-10-31 17:57:45] Error: You must specify a device (-d); Available devices:
Digital video:
   /dev/cx88mpeg0: WinTV HVR-1800
Analog video:
   (No devices found)
Analog audio:
   /dev/cx88audio0: WinTV HVR-1800
   /dev/cx88audio1: WinTV HVR-1800
root@TV:~ # ls /dev/dvb
adapter0
root@TV:~ # ls /dev/dvb/adapter0
demux0       dvr0       frontend0
```

Note: There is no firmware needed for cx88. I am still learning.....


----------



## Phishfry (Oct 31, 2017)

The cx88 driver provides its own interface.

```
root@TV:~ # cx88 -d /dev/cx88mpeg0
Welcome to the cx88 capture app.  Enter '?' for a list of commands.
> i
Driver stopped.
Channel: fox
   No signal
Device:
   /dev/cx88mpeg0 (WinTV HVR-1800)
Input source:
   Primary

> h
[cx88 2017-10-31 18:03:39] Driver started.
> [libtuner 2017-10-31 18:03:40] CX24227: demodulator not locked
[cx88 2017-10-31 18:03:40] Error starting frontend device

> s
Scanning profile USA . . . . . . . . . . . . . . 16 (87.013%) . . . . . . . . . . . . . . 31 (79.7619%) . 33 (84.9567%) . . . . . . 40 (86.9048%) . . . . . 46 (75.6494%) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Finished scan.
> [libtuner 2017-10-31 18:06:46] CX24227: demodulator not locked
[cx88 2017-10-31 18:06:46] Error starting frontend device
h
[cx88 2017-10-31 18:06:53] Driver stopped.
> h
[cx88 2017-10-31 18:06:56] Driver started.
> [libtuner 2017-10-31 18:06:57] CX24227: demodulator not locked
[cx88 2017-10-31 18:06:57] Error starting frontend device
?
Interactive commands:
--------------------------------------------------
c <channel> [<timeout>]       Change channel, optionally specifying lock timeout in ms
s [<strength%> [<timeout>]]   Scan for channels with at least the specified signal strength (0-100)
i                             Get current tuning information
h                             Toggle start/stop of all captures
+ <URL> [<minutes>]           Add a capture using the specified URL, with an optional time limit
- <number>                    Remove capture by index (use 'i' to get indexed capture list)
r [<minutes>]                 Toggle start/stop of recording to default recording file
n [<source>]                  Change the active input source, or list available sources
p [<port>]                    Set remote control port (0 => auto), or display list of remote connections
p-                            Disable remote control
t [<minutes>]                 Set program timer (0 => disable), or display remaining time
t <minutes> <capture #>       Set the timer for the given capture number (0 => disable)
ver                           Display version
q                             Quit app(interactive), or close session(remote)
q!                            Quit app(both interactive and remote)
b                             Toggle between backend and normal capture modes
psi                           Enable/disable MPEG stream parsing
cx88_mpeg_capture <json>      Display/modify the capture ioctl params sent to the driver (use with caution!)
cx88_mpeg_config <json>       Display/modify the buffer configuration params sent to the driver (use with caution!)

Capture URLs:
--------------------------------------------------
file://                       Append to file (e.g. file:///home/user/capture.m2t)
oss://                        Output to OSS audio device (e.g. oss:///dev/dsp0)
tcp://                        Output to TCP client socket (e.g. tcp://localhost:8802)
udp://                        Output to UDP port (e.g. udp://localhost:8802)
dvb://                        Create Linux DVB device nodes (e.g. dvb://adapter0)
radio://                      Create Linux V4L2 radio device nodes (e.g. radio://radio0)
rec://                        Overwrite file (e.g. rec:///home/user/capture.m2t)

>
```


----------



## Phishfry (Oct 31, 2017)

tvheadend setup on the APU3. Glad to see it is working well. Still need to try recording video and scheduling. Also LiveTV does not work right.


----------



## balanga (Oct 31, 2017)

Seems that my HP ExpressCard DVB-T TV Tuner aka Yuan Digital TV doesn't show up in any lists... although I also have an ITE Technologies USB device which is mentioned here:- https://wiki.freebsd.org/WebcamCompat which


> Requires firmware dvb-usb-it9135-01.fw; dual tuner, second tuner now tested and seems to be working, remote not working...



Not sure how to proceed.... I ran `pkg install  w_scan`

`w_scan -c GB`:-


> ..
> main:4007: FATAL: ***** NO USEABLE TERRESTRIAL CARD FOUND.  *****
> Please check wether dvb driver is loaded and
> verify that no dvb  application (i.e. vdr) is running.



Do I need anything in loader.conf or rc.conf


----------



## Phishfry (Nov 1, 2017)

https://forums.freebsd.org/threads/35179/


Phishfry said:


> That was why I recommend you get it where  w_scan can scan the tuner. It is the best indicator of correct setup including the proper firmware.


So what this means is you must get your device loaded correctly with webcamd before w_scan.
If you device is not listed on LinuxTV then I doubt it will work.


----------



## balanga (Dec 18, 2017)

Phishfry said:


> https://forums.freebsd.org/threads/35179/
> 
> So what this means is you must get your device loaded correctly with webcamd before w_scan.
> If you device is not listed on LinuxTV then I doubt it will work.



After much experimenting I have found a webcamd which works with my card....

It wouldn't work with the *PKG *but building from ports created something which recognised my device. The ports version built 4.8.0.4 whereas the PKG  version is 4.12.0.1.  I'm not sure how this happened... maybe I had an out of date ports tree....


----------



## balanga (Dec 20, 2017)

Useful notes for TVheadend


----------



## balanga (Dec 22, 2017)

/etc/rc.conf contains:

```
webcamd_enable="YES"

tvheadend_enable="YES"
tvheadend_flags="--noacl -l"
```

When booting, the system starts up tvheadend during the boot process with tvheadend in foreground and stays there not allowing other processes such as sshd or login to start.

What to do?


----------



## balanga (Dec 22, 2017)

```
-f     Fork and become a background process (daemon). Default is no
```

????


----------



## Donald Baud (Jan 5, 2018)

Could anyone please confirm if you are able to stream LiveTV from an IPTV stream on multimedia/tvheadend?

Ways to repeat this issue:
- Setup a network and Mux, and notice that you can't play IPTV stream
=======
Configuration -> DVB Inputs -> Networks -> Add
network name: ABCdirect

Configuration -> DVB Inputs -> Mux -> Add
url: http://abclive.abcnews.com/i/abc_live4@136330/index_1200_av-b.m3u8?sd=10&b=1200&rebase=on
mux name: abc-news
service name: abc-news

press the little Play logo
error: VLC or html5 browser unable to play
=======

The same setup works fine on ubuntu


----------



## PacketMan (Jan 5, 2018)

Donald Baud said:


> Could anyone please confirm if you are able to stream LiveTV from an IPTV stream on multimedia/tvheadend?



I had it working last year but don't remember much about it.  IPTV streams on the Internet would go to TVHeadend, and then VLC would play those streams.  I gave up on it because the only streams I could find were ones that only played for 15 seconds.


----------



## balanga (Jan 5, 2018)

Donald Baud said:


> Could anyone please confirm if you are able to stream LiveTV from an IPTV stream on multimedia/tvheadend?
> 
> Ways to repeat this issue:
> - Setup a network and Mux, and notice that you can't play IPTV stream
> ...



I've never used IPTV streams, but tried to follow your instructions, although I may have got something wrong....

When the mouse cursor is above the Play logo, the url shown is

```
192.168.1.2:9981/play/stream/service/74e466ca6f18ac1506afcf3e8f63ec85?title=abc-news
```
when I click on a file is downloaded with the long filename above with an m3u extension.
When I try to launch `vlc` with this file an error msg pops up saying your input can't be opened

```
VLC is unable to open the MRL
'http://192.168.1.2:9981/play/stream/service/74e466ca6f18ac1506afcf3e8f63ec85?ticket=99D1c1..........'.Check the log for details.
```

This is on Windows 10.

I'd love to see this working so that I can access IPTV stream via TVheadend.


----------



## balanga (Feb 27, 2018)

Just got my DVB-S2 USB adapter and hope to add it to my TVheadend server... 

Has anyone managed to get this working?


----------



## PacketMan (Feb 28, 2018)

Give it a try and see where that takes you.


----------



## balanga (Feb 28, 2018)

Running `w_scan -f s -c GB -s S13E0`

returned 

***** NO USEABLE SATELLITE CARD FOUND.  *****


----------



## balanga (Mar 1, 2018)

Not sure if I need an em28xx driver...

https://www.linuxtv.org/wiki/index.php/Em28xx_devices

It is mentioned here for a PCTV DVB-S2 Stick 460e 

https://wiki.freebsd.org/WebcamCompat

but no mention as to what it is or where to get it.


----------



## Phishfry (Mar 1, 2018)

Did you notice the last part of that graph.
*"Requires webcamd >= 3.1.0.4 and tda10071 firmware dvb-fe-tda10071.fw"*


----------



## balanga (Mar 2, 2018)

Phishfry said:


> Did you notice the last part of that graph.
> *"Requires webcamd >= 3.1.0.4 and tda10071 firmware dvb-fe-tda10071.fw"*



I have webcamd 4.8.04  and the firmware file is in/boot/modules but I can't tell if it has been picked up.

Another part of the puzzle may be em28xx driver which is mentioned in the wiki but I haven't tracked it down yet....

Tvheadend works OK with this adapter using LibreELEC so I may be forced to go down that route, which would be a pity if I'm using an adapter which is supposed to work with FreeBSD.


----------

