15% discount on service renewal Renew now

0

admin Admin

Tvheadend as a home IPTV hub: networks, EPG and clients

Article

Tvheadend is a TV streaming server and recorder for Linux. In a Tvheadend IPTV setup, you load one M3U playlist into an IPTV Automatic Network, turn its streams into channels once, attach a guide, and every client in the house gets the same channel list, guide and recordings from one place. It also gives you one switch for the number of provider connections in use. This guide covers installation in Docker, the network and mux settings, service mapping, XMLTV guide data and the clients that connect to it.

It works with any IPTV subscription that provides an M3U link; the examples use http://example-server.com:8080, username and password as placeholders.

Why put Tvheadend in the middle

  • One lineup for every screen. Channel names, numbers, logos and tags are set once on the server.
  • One guide. Guide data is loaded and matched on the server, and clients receive it ready to use.
  • A connection cap. The network's Maximum # input streams setting stops Tvheadend from opening more streams than your plan allows.
  • Central recording and timeshift for clients that support them.

The trade-offs are a Linux server that stays on and a learning curve. Tvheadend models television the way broadcast hardware works: a network contains muxes, a mux carries services, and services are mapped to channels, which are what clients see. For IPTV, each playlist entry becomes its own mux. Once that clicks, the rest is routine. For a single TV, a player app is simpler.

Install with Docker

The project publishes an official image at ghcr.io/tvheadend/tvheadend. A minimal start looks like this:

docker run -d --name tvheadend --restart unless-stopped -p 9981-9982:9981-9982 -e TZ=Europe/London -v /srv/tvheadend/config:/var/lib/tvheadend -v /srv/tvheadend/recordings:/var/lib/tvheadend/recordings ghcr.io/tvheadend/tvheadend:latest

  • Port 9981 serves the web interface and HTTP streaming, and 9982 is HTSP, the protocol Kodi's client uses.
  • Configuration lives in /var/lib/tvheadend and recordings in /var/lib/tvheadend/recordings. Use host folders or named volumes, not anonymous volumes that a cleanup command can delete.
  • Set TZ to your time zone. The project's Docker notes also show how to run the container under your own user ID so files on the host keep the right owner.
  • IPTV needs no device passthrough. Map /dev/dvb only for broadcast tuners, and /dev/dri only if you plan to transcode on a GPU.

Open http://192.168.1.30:9981 (your server's address) and complete the setup wizard, which creates the administrator account.

Create the IPTV Automatic Network

  1. Go to Configuration > DVB Inputs > Networks, click Add and choose IPTV Automatic Network.
  2. Give it a Network name you'll recognize.
  3. In URL, paste the playlist: http://example-server.com:8080/get.php?username=username&password=password&type=m3u_plus&output=ts.
  4. Set Maximum # input streams to the number of connections your plan allows.
  5. Set Re-fetch period (mins) to how often the playlist should reload; once a day suits most lists.
  6. If channel names come out garbled, set Content character set to the playlist's encoding, which is UTF-8 for most playlists.
  7. Choose a starting number in Channel numbers from if the playlist has no numbers.
  8. Keep Scan after creation on, save, and watch the Muxes tab as scans complete.

Tvheadend reads several playlist attributes while it creates muxes. tvg-id becomes the stream's EPG ID, tvg-logo its icon, group-title its tags, and tvg-chno its channel number. It also understands its own attributes such as tvh-chnum, tvh-tags and tvh-epg. Addresses can start with http://, https://, rtsp://, udp://, rtp://, file:// or pipe://.

Reading the scan results

  • OK means Tvheadend opened the stream and found its services.
  • FAIL means the stream was dead, unreachable, slower than Maximum timeout (seconds), or needed headers Tvheadend didn't send.
  • Scans use connections too. With a low input stream limit, a large playlist scans slowly. Use a live-only playlist if your provider offers one; scanning thousands of film and series entries is wasted effort.

Streams Tvheadend can't open directly

