2bc4 / twitch-hls-client

Minimal CLI client for watching/recording Twitch streams
GNU General Public License v3.0
31 stars 5 forks source link

Shell alias for macOS w/ IINA : full example #37

Open Write opened 4 months ago

Write commented 4 months ago

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
2bc4 commented 4 months ago

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'