Jump to content

HOW TO - Watch Youtube Live/Twitch streams on Emby with TVHeadend


Facy5

Recommended Posts

Hello everyone !

Seeing a lot of people want to add Youtube Live channels in their IPTV section, and knowing you can't simply add a Youtube Live stream link in your .m3u because YTLive links change every 3 to 6h (unless you want to edit your playlist and refresh Emby everytime, which would be a nightmare), this is a (quiet long) tutorial to show you how to make Youtube Live (but also Twitch or Dailymotion) streams work like a real TV channel in Emby.

I based this how to on my own knwoledge (basically none in Linux, a lot of trial and error), and the tutorial by Carlos Gomes, available here : https://cgomesu.com/blog/Tvhlink/ 
All the tutorial is setup on a Windows 10 machine.

You will need :

- a Windows 10 (build 19041 and higher) or Windows 11 machine
- Windows subsystem for Linux (can be version 1) - WSL to make short
- a Linux distribution of your choice (preferably Debian or Ubuntu)
- TVHeadend
- Streamink
- the TVHeadend plugin from the Emby plugin store

 

1) Install Windows subsystem for Linux.

For  Windows 10 below build 19041 :
Open Powershell in admin mode, copy/past these commands :

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

The Linux distributions available are : Ubuntu, Debian, kali-linux, Ubuntu-18.04, Ubuntu-20.04, Ubuntu-22.04, OracleLinux_8_5, OracleLinux_7_9, SUSE-Linux-Enterprise-Server-15-SP4, openSUSE-Leap-15.4 , or openSUSE-Tumbleweed.

Then, still in the Powershell, download your distribution of your choice :

To install Ubuntu 22.04 :

curl.exe -L -o ubuntu.appx https://aka.ms/wslubuntu2204

For Debian :

curl.exe -L -o debian.appx https://aka.ms/wsl-debian-gnulinux

Then restart the computer.

Optional :
If you want to install WSL 2, check this link by Microsoft : https://learn.microsoft.com/en-us/windows/wsl/install-manual#step-4---download-the-linux-kernel-update-package

 

For Windows 10 build 19041 and higher :
In the Command Prompt (or in Windows Terminal, available in the Windows Store) in admin mode, with WSL 2 already installed : (without the < > )

wsl --install -d <Distribution Name>

 

For Ubuntu 22.04 :

wsl --install -d Ubuntu-22.04

or, for Debian :

wsl --install -d Debian

Then restart the computer.

 

2) Install TVHeadend

Go to the download page : https://tvheadend.org/projects/tvheadend/wiki/AptRepositories


For Ubuntu, the easy way is to install via PPA :

sudo apt-add-repository ppa:mamarley/tvheadend-git
sudo apt update
sudo apt install tvheadend

 

For Debian, because the distribution can't handle PPA, to have to do this :

curl -1sLf \
  'https://dl.cloudsmith.io/public/tvheadend/tvheadend/setup.deb.sh' \
  | sudo -E bash

Then after, the usual :

sudo apt update
sudo apt install tvheadend


Once TVHeadend, and all its dependancies, donwloaded and installed, the install wizard will automatically be launched. You just have to create an admin ID and a password, leave the rest by default.

 

3) Install Streamlink

! For Debian, make sure you have backports repositories installed, otherwise you will get an older version of Streamlink and cause Python errors in TVHeadend ! 

 

echo "deb http://deb.debian.org/debian bullseye-backports main" | sudo tee "/etc/apt/sources.list.d/streamlink.list"

sudo apt update
sudo apt -t bullseye-backports install streamlink

 

4) Start the TVHeadend server :

sudo tvheadend

Wait a little, untill you see this line in blue (of course, the number version could vary with future update) :

 [ NOTICE] START: HTS Tvheadend version 4.3-2106~g9e1eb89be started

Go to the webserver page of TVHeadend : http://localhost:9981/ 

Warning ! If after entered your admin ID, the page show you a 403 Forbidden error, type :

sudo tvheadend -C

It will show you the post install wizard to configure admin ID's (keep the same as the install) and a client ID (you can just keep the same ID as the admin account).

Now :
a) set up TVHeadend -> https://cgomesu.com/blog/Tvhlink/#basic-configuration
b) create an automatically updated .m3u with Youtube Live/Twitch ... -> https://cgomesu.com/blog/Tvhlink/#automatic-network-of-livestream-channels


If you create your .m3u from Windows (with Notepad ++ for exemple), I strongly suggest you to save it in your Linux home folder.
Once done, you need to modify the permission of your .m3u, otherwise TVHeadend won't have the permission to handle it. To do so :

cd path/of/your/playlist/
chmod +rwx yourplaylist.m3u

 

Basically, your .m3u shoud look like this :

#EXTM3U
#EXTINF:-1 tvg-id="ChannelID.ShortCountryCode" tvg-country="ShortCountryCode",Name of the channel
pipe:///usr/bin/env streamlink --stdout --default-stream best --url https://www.youtube.com/user/ChannelName/live

 

5) Install the TVHeadend plugin

You can find it in the Emby plugin store, in the Live TV category. Once installed, restart your Emby server.

Then, in the admin pannel, in the Live TV section :
Add a new TV source -> select TVHeadend

If you installed the TVHeadend server on the same computer of the Emby server, change the Tvheadend Server Web Interface URL with : http://127.0.0.1:9981 instead of http://localhost:9981
If you installed on another computer of your network, enter its local IP adress, and the port number : 9981

Enter admin ID and password -> Save

Refresh data guide.

Now Emby can play Youtube Live/Twitch/Dailymotion (and many others) livestreams !

(If I have some time, I could edit this post with pictures. if I misspelled or misspoke something, please forgive me, English isn't my mother tongue.)

Edited by Facy5
  • Thanks 1
Link to comment
Share on other sites

  • 5 months later...
Bingie

Hi @Facy5

Thanks for this write-up!

It's that time of year again (NFL season) and for this year, I'm thinking of trying youtube live tv, and add it to emby.

I was going to try tvheadend last year, but the homepage gave me the distinct impression it's abandonware (the comment about the author too busy to work on it), so I tried channels dvr instead, and although channels is interesting, I found it lacking and eventually stopped using it.

I think I'll try tvheadend with emby.  Your linux commands look pretty straight forward (I'm old school debian guy).  I'm no fan of running linux on windows, so I'll fire up a spare mini-pc running the latest debian server.  Shouldn't be too hard.

Cheers

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...