Downloading Videos from YouTube with yt-dlp on WSL2


Posted on Tue, Mar 5, 2024
Tags youtube, windows, linux
youtube, windows, linux
📝 This article is a translation of the original Japanese post. View original

What Is yt-dlp?

An open source tool that parses things like the json api of the YouTube site and downloads videos.

yt-dlp/yt-dlp: A feature-rich command-line audio/video downloader

I used yt-dlp because I wanted to download, for personal use, a private video I had uploaded to YouTube, and I didn’t want to use a sketchy web site.

Installation

It’s documented in Installation · yt-dlp/yt-dlp Wiki, so that’s a good reference. In my environment python3 is installed in wsl, so

1
python3 -m pip install -U yt-dlp

was all it took.

Downloading in High Quality

The -F option shows the formats and resolutions available for download.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
$ yt-dlp -F --progress "https://www.youtube.com/watch?v=xxxxxxxxx"

[info] Available formats for :
ID  EXT   RESOLUTION FPS HDR CH │   FILESIZE   TBR PROTO │ VCODEC          VBR ACODEC      ABR ASR MORE INFO
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
sb3 mhtml 48x27        0        │                  mhtml │ images                                  storyboard
sb2 mhtml 80x45        0        │                  mhtml │ images                                  storyboard
sb1 mhtml 160x90       0        │                  mhtml │ images                                  storyboard
sb0 mhtml 320x180      0        │                  mhtml │ images                                  storyboard
233 mp4   audio only            │                  m3u8  │ audio only          unknown             [ja] Default
234 mp4   audio only            │                  m3u8  │ audio only          unknown             [ja] Default
139 m4a   audio only          2 │   13.70MiB   49k https │ audio only          mp4a.40.5   49k 22k [ja] low, m4a_dash
140 m4a   audio only          2 │   36.35MiB  129k https │ audio only          mp4a.40.2  129k 44k [ja] medium, m4a_dash
251 webm  audio only          2 │   37.16MiB  132k https │ audio only          opus       132k 48k [ja] medium, webm_dash
269 mp4   256x144     29        │ ~ 54.47MiB  189k m3u8  │ avc1.4D400C    189k video only
160 mp4   256x144     29        │   22.38MiB   80k https │ avc1.4D400C     80k video only          144p, mp4_dash
603 mp4   256x144     29        │ ~ 47.97MiB  167k m3u8  │ vp09.00.11.08  167k video only
278 webm  256x144     29        │   24.57MiB   88k https │ vp09.00.11.08   88k video only          144p, webm_dash
631 mp4   256x144     29 10     │ ~ 63.81MiB  222k m3u8  │ vp09.02.11.10  222k video only
330 webm  256x144     29 10     │   39.78MiB  142k https │ vp09.02.11.10  142k video only          144p HDR, webm_dash
229 mp4   426x240     29        │ ~103.40MiB  360k m3u8  │ avc1.4D4015    360k video only
133 mp4   426x240     29        │   48.49MiB  173k https │ avc1.4D4015    173k video only          240p, mp4_dash
604 mp4   426x240     29        │ ~ 86.37MiB  300k m3u8  │ vp09.00.20.08  300k video only
242 webm  426x240     29        │   47.07MiB  168k https │ vp09.00.20.08  168k video only          240p, webm_dash
632 mp4   426x240     29 10     │ ~ 95.90MiB  334k m3u8  │ vp09.02.21.10  334k video only
331 webm  426x240     29 10     │   71.67MiB  255k https │ vp09.02.21.10  255k video only          240p HDR, webm_dash
230 mp4   640x360     29        │ ~229.20MiB  797k m3u8  │ avc1.4D401E    797k video only
134 mp4   640x360     29        │   91.30MiB  325k https │ avc1.4D401E    325k video only          360p, mp4_dash
18  mp4   640x360     29      2 │  117.62MiB  419k https │ avc1.42001E         mp4a.40.2       44k [ja] 360p
605 mp4   640x360     29        │ ~163.72MiB  570k m3u8  │ vp09.00.21.08  570k video only
243 webm  640x360     29        │   85.98MiB  306k https │ vp09.00.21.08  306k video only          360p, webm_dash
633 mp4   640x360     29 10     │ ~211.74MiB  737k m3u8  │ vp09.02.30.10  737k video only
332 webm  640x360     29 10     │  154.75MiB  551k https │ vp09.02.30.10  551k video only          360p HDR, webm_dash
231 mp4   854x480     29        │ ~394.27MiB 1372k m3u8  │ avc1.4D401F   1372k video only
135 mp4   854x480     29        │  172.61MiB  615k https │ avc1.4D401F    615k video only          480p, mp4_dash
606 mp4   854x480     29        │ ~271.20MiB  943k m3u8  │ vp09.00.30.08  943k video only
244 webm  854x480     29        │  151.19MiB  538k https │ vp09.00.30.08  538k video only          480p, webm_dash
634 mp4   854x480     29 10     │ ~362.73MiB 1262k m3u8  │ vp09.02.31.10 1262k video only
333 webm  854x480     29 10     │  292.98MiB 1043k https │ vp09.02.31.10 1043k video only          480p HDR, webm_dash
22  mp4   1280x720    29      2 │ ≈383.02MiB 1332k https │ avc1.64001F         mp4a.40.2       44k [ja] 720p
232 mp4   1280x720    29        │ ~727.85MiB 2532k m3u8  │ avc1.64001F   2532k video only
136 mp4   1280x720    29        │  338.06MiB 1204k https │ avc1.64001F   1204k video only          720p, mp4_dash
609 mp4   1280x720    29        │ ~506.91MiB 1763k m3u8  │ vp09.00.31.08 1763k video only
247 webm  1280x720    29        │  318.46MiB 1134k https │ vp09.00.31.08 1134k video only          720p, webm_dash
635 mp4   1280x720    29 10     │ ~782.44MiB 2722k m3u8  │ vp09.02.40.10 2722k video only
334 webm  1280x720    29 10     │  665.27MiB 2369k https │ vp09.02.40.10 2369k video only          720p HDR, webm_dash
270 mp4   1920x1080   29        │ ~  1.43GiB 5100k m3u8  │ avc1.640028   5100k video only
137 mp4   1920x1080   29        │  744.60MiB 2652k https │ avc1.640028   2652k video only          1080p, mp4_dash
614 mp4   1920x1080   29        │ ~813.61MiB 2830k m3u8  │ vp09.00.40.08 2830k video only
248 webm  1920x1080   29        │  525.06MiB 1870k https │ vp09.00.40.08 1870k video only          1080p, webm_dash
636 mp4   1920x1080   29 10     │ ~  1.25GiB 4439k m3u8  │ vp09.02.41.10 4439k video only
335 webm  1920x1080   29 10     │    1.11GiB 4031k https │ vp09.02.41.10 4031k video only          1080p HDR, webm_dash

You can pick and merge high-quality video & audio as below, but note that ffmpeg must be installed.

1
2
3
4
yt-dlp -f 636+251 -N10 --progress "https://www.youtube.com/watch?v=xxxxxxxxx"

# without ffmpeg installed you get the warning below
WARNING: You have requested merging of multiple formats but ffmpeg is not installed. The formats won't be merged

If they end up downloaded separately, merging them with video editing software is probably the way to go.

Share


See also