This guide covers how to record livestreams as they are occurring. This is useful for streams that will not be archived later.
These instructions are for recording publicly available streams using Streamlink. Youtube-dl can record livestreams as well but Streamlink offers a better user experience for this scenario (it is common for people to corrupt their livestream recordings with youtube-dl). The following steps will record a stream while playing the stream through VLC. Instructions for using alternative media players are provided under Advanced Scenarios.
tl;dr
streamlink --retry-streams 10 --player mpv -r stream.mp4 <stream_url> best
- Install Streamlink
- Install VLC or another video player of your choice.
- Optionally install youtube-dl. A simple install and usage guide is provided here. This will be used to download the stream's description and thumbnail for a more complete archive.
The example will save the high quality stream available as stream.mp4
in the folder C:\Users\anon\stream_folder
.
- Create a folder for where you want to save the stream to. You may want to user a temporary folder and then manually move it to the final destination afterwards.
- Open the command prompt, you will run commands here by copying and pasting commands and pressing enter.
- Open the start menu and search for
command prompt
.
- Open the start menu and search for
- Move to the folder where you want to save the stream to.
- Command:
cd "<path_to_folder_from_step_1>"
- Example:
cd "C:\Users\anon\stream_folder"
- Command:
- Start recording the stream
- Command:
streamlink -r <name_to_save_stream_as>.mp4 <stream_url> best
- Example:
streamlink -r stream.mp4 https://www.youtube.com/watch?v=RPdUErEiRbk best
- Command:
This is useful when you do not have enough bandwidth for 1080p streams.
streamlink -r <name_to_save_stream_as>.mp4 <stream_url> 720p
When the waiting room is available, you can use this command to have streamlink try start recording every 10 seconds. This is very useful if you know you will not be present for the start of the stream.
streamlink --retry-streams 10 -r <name_to_save_stream_as>.mp4 <stream_url> best
You may have to provide the full file path to the video player executable instead of just using the short name. To use the short name instead of the full file path, you have to add the file path of the video player to your PATH
. Refer to the setx
command here
mpv:
streamlink --player mpv -r <name_to_save_stream_as>.mp4 <stream_url> best
mpc:
streamlink --player mpc-hc64 -r <name_to_save_stream_as>.mp4 <stream_url> best
Changing -r
to -o
in the command makes it only save to a file. This is useful to combine with --retry-streams 10
to record a stream that has been scheduled when you will not be present.
streamlink -o <name_to_save_stream_as>.mp4 <stream_url> best
streamlink --retry-streams 10 -o <name_to_save_stream_as>.mp4 <stream_url> best
This script will extract the right value out of a cookies.txt
file and run streamlink
with the arguments you provide it.
- Get a
cookies.txt
file. Refer to steps 1 to 4 here - Copy streamlink-auth.ps1 and save it as
streamlink-auth.ps1
where you installedstreamlink
.- Default installation location is
C:\Program Files (x86)\Streamlink\bin
- Default installation location is
- Open Powershell.
- Open the start menu (Windows key), type in powershell, open Windows Powershell
- Run the command
streamlink-auth COOKIES_TXT_FILE_PATH STREAMLINK_ARGUMENTS
- Example: You want to watch https://www.youtube.com/watch?v=-hLmfV-wQKo and your
cookies.txt
file is located atC:\Users\anon\Documents\cookies.txt
streamlink-auth C:\Users\anon\Documents\cookies.txt https://www.youtube.com/watch?v=-hLmfV-wQKo best
- If you are running into issues with
streamlink-auth
not found, then copy the script somewhere else, and navigate to that folder in Powershell using the commandcd <Path to folder containing script>
and try again.
- Example: You want to watch https://www.youtube.com/watch?v=-hLmfV-wQKo and your
The above script is simply extracting the __Secure-3PSID
cookie for .youtube.com and setting the --http-cookie
command line arguement as --http-cookie __Secure-3PSID=<cookie value>
. The line in the cookies.txt
you are looking for looks like #HttpOnly_.youtube.com TRUE / TRUE 1667272763 __Secure-3PSID <Some random letters and numbers, this is the cookie value>
. If you use the same cookies.txt
with youtube-dl
then the line might not start with #HttpOnly_
.
The previous steps should have given you a working video file but it can be improved with a few simple steps. The following steps will convert the file to a real .mp4
file [note], add a fancy thumbnail, save the video description with the recording, and give the video a nice name.
Before and After:
Do the following in PowerShell instead of command prompt. You can convert a command prompt into PowerShell by using the command powershell
.
You will have to open a new command prompt for PowerShell while your previous command prompt is busy running Streamlink.
- Generate a nice filename to be used later. Example generated filename:
[Botan Ch.獅白ぼたん][20200830] 5期生より (fCqDv94ZeuA)
. You will want to do this step while the stream is still live.
$filename = youtube-dl --write-description --skip-download -o "[%(uploader)s][%(upload_date)s] %(title)s (%(id)s)" --get-filename <stream_url>
- Download the livestream's description and thumbnail as
stream.description
andstream.jpg
respectively. You will want to do this step while the stream is still live, once the livestream ends and the archive is deleted, you will not have access to the description nor the thumbnail anymore.
youtube-dl --write-thumbnail --write-description --skip-download -o stream <stream_url>
- Store the livestream's description into variable
$description
.
$description = [IO.File]::ReadAllText(".\stream.description")
- Convert to
.mp4
, add thumbnaill, add the description to the video's comment and save the new video with a formatted name.
ffmpeg -i .\stream.mp4 -i .\stream.jpg -map 1 -map 0 -c copy -disposition:0 attached_pic -metadata comment=$description $($filename + ".mp4")
The original recording from streamlink is saved with a .mp4
file extension but it is actually a MPEG-TS
format file. Most video players will still be able to play the recording since they understands the format and do not rely on the file extension.
The fake .mp4
extension is convenient for most people because their computers would be set up to use a video player to open files with the extension .mp4
. Converting it to a real .mp4
file will reduce the file size without affecting quality.
My thumbnail was downloaded as a .webp file and that file format is not supported for thumbnails, how do I convert it?
Convert from .webp
to .jpg
. ffmpeg is wonderful.
ffmpeg -i stream.webp stream.jpg
youtube-dl -o - <stream_url> best | tee stream.mp4 | mpv -
You can get tee
by installing git. This will not work in PowerShell.
AtomicParsley only records the first 255 characters of the video's comment. If you want to use it, do it before adding the comment.
Read the manuals