Icey One
My wish is to see you again, even across the world.
How to download video?

Introduction

Often we have the need to download videos, such as for learning or collection. Here is how I download videos. I usually use Aria2 to download BT, yt-dlp to download streaming video.

The machine used in this article is Windows 11, please change it as appropriate for other systems.

1. Aria2

In theory, aria2 is the silver bullet, which can download anything, multi-protocol & cross platform, etc. But I only use it to download BT, because other have better tools.

First of all, I think it’s better to introduce what is BT, Track and P2P.

The full name of BT is BitTorrent, a protocol for P2P, which enables users to distribute and download files over internet. Where P2P means Peer-to-peer file sharing. It’s decentralized and doesn’t even require a network. Track is a special type of server that assists in the communication between peers using BT. If you want to increase the download speed, you should add the appropriate Tracker servers.

1.1 Config

Create this new files (or folder):

1
2
3
4
Download      # Path to save the downloaded file
aria2.conf    # Config
aria2.log     # Log storage, ignore it if you not needed
aria2.session # Blank file

Then your file tree should look like this:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
│  aria2.conf
│  aria2.log
│  aria2.session
│  aria2c.exe
│  AUTHORS
│  ChangeLog
│  COPYING
│  index.html
│  LICENSE.OpenSSL
│  NEWS
│  README.html
│  README.mingw
└─Download

This is my aria2.conf, you can modify it according to your needs.

  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
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
# File name:aria2.conf

## aria2 config ##

# Download path. absolute path or relative path can be used. Default: current startup location
# Absolute path: dir=Folder path
# Relative path: dir=~/Download
dir=~/Download

# Disk cache, 0 is to disable cache, default: 16M
# Enable disk cache. If SIZE is 0, the disk cache is disabled. Default: 16M
# This feature caches the downloaded data in memory, which grows to at most SIZE bytes. SIZE can include K or M. 
disk-cache=64M

# File pre-allocation method, optional: none, prealloc, trunc, falloc, default: prealloc
# Pre-allocation can effectively reduce disk fragmentation, improve disk read and write performance, and extend disk life for mechanical hard disks.
# The mechanical hard disk uses ext4 (with extended support), btrfs, xfs or NTFS (only MinGW compiled version) and other file systems are recommended to be set to falloc
# SSD does not need to be pre-allocated, it is only recommended to set it to none.
file-allocation=none

# File allocation limit size,Unit K or M,default: 5M
no-file-allocation-limit=64M

# Resume from break-point
continue=true

# Always try to resume the download, if the download cannot be resumed, the download will be terminated, default: true
always-resume=false

# URI values that do not support resumable uploads, take effect when always-resume=false.
max-resume-failure-tries=0

# Get remote server time, default:false
# I set this to true to prevent cross-time zone situations.
remote-time=true


## Session setting ##

# Path of input download file
input-file=~/aria2.session

# Path of saved session
save-session=~/aria2.session
save-session-interval=1

# The time interval to automatically save to the session, default: 60
auto-save-interval=20

# Force save, default: false
force-save=false


## Download connection settings ##

# File not found retries, default: 0 (disabled)
max-file-not-found=10

# Maximum number of attempts, 0 means unlimited, default: 5
max-tries=0

# Retry wait time (s), default: 0 (disable)
retry-wait=10

# Default(s)
connect-timeout=10

# Default(s)
timeout=10

# The maximum number of simultaneous download tasks, default: 5
max-concurrent-downloads=15

# Max connection per server, default: 1, max: 16
max-connection-per-server=16

# The maximum number of connection threads for one task, default: 5
split=64

# file minimum segment size, 1M-1024M, default 20M
min-split-size=4M
piece-length=1M

# Allow piece length change, default: false
allow-piece-length-change=true

# Minimum download speed limit, Unit K or M ,default:0 (unlimited)
lowest-speed-limit=0

# Global maximum download speed limit, can be modified at runtime, default: 0 (unlimited)
max-overall-download-limit=0

# Single task download speed limit, default: 0 (unlimited)
max-download-limit=0

# Disable IPv6, default: false
disable-ipv6=true

# GZip,default:false
http-accept-gzip=true

# URI
reuse-uri=false

# Disable netrc
no-netrc=true

# Allows overwriting, re-downloading from scratch when the control file (.aria2) doesn't exist. 
# Default: false
allow-overwrite=false

# Auto rename files
auto-file-renaming=true

