Linux 下載 YouTube 影片

📢 本文由 gemini-3-flash-preview 翻譯

前言

既然都有 Win 命令列了,那怎麼能沒有 Linux 呢?

Windows 的文章: 命令列下載 YouTube 影片

下載 yt-dlp

建議配置好 Python 環境,然後到 Releases · yt-dlp/yt-dlp · GitHub 下載 yt-dlp,如果不想配置 Python 就下載 yt-dlp_linux

下載完成後賦予執行權限並放在 /usr/local/bin/ 下。

下載 FFmpeg

參考官網 Download FFmpeg

Fedora 下使用以下命令:

1
sudo dnf install ffmpeg

設定檔

切換設定目錄:

1
cd ~/.config

建立資料夾並進入:

1
2
mkdir yt-dlp
cd yt-dlp

建立設定檔:

1
vi config

我的設定檔如下:

1
-f bv+ba/b -o ~/Videos/%(uploader)s/%(upload_date)s%(title)s%(id)s.%(ext)s --continue --merge-output-format mp4

說明一下:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
-f bv+ba/b # 最高畫質與音訊

-o # 輸出資料夾設定
/%(uploader)s/ # 依頻道名稱建立資料夾
%(upload_date)s # 上傳時間
%(title)s # 影片標題
%(id)s # 影片 ID
.%(ext)s # 影片副檔名

--continue # 斷點續傳

--merge-output-format mp4 # 合併為 mp4 影片

參考文章

FFmpeg 批次轉換影片格式 話說自己的文章有必要放連結嗎

This post is licensed under CC BY-NC-SA 4.0 by the author.