Stream/Clip Download Guide for Dummies

(I include myself in the dummy category - surely there are other ways, but this is just how I managed to figure out how to get the vids/clips I want after all the easy online tools I used to use broke, died, were bullied out of existence by the RIAA, or can't handle livestreams and hours-long videos. I'm doing all this on Windows, so I can't help with Mac or Linux specifics)

Get yt-dlp & FFmpeg

Download yt-dlp & FFmpeg from Github

Once downloaded, unzip the FFmpeg download and put ffmpeg.exe, ffplay.exe, ffprobe.exe, and yt-dlp.exe in the same folder together.
(The other files included with FFmpeg are just extra information, so you can either take the ffmpeg executables out and move them to the folder yt-dlp.exe is in, or you could move yt-dlp in with them. Any vids/clips downloaded will be automatically dumped in with these executables.)

Notes:

  • The yt-dlp project is basically the newer version of the widely-used youtube-dl project except moved because the old devs went inactive. If you Google around for help with commands or errors or whatever, older results may reference youtube-dl instead. Some info may be too outdated to apply but some is basically the same.
  • The yt-dlp program is bare-bones with no GUI - you have to control it through the command line or batch files. (I use batch files b/c I'm lazy.) There are also some projects out there that make a GUI to use with it, but I haven't bothered looking for one that does what I want it to do (some only include certain options).
Make batch files

In the same folder you have your executables in, right click -> new text document, then open it in Notepad.

I have a few different batch files I use for different things and can provide them below (see sample batch file section). Write/copypaste the commands you want into the text file, save, and then change the file extension from .txt to .bat (If you can't see the extension, enable viewing of file name extensions in the view menu at the top of Win explorer.)

When you want to download a video/clip, you'll edit the .bat file in Notepad to change whatever settings you want (URL, timestamps if applicable, etc.), save it, and then double click the .bat file to launch yt-dlp.exe using the settings in the .bat file. (Don't double-click yt-dlp.exe itself because it'll open, not know what you wanted to do, and then just shrug and close itself. The batch file launches yt-dlp and feeds it your instructions for you so you don't have to do it manually in the command line.)

  • If you add "pause" at the end of the bat file, it'll stay open after it's done running and wait for you to close it; otherwise it'll auto-close itself once it's done running. Letting it auto-close itself when it's done is fine unless there was an error you didn't have time to read. You can either leave "pause" in the batch file all the time and manually close it, or just take it out and only put it back in when it didn't work and you want to know what happened. (Maybe a logging feature exists but I just rerun it b/c idk/lazy)
  • You can use "rem blahblah" to add comments to your batch file it won't actually run
  • If it's a member-only stream (and you currently have membership and are logged in), add --cookies-from-browser chrome (replace with your browser) to the batch file to give it the p e r m s
    (You can either leave this in all the time and not care that it takes a few extra seconds for videos that don't need it, or you can do what I do sometimes and put "rem --cookies-from-browser chrome" at the bottom of the batch file and just paste it back in when needed for membership streams)
Downloading Twitter spaces:

Before joining the space, hit F12 (DevTools) in the browser & go to network tab, then join the Twitter space, then filter in the network tab for m3u8. Click one on the left, then copy the URL in the panel on the right and paste it into yt-dlp. Also add --downloader ffmpeg --hls-use-mpegts to the commands. It should start downloading from that moment on (don't think you can download live-from-start with Twitter spaces).

Quirks/usage notes

There are some quirks with livestreams just because of how YouTube/its API works.

  • Timestamps aren't 100% accurate (often a couple seconds behind), so I just add a couple seconds to the end timestamp and trim it later.
  • If you try to download from a livestream that just ended, it might fail to download (& give errors like "failed to download first fragment"). If this happens, try coming back later (maybe an hour or two?) and it'll just work when it's ready.
  • If it's a long stream that just ended, it might only be able to download the last 2 hours of the stream, so you'll have to come back later (maybe a day or two?) after the vid is done processing and lets you download the full thing.
  • You can also download a stream that's still live with the live-from-start option. Even if you start recording late, it'll start downloading the livestream from the beginning and then try to catch up. If the stream ends before it catches up, it should still (try to) download the rest and merge it with what it already downloaded. If you do it this way, you could have a 2hr+ livestream you caught late downloaded the same day without the 2-hour new VOD cutoff (first x hours you downloaded while it was live + last 2 hrs from the VOD)
  • If you try to download again from the same vid URL (maybe it failed the first time or you want to clip something else from the same vid) and there's already a file with that name in that folder, yt-dlp will decide you already have the video and close itself. If that happens, I usually just rename or delete the file and rerun it. (There's probably a command you could use to change the behavior but idk/lazy)
Sample commands/batch files:
  • Download video (whole):
    yt-dlp -f "bv+ba/b" https://www.youtube.com/watch?v=asdfasdf
    This downloads the best available video & audio formats it can find and merges them together

    yt-dlp -f "bv+ba/b" https://www.youtube.com/watch?v=asdfasdf --cookies-from-browser chrome
    Same but for members-only VODs

  • Download video (partial):
    yt-dlp -f "bv+ba/b" https://www.youtube.com/watch?v=asdfasdf --downloader ffmpeg --downloader-args "ffmpeg_i:-ss 1:02:31 -to 1:03:15"
    Specify the start and end timestamps for the clip you want (e.g. 1:01 for 1m1s, 1:01:00 for 1h1m0s, etc.)
  • Download livestream
    yt-dlp -f "bv+ba/b" https://www.youtube.com/watch?v=asdfasdf --live-from-start --wait-for-video 60 --cookies-from-browser chrome
    pause
    You can run this before the stream starts (it will keep checking back until the stream starts) or during the stream (it will download the stream from the start even if you start it late). This won't work if the stream has already ended and is now a VOD (use normal video download commands above for VODs).
  • Download audio (partial, wav format)
    yt-dlp -f bestaudio https://www.youtube.com/watch?v=asdfasdf --extract-audio --audio-format wav --downloader ffmpeg --downloader-args "ffmpeg_i:-ss 48:18 -to 49:00"
    • Specify the start and end timestamps for the clip you want (e.g. 1:01 for 1m1s, 1:01:00 for 1h1m0s, etc.)
    • This is for VODs only - idk if/how you can automatically download an audio clip from timestamps from a livestream
    • Because of the inaccurate timestamp thing, I add maybe 2 seconds to the end timestamp and have it save as a wav, then open it in Audacity, trim it myself, and export as mp3
Edit
Pub: 01 Nov 2022 15:05 UTC
Edit: 01 Dec 2022 10:14 UTC
Views: 884