# UTF-8 to Content-Disposition, default:false
content-disposition-default-utf8=true

# TLS version, option: TLSv1.1、TLSv1.2、TLSv1.3 default: TLSv1.2
#min-tls-version=TLSv1.2


## BT/PT setting ##

# BT listen port(TCP), default: 6881-6999
# Devices directly connected to internet, such as VPS, must configure firewalls and security group policies to allow this port to enter
# Devices in the internal network environment, such as NAS, in addition to firewall settings, you also need to set the external network port forwarding to this port on the router
listen-port=51413

# DHT and UDP tracker listen port(UDP), default:6881-6999
dht-listen-port=51413

# enable IPv4 DHT, PT download will disable, default:false
enable-dht=true

# enable IPv6 DHT, PT download will disable, default:false
# Enabling it in an environment without IPv6 support may cause DHT to malfunction
enable-dht6=false


# IPv4 DHT path,default:$HOME/.aria2/dht.dat
dht-file-path=/root/.aria2/dht.dat

# IPv6 DHT path,default:$HOME/.aria2/dht6.dat
dht-file-path6=/root/.aria2/dht6.dat

# IPv4 DHT
dht-entry-point=dht.transmissionbt.com:6881

# IPv6 DHT
dht-entry-point6=dht.transmissionbt.com:6881

# local peer discovery, PT download will disable, default:false
bt-enable-lpd=true


# Enable peer exchange, PT will auto disable
enable-peer-exchange=true

# BT maximum connections,0 means unlimted, default: 55
bt-max-peers=128

# BT download expected speed value (single task) Unit K or M. Default: 50K
bt-request-peer-speed-limit=10M

# Global maximum upload speed limit, default: 0 (default)
max-overall-upload-limit=2M

# Single task upload speed limit, default: 0 (unlimited)
max-upload-limit=0

# Minimum share rate. Stop seeding when the seed sharing rate reaches the value set by this option 
# 0 means always seeding, default: 1.0
# It is strongly recommended that you set this option to >= 1.0
seed-ratio=1.5

# min seed time (min)。Setting to 0 will stop seeding after the torrent download is complete.
seed-time=0

# Check file hash before seeding, default: true
bt-hash-check-seed=true

# When continuing the previous BT task, there is no need to verify again, default: false
bt-seed-unverified=false

# BT tracker server connection timeout (s). Default: 60
bt-tracker-connect-timeout=10

# BT tracker max timeout (s). default: 60
bt-tracker-timeout=10

# BT track max time interval. Default: 0 (auto)
#bt-tracker-interval=0

# BT downloads the beginning or end of the file first
bt-prioritize-piece=head=32M,tail=32M

# Save torrent uploaded via RPC, default: true
rpc-save-upload-metadata=true

# Automatically start downloading after downloading a torrent.
# option:true, false, mem, default: true
follow-torrent=true

# only download feed, default: false
pause-metadata=false

# save feed(.torrent), default: false
bt-save-metadata=true

# Bt load saved metadata(.torrent), default: false
bt-load-saved-metadata=true

# remove BT file which be unselected, default: false
bt-remove-unselected-file=true

# BT force encrypt, default: false
# It can solve the blockade of BT download by some Telecom operators, and can anti-Xunlei(反迅雷)
# If you enable it, the next option(bt-require-crypto=true, bt-min-crypto-level=arc4) don't need setting.
bt-force-encryption=true

# BT require crypto,default:false
# bt-require-crypto=true

# BT min crypto,option:plain, arc4, default: plain
# bt-min-crypto-level=arc4

# Bt detach the task of seed only, default: false
bt-detach-seed-only=true


## Client agent ##

# Customize User Agent
user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.63 Safari/537.36 Edg/93.0.961.47

# BT agent
# PT download needs to keep the two parameters of user-agent and peer-agent consistent
peer-id-prefix=-TR2770-
user-agent=Transmission/2.77
peer-agent=Transmission/2.77


## RPC ##
# If you are not a professional, I do not recommend modifying these

# enable JSON-RPC/XML-RPC server, default: false
enable-rpc=true

# Accept all remote requests, default: false
rpc-allow-origin-all=true

# Accept all remote listen, default:false
rpc-listen-all=true

# RPC port, default:6800
rpc-listen-port=6800

# RPC key
rpc-secret=P3TERX

# RPC max request
rpc-max-request-size=10M

