twitch-hls-client icon indicating copy to clipboard operation
twitch-hls-client copied to clipboard

Shell alias for macOS w/ IINA : full example

Open Write opened this issue 1 year ago • 1 comments

Here's my script to use twitch-hls-client on macOS with IINA player. It automatically creates a record folder based on twitch username and put all records here.

It's also completely hide the output and disown the process, so it's as detached as it can be from your terminal after the command is run.

This make it very easy to open a twitch stream by simply typing tw twitchusername in your console.

IINA Player

tw() {
    path_friendly_date=$(date +'%Y-%m-%d_%H-%M-%S')
    mkdir -p ~/twitch/"$@"/
    nohup ~/.cargo/bin/twitch-hls-client -s https://lb-eu5.cdn-perfprod.com/live/\[channel\] "$@" best -p /Applications/IINA.app/Contents/MacOS/iina-cli -r ~/twitch/"$@"/"$path_friendly_date".mp4 < /dev/null > /dev/null 2>&1 &
    disown
}

alias tw=tw

MPV

You can gain anywhere from 1 to 2 seconds with the help of "low-latency" params in MPV, which you would need to install trough brew install mpv

tw() {
    path_friendly_date=$(date +'%Y-%m-%d_%H-%M-%S')
    mkdir -p ~/twitch/"$@"/
    nohup ~/.cargo/bin/twitch-hls-client -s https://lb-eu5.cdn-perfprod.com/live/\[channel\] "$@" best -p /opt/homebrew/bin/mpv -r ~/twitch/"$@"/"$path_friendly_date".mp4 -a '- --profile=low-latency --no-cache' < /dev/null > /dev/null 2>&1 
    disown
}

alias tw=tw

Write avatar Jun 18 '24 00:06 Write

Nice script!

player-args=- --profile=low-latency --no-cache

You need to use -a when passing player args via command line:

-a '- --profile=low-latency --no-cache'

2bc4 avatar Jun 18 '24 03:06 2bc4