21 stable releases
1.3.12 | Oct 9, 2024 |
---|---|
1.3.8 | Jun 26, 2024 |
1.3.6 | Mar 16, 2024 |
0.4.3 |
|
#22 in Video
23 downloads per month
77KB
2K
SLoC
twitch-hls-client
twitch-hls-client
is a minimal command line client for watching/recording Twitch streams
Features
- Playback of low latency and normal latency streams
- Ad blocking with playlist proxies or with a turbo/subscriber token
- Generally lower latency than the Twitch web player
- Tiny (at most uses 3-4MB of memory depending on platform)
Usage
Watching
Provide a player to output the stream to with -p
, a channel to watch, and a stream quality.
Example:
$ twitch-hls-client -p mpv twitchchannel best
Fetching playlist for channel twitchchannel
Low latency streaming
Opening player: mpv -
(+) Video --vid=1 (h264)
(+) Audio --aid=1 (aac)
Using hardware decoding (vaapi).
VO: [gpu] 1920x1080 vaapi[nv12]
AO: [pipewire] 48000Hz stereo 2ch floatp
AV: 03:57:23 / 03:57:23 (100%) A-V: 0.000 Cache: 0.7s/482KB
Recording
Provide a file path to output the stream to with -r
, a channel to watch, and a stream quality.
Example:
$ twitch-hls-client -r recording.mp4 twitchchannel best
Fetching playlist for channel twitchchannel
Low latency streaming
Recording to: recording.mp4
You can also use -p
and -r
at the same time.
That is the bare minimum, but there are many more options which can be viewed here or by passing --help
.
Ad blocking playlist proxies
These servers can be used to block ads with -s
. They work by requesting the master playlist from a country where Twitch doesn't serve ads:
TTV-LOL-PRO v1 servers:
https://lb-eu.cdn-perfprod.com/live/[channel]
(Europe)https://lb-eu2.cdn-perfprod.com/live/[channel]
(Europe 2)https://lb-eu4.cdn-perfprod.com/live/[channel]
(Europe 4)https://lb-eu5.cdn-perfprod.com/live/[channel]
(Europe 5)https://lb-na.cdn-perfprod.com/live/[channel]
(NA)https://lb-as.cdn-perfprod.com/live/[channel]
(Asia)https://lb-sa.cdn-perfprod.com/live/[channel]
(SA)
luminous-ttv servers:
https://eu.luminous.dev/live/[channel]
(Europe)https://eu2.luminous.dev/live/[channel]
(Europe 2)https://as.luminous.dev/live/[channel]
(Asia)
Using your turbo/subscriber token
With --auth-token
you can set an OAuth token to be used when fetching the master playlist. Twitch won't serve ads if the Twitch account associated with the OAuth token is subscribed to turbo or the specific channel you're watching.
To find your token, navigate to the Twitch website in a browser and open your browser's devtools (press F12). Click the Application
(Chrome) or Storage
(Firefox) tab and find https://www.twitch.tv
under Cookies
on the left. Your token is the string of characters beside the cookie named auth-token
.
Config file
Almost every option can also be set via config file. There is an example config file with all possible values set here.
Depending on your platform this will look for the config file at the following locations (can be overridden with -c
):
Platform | Default location |
---|---|
Linux & BSD | ${XDG_CONFIG_HOME:-${HOME}/.config}/twitch-hls-client/config |
Windows | %APPDATA%\twitch-hls-client\config |
MacOS | ${HOME}/Library/Application Support/twitch-hls-client/config |
Other | ./twitch-hls-client/config |
Installing
There are standalone binaries built by GitHub for Linux and Windows here.
Alternatively, you can build it yourself by installing the Rust toolchain and then running:
cargo install --git https://github.com/2bc4/twitch-hls-client.git
NixOS
Flake Package
# flake.nix
{
inputs.twitch-hls-client.url = "github:2bc4/twitch-hls-client";
# ...
outputs = {nixpkgs, ...} @ inputs: {
nixosConfigurations.HOSTNAME = nixpkgs.lib.nixosSystem {
specialArgs = { inherit inputs; }; # this is the important part
modules = [
./configuration.nix
];
};
}
}
# configuration.nix
{inputs, pkgs, ...}: {
programs.twitch-hls-client = {
enable = true;
package = inputs.twitch-hls-client.packages.${pkgs.system}.default;
};
}
Flake Home-Manager
# twitch-hls-client.nix
{
programs.twitch-hls-client = {
enable = true;
# ...
# This is a example to use -c config file every time
systemd.user.services.twitch-hls-client = {
Unit = {
Description = "Twitch HLS Client Service";
};
Service = {
Type = "simple";
ExecStart = "twitch-hls-client -c ${config.xdg.configHome}/twitch-hls-client/config";
Restart = "always";
};
Install = {
WantedBy = ["default.target"];
};
};
};
}
Optional build time features
colors
- Enable terminal colors (enabled by default)debug-logging
- Enable debug logging support
Reducing player latency with mpv
If your internet connection is fast enough to handle it, adding these values to your config will reduce latency by ~1-2 seconds:
player-args=- --profile=low-latency --no-cache
License
Distributed under the terms of the GNU General Public License v3, see LICENSE for more information.
Dependencies
~8–15MB
~287K SLoC