# RPC server, SSL/TLS encryption, default: false
# After enabling encryption, you must use https or wss protocol to connect. It is not recommended to enable it. 
# It is recommended to use web server reverse proxy, such as Nginx and Caddy, which are more flexible.
#rpc-secure=false

# 在 RPC certificate(.pem/.crt)
#rpc-certificate=/root/.aria2/xxx.pem

# 在 RPC private key(.key)
#rpc-private-key=/root/.aria2/xxx.key


## log setting ##

# Log file save path, ignore or set to empty to not save, default: not save
log=~/aria2.log

# log level, option: debug, info, notice, warn, error. Default: debug
#log-level=warn

# console log lever, option debug, info, notice, warn, error, default: notice
console-log-level=notice

# Quiet mode, disable log output on the console, default: false
quiet=false

#Download summary output interval (s),0 is disable. Default:60
summary-interval=0

## BitTorrent trackers ##
# Different trackers are separated by commas(,) 
# For example bt-tracker=tracker-a,tracker-v
bt-tracker=

If you want to make more in-depth changes, I recommend you to read aria2 doc .

1.2 Tracker

Adding tracker is crucial to improve torrent download speed. Here are some trackers I use, it is very helpful for downloading anime.

1.3 Usage

For example I want to download Vivy-Flourite Eye’s Song OST, in Nyaa, I can download via BitTorrent or Magnet.

BitTorrent:

1
aria2c https://nyaa.si/download/1525645.torrent

Magnet:

1
aria2c 'magnet:?xt=urn:btih:ebaa26b16ba4c3b9b618019e0e988a687c28aba1&dn=Vivy-Flourite%20Eye%27s%20Song%20OST&tr=http%3A%2F%2Fnyaa.tracker.wf%3A7777%2Fannounce&tr=udp%3A%2F%2Fopen.stealth.si%3A80%2Fannounce&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337%2Fannounce&tr=udp%3A%2F%2Fexodus.desync.com%3A6969%2Fannounce&tr=udp%3A%2F%2Ftracker.torrent.eu.org%3A451%2Fannounce'

If you want to know more commands, run

1
aria2c -h

1.4 GUI

If you don’t want to use command line, you can also use third-party GUI, here I list some of the more well-known GUI. But I recommend using the command line, and you will understand the command line after using it a few times.

Name Remark
AriaNg GUI Chinese only, no need to download aria2 separately.
Aria2 for Chrome Need to enable RPC mode
Motrix Doesn’t support remote control.

2. yt-dlp

yt-dp is a free and open source program to download videos from YouTube and other video sites, build written by Python, so we need download Python and pip. In this way, Python isn’t useless.

You can find all sites which support youtube-dl in here .

2.1 Download

The following default installed Python version >= 3.10, if not, download Python please.

Download youtube-dl

1
pip install yt-dlp

Enter the following code to check the installation.

1
yt-dlp --version

Download FFmpeg

1
pip install ffmpeg

Enter the following code to check the installation.

1
ffmpeg

If running FFmpeg fails, please go to the official website to download and add environment variables.

Download FFmpeg and add bin folder path to Environment variables path. For me, the path is D:\Download\ffmpeg-5.1.2-full_build\bin.

2.2 Usage

2.2.1 Download single video

For instance, I want install Mili - String Theocracy / “Library of Ruina” theme song .

List all format of the video (YouTube only).

1
yt-dlp -F https://www.youtube.com/watch?v=nOj_A3aZxGs

Then the following will be printed out

 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
