Featured image of post yt-dlp 指定下載影片畫質

yt-dlp 指定下載影片畫質

↩️回總教學文

選擇畫質

yt-dlp 預設會下載最高畫質的版本,不一定是 mp4 格式

列出可下載的畫質:

>_ terminal
 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
\$ yt-dlp -F https://www.youtube.com/watch?v=dQw4w9WgXcQ
[youtube] dQw4w9WgXcQ: Downloading webpage
[info] Available formats for dQw4w9WgXcQ:
format code  extension  resolution note
249          webm       audio only tiny   46k , webm_dash container, opus @ 46k (48000Hz), 1.18MiB
250          webm       audio only tiny   61k , webm_dash container, opus @ 61k (48000Hz), 1.55MiB
140          m4a        audio only tiny  129k , m4a_dash container, mp4a.40.2@129k (44100Hz), 3.27MiB
251          webm       audio only tiny  129k , webm_dash container, opus @129k (48000Hz), 3.28MiB
394          mp4        256x144    144p   68k , mp4_dash container, av01.0.00M.08@  68k, 25fps, video only, 1.72MiB
160          mp4        256x144    144p   71k , mp4_dash container, avc1.4d400c@  71k, 25fps, video only, 1.81MiB
278          webm       256x144    144p   89k , webm_dash container, vp9@  89k, 25fps, video only, 2.27MiB
133          mp4        426x240    240p  117k , mp4_dash container, avc1.4d4015@ 117k, 25fps, video only, 2.96MiB
395          mp4        426x240    240p  134k , mp4_dash container, av01.0.00M.08@ 134k, 25fps, video only, 3.40MiB
242          webm       426x240    240p  159k , webm_dash container, vp9@ 159k, 25fps, video only, 4.02MiB
134          mp4        640x360    360p  219k , mp4_dash container, avc1.4d401e@ 219k, 25fps, video only, 5.55MiB
396          mp4        640x360    360p  262k , mp4_dash container, av01.0.01M.08@ 262k, 25fps, video only, 6.64MiB
243          webm       640x360    360p  273k , webm_dash container, vp9@ 273k, 25fps, video only, 6.92MiB
135          mp4        854x480    480p  337k , mp4_dash container, avc1.4d401e@ 337k, 25fps, video only, 8.52MiB
244          webm       854x480    480p  397k , webm_dash container, vp9@ 397k, 25fps, video only, 10.04MiB
397          mp4        854x480    480p  450k , mp4_dash container, av01.0.04M.08@ 450k, 25fps, video only, 11.38MiB
136          mp4        1280x720   720p  655k , mp4_dash container, avc1.4d401f@ 655k, 25fps, video only, 16.57MiB
247          webm       1280x720   720p  699k , webm_dash container, vp9@ 699k, 25fps, video only, 17.67MiB
398          mp4        1280x720   720p  858k , mp4_dash container, av01.0.05M.08@ 858k, 25fps, video only, 21.70MiB
399          mp4        1920x1080  1080p 1576k , mp4_dash container, av01.0.08M.08@1576k, 25fps, video only, 39.84MiB
137          mp4        1920x1080  1080p 3546k , mp4_dash container, avc1.640028@3546k, 25fps, video only, 89.64MiB
18           mp4        640x360    360p  630k , avc1.42001E, 25fps, mp4a.40.2 (44100Hz), 15.95MiB (best)

選好要下載的格式,把 format code 填入參數 -f 裡

>_ terminal
1
yt-dlp -f 137 https://www.youtube.com/watch?v=dQw4w9WgXcQ

1920x1080 影片 + 129K音軌 (需要先裝 ffmpeg)

>_ terminal
1
yt-dlp -f "137+140" https://www.youtube.com/watch?v=dQw4w9WgXcQ

如果懶得查,也可以直接指定某種影片、音樂最高品質

下載 MP4 格式中最高畫質,或是其他格式中的最高畫質

>_ terminal
1
yt-dlp -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best' url

指定最佳畫質,但不要高於 480p

>_ terminal
1
yt-dlp -f 'bestvideo[height<=480]+bestaudio/best[height<=480]' url

下載檔案大小小於 50M 的最高畫質影片

>_ terminal
1
yt-dlp -f 'best[filesize<50M]' url

指定格式、品質時,若網站沒有該格式會下載失敗

↩️回總教學文

使用 Hugo 建立
主題 StackJimmy 設計