How to download YouTube Live Stream videos using Streamlink
How to save / download live streaming videos from YouTube, Dailymotion, UStream, Twitch, Livestream? Streamlink is a CLI utility that can transfer Flash videos from online streaming services to various video players, such as VLC, mpv, MPlayer e.t.c. It aims to convert Flash plug-ins that consume a lot of CPU to a format that consumes less CPU.
Install FFmpgeg
Install FFmpeg on Ubuntu / Debian / Linux Mint:
To install FFmpeg on Ubuntu / Debian / Linux Mint, run:
sudo apt-get -y install ffmpeg
Install FFmpeg on Arch Linux:
Install FFmpeg on Arch Linux by running the following command:
sudo pacman -S ffmpeg
Install FFmpeg on Fedora:
For Fedora, use the following guidelines:
How to install FFmpeg on Fedora
Install FFmpeg on CentOS:
CentOS 8: Install FFmpeg on CentOS 8
For CentOS 7:
sudo yum -y install epel-release
sudo rpm -v --import http://li.nux.ro/download/nux/RPM-GPG-KEY-nux.ro
sudo rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-5.el7.nux.noarch.rpm
sudo yum install ffmpeg ffmpeg-devel
Install Streamlink
Apple system
$ sudo easy_install -U streamlink
OR
$ brew install streamlink
Arch Linux:
sudo pacman -S streamlink
Ubuntu:
sudo add-apt-repository ppa:nilarimogard/webupd8
sudo apt update
sudo apt install streamlink
Debian:
wget -qO- "https://bintray.com/user/downloadSubjectPublicKey?username=amurzeau" | sudo apt-key add -
echo "deb https://dl.bintray.com/amurzeau/streamlink-debian stretch-backports main" | sudo tee "/etc/apt/sources.list.d/streamlink.list"
sudo apt update
sudo apt install streamlink
Fedora:
sudo dnf install streamlink
Solus:
sudo eopkg install streamlink
invalid:
sudo xbps-install streamlink
Download live streaming video with Streamlink
The way Streamlink works is that it is just a way to extract and transport the stream, and playback is done by an external video player. Streamlink works best with VLC Either mpvThey are also cross-platform, but other players may also be compatible.
Watch live with Streamlink
Assuming you want to watch the stream located at https://youtu.be/yixlb8qMTmA, you would run:
$ streamlink https://youtu.be/yixlb8qMTmA [cli][info] Found matching plugin youtube for URL https://youtu.be/yixlb8qMTmA Available streams: 144p (worst), 240p, 360p, 480p, 720p, 1080p (best)
The above command tells Streamlink to try to extract the stream from the specified URL, and if successful, it will print out a list of alternative streams.
You can choose from the available streams:
$ streamlink https://youtu.be/yixlb8qMTmA best cli][info] Found matching plugin youtube for URL https://youtu.be/yixlb8qMTmA [cli][info] Available streams: 144p (worst), 240p, 360p, 480p, 720p, 1080p (best) [cli][info] Opening stream: 1080p (hls) [cli][info] Starting player: /usr/bin/vlc
It will use the installed default player, but you can also specify a player, see the full list of supported players.
$ streamlink --player=mpv https://youtu.be/yixlb8qMTmA best [cli][info] Found matching plugin youtube for URL https://youtu.be/yixlb8qMTmA [cli][info] Available streams: 144p (worst), 240p, 360p, 480p, 720p, 1080p (best) [cli][info] Opening stream: 1080p (hls) [cli][info] Starting player: mpv
Downloading a live stream using Streamlink
You can also save the file for offline viewing, see the example below.
streamlink --hls-live-restart -o hot-pop.mp4 https://youtu.be/yixlb8qMTmA best
This will save the live stream to a file hot-pop.mp4.
See all available options by running:
$ streamlink --help
And man pages
$ man streamlink
Also visit the Streamlink Wiki page for more information.
Similar guide:
Download YouTube videos on Linux with Annie
How to download YouTube videos on Linux using ytdl-webserver