[youtube] Extracting URL: https://www.youtube.com/watch?v=nOj_A3aZxGs
[youtube] nOj_A3aZxGs: Downloading webpage
[youtube] nOj_A3aZxGs: Downloading android player API JSON
[info] Available formats for nOj_A3aZxGs:
ID  EXT   RESOLUTION FPS CH │   FILESIZE   TBR PROTO │ VCODEC          VBR ACODEC      ABR ASR MORE INFO
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────
sb2 mhtml 48x27        1    │                  mhtml │ images                                  storyboard
sb1 mhtml 80x45        1    │                  mhtml │ images                                  storyboard
sb0 mhtml 160x90       1    │                  mhtml │ images                                  storyboard
599 m4a   audio only      2 │  658.58KiB   31k https │ audio only          mp4a.40.5   31k 22k ultralow, m4a_dash
600 webm  audio only      2 │  721.82KiB   34k https │ audio only          opus        34k 48k ultralow, webm_dash
139 m4a   audio only      2 │    1.02MiB   49k https │ audio only          mp4a.40.5   49k 22k low, m4a_dash
249 webm  audio only      2 │    1.04MiB   50k https │ audio only          opus        50k 48k low, webm_dash
250 webm  audio only      2 │    1.37MiB   66k https │ audio only          opus        66k 48k low, webm_dash
140 m4a   audio only      2 │    2.70MiB  130k https │ audio only          mp4a.40.2  130k 44k medium, m4a_dash
251 webm  audio only      2 │    2.72MiB  130k https │ audio only          opus       130k 48k medium, webm_dash
17  3gp   176x144      8  1 │  989.32KiB   46k https │ mp4v.20.3       46k mp4a.40.2    0k 22k 144p
597 mp4   256x144     15    │  636.23KiB   30k https │ avc1.4d400b     30k video only          144p, mp4_dash
598 webm  256x144     15    │  380.11KiB   18k https │ vp9             18k video only          144p, webm_dash
394 mp4   256x144     30    │  724.94KiB   34k https │ av01.0.00M.08   34k video only          144p, mp4_dash
160 mp4   256x144     30    │  393.27KiB   18k https │ avc1.4d400c     18k video only          144p, mp4_dash
278 webm  256x144     30    │  880.14KiB   41k https │ vp9             41k video only          144p, webm_dash
395 mp4   426x240     30    │    1.18MiB   57k https │ av01.0.00M.08   57k video only          240p, mp4_dash
133 mp4   426x240     30    │  594.25KiB   28k https │ avc1.4d4015     28k video only          240p, mp4_dash
242 webm  426x240     30    │    1.15MiB   55k https │ vp9             55k video only          240p, webm_dash
396 mp4   640x360     30    │    2.38MiB  114k https │ av01.0.01M.08  114k video only          360p, mp4_dash
134 mp4   640x360     30    │    1.02MiB   49k https │ avc1.4d401e     49k video only          360p, mp4_dash
18  mp4   640x360     30  2 │ ~  3.80MiB  178k https │ avc1.42001E    178k mp4a.40.2    0k 44k 360p
243 webm  640x360     30    │    2.12MiB  102k https │ vp9            102k video only          360p, webm_dash
397 mp4   854x480     30    │    4.52MiB  217k https │ av01.0.04M.08  217k video only          480p, mp4_dash
135 mp4   854x480     30    │    1.62MiB   78k https │ avc1.4d401f     78k video only          480p, mp4_dash
244 webm  854x480     30    │    3.62MiB  173k https │ vp9            173k video only          480p, webm_dash
22  mp4   1280x720    30  2 │ ~  6.27MiB  293k https │ avc1.64001F    293k mp4a.40.2    0k 44k 720p
398 mp4   1280x720    30    │   11.09MiB  532k https │ av01.0.05M.08  532k video only          720p, mp4_dash
136 mp4   1280x720    30    │    3.43MiB  165k https │ avc1.4d401f    165k video only          720p, mp4_dash
247 webm  1280x720    30    │    8.04MiB  385k https │ vp9            385k video only          720p, webm_dash
399 mp4   1920x1080   30    │   21.78MiB 1045k https │ av01.0.08M.08 1045k video only          1080p, mp4_dash
137 mp4   1920x1080   30    │   15.88MiB  761k https │ avc1.640028    761k video only          1080p, mp4_dash
248 webm  1920x1080   30    │   21.13MiB 1013k https │ vp9           1013k video only          1080p, webm_dash

We want to download 1080p video, so choose format 137, so run

1
yt-dlp -f 137 https://www.youtube.com/watch?v=nOj_A3aZxGs

OK, just wait for the download. Wait! There seems to be a problem. Why is there no sound?

So we need ffmpeg to merge video and audio, run

1
yt-dlp -f 137+251 https://www.youtube.com/watch?v=nOj_A3aZxGs

If you don’t set format, yt-dlp will download the best ability by default.

2.2.2 Download video playlist

You may say: OK, It’s easy, I know how to download videos, but what if I want to download all the videos in my collection, do I have to download them one by one?

Of course not, next we will introduce how to download videos that you liked in batches.

Download Functional Analysis - The Bright Side of Mathematics playlist with the videos being 1080p and the best audio. Save into channel_id/playlist_id directory with the video added to an archive text file:

1
yt-dlp -f bv*[height=1080]+ba --download-archive videos.txt https://www.youtube.com/playlist?list=PLBh2i93oe2qsGKDOsuVVw-OCAfprrnGfr -o '%(channel_id)s/%(playlist_id)s/%(id)s.%(ext)s'

