In order to make this possible you need the program youtube-dl. In the beginning this program was only made for Youtube, hence the name. But today it has grown to support hundreds of sites, and Twitch is one of them.
There are several ways to install
- From your package manager, this version might be outdated.
- System-wide by placing the script in
/usr/local/bin, requires root.
- As a user by placing the script in
I will install it as a user.
youtube-dl and place it in
cd ~/bin wget https://yt-dl.org/downloads/latest/youtube-dl chmod +x youtube-dl
~/bin is in your PATH environment variable:
echo "$PATH" | grep -o "$HOME/bin"
If you get zero output, then add
echo 'PATH="$HOME/bin:$PATH"' >> ~/.profile source ~/.profile
Make sure your
youtube-dl is up-to-date:
Watch a stream in mpv:
Watch a stream in vlc:
youtube-dl -o - "twitch.tv/stream" | vlc -
If you need to login to watch a stream, add the following to
~/.netrc, replacing USERNAME and PASSWORD respectively:
machine twitch login USERNAME password PASSWORD
Make sure the permissions on
~/.netrc is properly set:
chmod 600 ~/.netrc
Then add the parameter as follows:
mpv --ytdl-raw-options=netrc "twitch.tv/stream"