For a handful of difficult streams, create a manual IPTV Network and add muxes that hand the work to FFmpeg through pipe://, for example:

pipe:///usr/bin/ffmpeg -loglevel fatal -user_agent MyPlayer -i http://example-server.com:8080/live/username/password/101.ts -c copy -f mpegts pipe:1

FFmpeg must be installed where Tvheadend runs, which means inside the container if you use Docker. The -c copy part copies the stream without re-encoding.

Map services to channels

  1. Open Configuration > DVB Inputs > Services. Each working mux has produced at least one service.
  2. Click Map services and choose Map all services, or select the ones you want and map only those.
  3. Check the result under Configuration > Channel / EPG > Channels: names, numbers, icons and tags taken from the playlist.

When the provider later adds channels, the re-fetch creates new muxes; map their services the same way.

Guide data

Tvheadend keeps the guide in an in-memory database fed by broadcast data or by XMLTV grabbers. For IPTV, XMLTV is the route, and there are two kinds of module under Configuration > Channel / EPG > EPG Grabber Modules:

  • Internal XMLTV grabbers are programs whose names start with tv_grab_, which Tvheadend finds on the system and runs on a cron schedule. A small grabber script that downloads your guide address fits here.
  • External: XMLTV opens a socket that accepts a guide pushed by your own script, such as a nightly job: curl -s "http://example-server.com:8080/xmltv.php?username=username&password=password" | socat - UNIX-CONNECT:/srv/tvheadend/config/epggrab/xmltv.sock.

Next, link guide channels to Tvheadend channels. Because each stream already carries its tvg-id as an EPG ID, many links are made automatically. The rest can be set in EPG Grabber Channels, or in the EPG source field of a channel. Programs then appear in the Electronic Program Guide tab and in every client. If times are off, check TZ first, then the offsets in the guide; the XMLTV troubleshooting article in the Setup and help section goes through both.

Connect your clients

  • Users: under Configuration > Users, create an access entry and a password for your clients with streaming rights, and recording rights if they should record. Keep the administrator account for administration.
  • Kodi: install the Tvheadend HTSP Client from Kodi's repository and enter the server address, HTSP port 9982 and the client user. Kodi then gets channels, the guide, timeshift and recordings from Tvheadend.
  • Jellyfin: use the Tvheadend plugin if a build exists for your Jellyfin version, or add an M3U tuner pointed at http://192.168.1.30:9981/playlist/channels.m3u and an XMLTV provider pointed at http://192.168.1.30:9981/xmltv/channels. With this second method, Jellyfin schedules and stores recordings itself, while Tvheadend still supplies the streams and the guide.
  • VLC, mpv and other players: the same playlist address works, signed in with the client user.
  • Plex: Plex needs an HDHomeRun-style tuner, so feed Tvheadend's playlist and guide into Threadfin; the Plex article in this section covers that part.

Timeshift, recording and stream profiles

Server-side timeshift, which lets clients pause and rewind live channels, is configured under Configuration > Recording > Timeshift; give it a size limit and a disk with room. Recording profiles live under Configuration > Recording, and the recording discussions in the community cover them in more depth. The default pass stream profile sends the MPEG-TS stream through unchanged, which costs the server almost nothing; transcoding profiles need a build with transcoding support and real CPU or GPU power.

If it doesn't work

  • Most muxes fail: the playlist address or login is wrong, or the provider requires a user agent. Test one stream address in VLC from the server's network, then try the pipe:// method with a user agent.
  • Channels exist but clients get no picture: all input streams are in use, the client user lacks streaming rights, or the stream format needs a different profile.
  • The provider reports too many connections: lower Maximum # input streams and stop scans running while people watch.
  • The guide is empty: no grabber is enabled, the grabber hasn't run yet, or guide channels aren't linked.

If you'd rather start with a single player app before building a server, our VLC guide is the quickest way to check that your playlist works on a computer.

Sources and further reading

0 replies

0 replies

Log in with the account you ordered with to reply and vote.Log in
Chat on WhatsApp