Stream Archiving Guide

This mostly assume you are using windows, since if you are on linux I assume you know what you're doing, and I know nothing about macos - the commands should still be usable tho'.


Download

yt-dlp interface - https://github.com/ErrorFlynn/ytdlp-interface

GUI for yt-dlp, as well as a handy tool for checking and obtaining updates for yt-dlp and ffmpeg.
screenshot of ytdlp infereface update page
Alternatively, you can download yt-dlp and ffmpeg yourself at https://github.com/yt-dlp

ytarchive - https://github.com/Kethsar/ytarchive

Easiest tool to monitor channels for live streams and download from the start even if you start half way.

streamlink - https://github.com/streamlink/windows-builds/release

Get this if you need to archive Twitch/Bilibili livestreams, otherwise the above two works better with youtube. When in doubt, see here for which version (if you don't know which is which, you most likely want the x86_64.exe one)

Installation

Step 1: Extract ytarchive and yt-dlp to an easily accessable folder.

Personally I prefer to keeping them all in the same place, for example: C:\yt\

Step 2: Set up PATH to the folder (To run the exe from any location)

Typing "Environment" in the startmenu should bring up "Edit System Environment Varibles".

If not, Right-click the Windows icon > "System" > "Related Settings" (to the right)> "Advanced System Settings" > "Environment Variables" > PATH (the "system variable" one in the lower table)
Add a new entry with the path in step 2.

getting to environment variables path settings in environment variables

Streamlink comes with its own installer

Get the exe file, it'll install all the necessary parts, set the path and create the config file for you.


Basic Usage

Archiving ongoing youtube streams using ytarchive

Browse to the folder you want to save the vod to. Type "cmd" in the address bar to open the command prompt.
cmd prompt from file explorer

Type in the following commands and follow the prompt:
ytarchive https://www.youtube.com/watch?v=######

Or the following skip the prompt:
ytarchive -w https://www.youtube.com/watch?v=###### best
(-w: wait for scheduled time, best: best quality. You can replace these with -r 30 (poll every 30s), and list preferred bitrate if you a smaller file - include "best" as a failsafe in case the prefered bitrate is not avalible, eg: 720/720p60/best)

Downloading VODs with yt-dlp

The yt-dlp interface GUI should be pretty self explainatory.
Here are a few useful options that you can use in the command or add to the "custom argument" field of the GUI:
--download-archive "c:/yt/database.txt" - save a list of downloaded videos so you don't accidentally re-download again
--embed-metadata --embed-thumbnail - embed the thumbnail and metadata into the vod (only supported by mkv and mp4)
--extract-audio --audio-format mp3 - extract audio into mp3/aac/m4a/opus/vorbis/flac/alac/wav.
--download-sections " *30:15-55:00" - download only the selected time portion of a vod. Keep the * before the time range.
--write-subs --sub-langs live_chat - download the chat record in a .json file.
Despite the name, yt-dlp can be used to download vods from almost every sevice under the sun, including Bilibili and Twitch - only after they finished processing tho, for livestreams use ytarchive and streamlink.

Archiving ongoing twitch/bilibili streams using streamlink

Like with ytarchive, start a command prompt in the folder you want to save the file in, type in the following commands:
Type in the following commands and follow the prompt:
streamlink -o {author}-{title}({id}).mp4 --twitch-disable-ads --twitch-disable-hosting https://www.twitch.tv/###### 720p,720p60,best
Twich streams tends to be long, I'd recommend grabbing 720p or lower to save space, feel free to change that to just "best" if you have tons of space. Make sure you keep the --twitch-disable-ads to avoid video getting stuck on ads.

For Bilibili (The site doesn't seems to be working for me right now due to silly WW3 things... pretty sure this command would work tho.):
streamlink -o name-your-file.mp4 https://live.bilibili.com/#### best


Cookies for members-only streams

If you have joint memberships and would like to archive mengen streams, you need to login in a browser and do one of the following:

Option 1: Extract cookies.txt from your browser

This can be used by both yt-dlp and ytarchive, plus the file can be re-used on different PC / user profiles.
  1. Download the appropriate browser plugin (Chrome, Firefox, Edge).

  2. Go to a youtube page while logged into your account and extract the cookies using the plugin.

  3. Place the file somewhere easy to access. For example, C:\yt\cookies.txt You would then use it with --cookies "path-to-the-file"
Example:
ytarchive --cookies "C:/yt/cookies.txt" https://www.youtube.com/watch?v=###### best
yt-dlp --cookies "C:/yt/cookies.txt" https://www.youtube.com/playlist?list=UUMO_MembersOnlyPlayList
(you can find the mengen playlist of any channel by replacing the "UC" part of their channel with "UMMO", eg, youtube.com/channel/UCckdfYDGrjojJM28n5SHYrA becomes youtube.com/playlist?list=UUMOckdfYDGrjojJM28n5SHYrA

Option 2 Refer to the browser profile directly

This only works for yt-dlp, but requires no prior set up.

The format is --cookies-from-browser BROWSER[+KEYRING][:PROFILE], and it supports: brave, chrome, chromium, edge, firefox, opera, safari,vivaldi. If unspecified, it will use the last used profile.

Example:
yt-dlp --cookies-from-browser chrome https://www.youtube.com/watch?v=######
yt-dlp --cookies-from-browser firefox:asd12f.default https://www.youtube.com/watch?v=######


ytarchive tips

Monito a channel for livestreams

You can monitor a channel for any livestreams, even before a waiting room was created by using the following commands with a /live added to the channel url
ytarchive --monitor-channel https://www.youtube.com/channel/######/live best
As usual, you can specify the preferred bitrate instead of using best.
Once it finishes downloading and merging a stream, it will go right back to monitoring for the next stream.
Make sure you keep an eye on the storage space if you plan to leave this running 24/7.


Stop recording before stream ends:

If you want to stop an ongoing archive(eg, your laptop is out of battery and your oshi has left the stream), press Ctrl+C, and y on the prompt for merging files.
Make sure you leave some leeway to make sure the download have caught up to the parts you want to keep.
interrupted download

yt-dlp tips

Downloading live streams from the start (makeshift ytarchive)

If, for whatever reason, you cannot get ytarchive working and desperately need to download a livestream that has already begun, you can actually use yt-dlp to do it.
However, ytachive is still the better option if avalible as yt-dlp has higher chance of fucking up the file, and will to notice a stream has ended, it also does not offer to merge a partial download if you stop the download before it decided it is finished (you can still manually merge the files).
yt-dlp --live-from-start https://www.youtube.com/watch?v=######

Config file for default settings

If you can't be bothered to type in your preferred settings every time you use yt-dlp, you can save your default settings by creating a config.txt
Go to %appdata% and create the config file under %appdata%/yt-dlp/config.txt

Inside the file, put in what the settings you want yt-dlp to always use unless otherwise specified.

For example, here is what I put in mine to (1) always using the cookies file, (2) record livestreams from the start, get best bitrate mp4 preferred, and (4) embed thumbnail and metadata in the mp4:
--cookies "C:/yt/cookies.txt" --live-from-start -f "bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best" --embed-metadata --embed-thumbnail
yt-dlp config file location

Using Batch(.bat) files to start commends with one click

To avoid typing the same commands over and over again, you can save your frequently used commands in .bat files and run them whenever needed. Scroll down for gif showing how to create .bat files.

Here are some examples:

ytarchvie-prompt.bat - Prompt for the URL of a stream wait for start time, use cookies.txt, embed meta data, and use highest quality avalible, and saved it in a folder called W:\Youtube Archive.
@echo off
TITLE ytarchive: Best Quality, Wait for Start, Use Cookies
Echo:ytarchive: Best Quality, Wait for Start, Use Cookies
cd /d W:\Youtube Archive
echo Saving the file to %CD%
set /p yturl= "Stream URL:"
@echo on
ytarchive -w --cookies "C:/yt/cookies.txt" --add-metadata %yturl% best

ytarchive-monitor-###.bat - Monitor a channel and download best avalible format when a stream starts. Once it finish downloading and saving, it'll go right back to monitor.
@TITLE ytarchive-monitor: Name
@cd /d w:\Youtube Archive\Name
ytarchive --cookies "C:/yt/cookies.txt" --add-metadata --monitor-channel https://www.youtube.com/channel/######/live best

ytdlp-ArchiveChannel.bat - Download everything on a channel / playlist, record what has been downloaded so it can be stopped and resumed / updated, use cookies, get best quality (mp4 preferred)
@TITLE ytarchive: Full Playlist/Channel Archive
@cd /d w:\Youtube Archive\Name
yt-dlp --ignore-config --cookies "C:/yt/cookies.txt" --download-archive "C:/yt/database.txt" --embed-metadata --embed-thumbnail -f "bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best" https://www.youtube.com/channel/######

yt-dlp-monitor-###.bat - yt-dlp can technically monitor channel if you run it in a loop too. Again, ytarchive is recommended due to lower chance of having download issues. Only use this if you have issue getting ytarchive working.
@TITLE yt-dlp-monitor: Name
@cd /d w:\Youtube Archive\Name
:loop
yt-dlp --cookies "C:/yt/cookies.txt" --live-from-start --embed-metadata --embed-thumbnail https://www.youtube.com/channel/######/live best
timeout /T 120
goto loop

streamlink-monitor-###.bat - streamlink to monitor twitch/bilibi channels (it can technically monitor youtube live streams too, but again, use ytarchive for that if you can)
@TITLE streamlink-monitor: Name
@cd /d w:\Youtube Archive\Name
:loop
streamlink -o "{author}-{title}({id})-{time:%%Y%%m%%d-%%H%%M}.mp4" https://www.twitch.tv/#### 720p,720p60,best --twitch-disable-hosting --twitch-disable-ads
timeout /T 120
goto loop

live-vod-and-chat-###.bat - prompt for url and simultaneously archive the vod with ytarchive and the chatlog with yt-dlp
TITLE Live VoD and Chat
@echo Live VoD and Chat
cd /d w:\Youtube Archive
set /p yturl= "Stream URL:"
start cmd /k "ytarchive -w --cookies "C:/yt/cookies.txt" --add-metadata %yturl% best"
start cmd /k "yt-dlp --cookies "C:/yt/cookies.txt" --write-subs --sub-langs live_chat --skip-download %yturl%"

Steps to making bat files:
steps for making .bat file