For some websites, we need to log in to watch or download 1080 p videos, such as YouTube member or Bilibili , so we need add cookie to download.

1
yt-dlp -F xxxxx --cookies-from-browser <brower name>

For example, find all format of 7日之都大圆舞曲 , using the cookie of chrome, run

1
yt-dlp -F https://www.bilibili.com/video/BV1Bi4y1V7Wf --cookies-from-browser chrome

Then the following will be printed out

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
yt-dlp -F https://www.bilibili.com/video/BV1Bi4y1V7Wf --cookies-from-browser chrome
[Cookies] Extracting cookies from chrome
[Cookies] Extracted 1098 cookies from chrome
[BiliBili] Extracting URL: https://www.bilibili.com/video/BV1Bi4y1V7Wf
[BiliBili] 1Bi4y1V7Wf: Downloading webpage
[BiliBili] BV1Bi4y1V7Wf: Extracting videos in anthology
[BiliBili] 542925024: Extracting chapters
[info] Available formats for BV1Bi4y1V7Wf:
ID EXT RESOLUTION FPS │  FILESIZE   TBR PROTO │ VCODEC          VBR ACODEC      ABR
───────────────────────────────────────────────────────────────────────────────────
0  m4a audio only     │ ~ 1.07MiB   65k https │ audio only          mp4a.40.2   65k
1  m4a audio only     │ ~ 2.20MiB  133k https │ audio only          mp4a.40.2  133k
2  m4a audio only     │ ~ 4.23MiB  255k https │ audio only          mp4a.40.2  255k
3  mp4 640x360     25 │ ~ 5.03MiB  303k https │ avc1.64001E    303k video only
4  mp4 640x360     25 │ ~ 3.51MiB  212k https │ hev1.1.6.L120  212k video only
5  mp4 852x480     25 │ ~11.33MiB  684k https │ avc1.64001F    684k video only
6  mp4 852x480     25 │ ~ 7.88MiB  475k https │ hev1.1.6.L120  475k video only
7  mp4 1280x720    25 │ ~25.24MiB 1522k https │ avc1.640028   1522k video only
8  mp4 1280x720    25 │ ~17.51MiB 1056k https │ hev1.1.6.L120 1056k video only
9  mp4 1920x1080   25 │ ~37.90MiB 2286k https │ avc1.640032   2286k video only
10 mp4 1920x1080   25 │ ~26.25MiB 1584k https │ hev1.1.6.L120 1584k video only
11 mp4 1920x1080   25 │ ~77.16MiB 4655k https │ avc1.640032   4655k video only
12 mp4 1920x1080   25 │ ~46.57MiB 2809k https │ hev1.1.6.L120 2809k video only

Select 2+12, merge to 1080 p video

1
yt-dlp -f 2+12 https://www.bilibili.com/video/BV1Bi4y1V7Wf --cookies-from-browser chrome

2.2.4 External downloader

We can achieve multi-threaded download through external downloader.

Download Mili - String Theocracy / “Library of Ruina” theme song via aria2, 8 threads, 2 M pre slice.

1
yt-dlp --external-downloader aria2c --downloader-args aria2c:"-x 8 -k 2M" https://www.youtube.com/watch?v=nOj_A3aZxGs

2.2.4 Live

In YouTube, Live and video are the same, maybe we want download a private Live, for instance, recoder-man or mark it for future study.

1
yt-dlp --live-from-start [url]

But sometimes yt-dlp may fail to download, so I recommend using ytarchive .

1
ytarchive -w [url] best

The best means the best ability for the live. ytarchive will download live form start by default.

2.3 GUI

If you really don’t want to use the command line, you can use this yt-dlp gui , but it lacks a lot of features. For example, through aira2 multi-threaded download.

3. Other Tools

Here are some useful tools for download

Name Paltform Remark
bilidown All only for Bilibili , depends on youtube-dl
Downie macOS
IDM Windows
Jable TV Download All Download Jable video
NDM Windows & macOS Open souce IMD alternative
youtube-dl All Not updated for a long time

I don’t recommend using youtube-dl to download YouTube videos, the speed is very slow, always no more than 70 k/s, and not updated for a long time.

Summary

This is how I download videos, if you master these, you can download 99% of videos.

I want to tell you that streaming media is a scam, only downloaded to your hard disk, it really belongs to you, completely under your control, no ads, no censorship…