← 返回命令列表

Linux command

youtube-dl 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Download a video

youtube-dl "[url]"

Download audio only

youtube-dl -x --audio-format mp3 "[url]"

List available formats

youtube-dl -F "[url]"

Download a specific format

youtube-dl -f [format_code] "[url]"

Download a playlist

youtube-dl "[playlist_url]"

Download with custom filename

youtube-dl -o "%(title)s.%(ext)s" "[url]"

Download subtitles

youtube-dl --write-sub --sub-lang [en] "[url]"

Resume a partial download

youtube-dl -c "[url]"

说明

youtube-dl is a command-line program to download videos from YouTube and hundreds of other video platforms. It supports playlists, channels, and individual videos, with options for format selection, audio extraction, and subtitle downloading. The output filename can be customized using templates with metadata variables. Configuration options can be stored in ~/.config/youtube-dl/config or /etc/youtube-dl.conf for persistent settings. The tool requires Python and works on Linux, macOS, and Windows.

参数

-f, --format _format_
Video format code. Use -F to list available formats.
-F, --list-formats
List all available formats for the video.
-o, --output _template_
Output filename template with variables like %(title)s, %(ext)s.
-x, --extract-audio
Extract audio track only.
--audio-format _format_
Audio format for extraction: mp3, aac, flac, wav, etc.
--audio-quality _quality_
Audio quality: 0 (best) to 9 (worst), or specific bitrate.
-a, --batch-file _file_
Read URLs from a file (one per line).
-c, --continue
Resume partially downloaded files.
-i, --ignore-errors
Continue on errors (useful for playlists).
--playlist-start _num_
Start playlist at video number.
--playlist-end _num_
End playlist at video number.
--write-sub
Download subtitles.
--sub-lang _langs_
Subtitle languages to download.
-j, --dump-json
Print video info as JSON without downloading.
--cookies _FILE_
Read cookies from a Netscape cookie file for authenticated access.
--proxy _URL_
Use specified HTTP/HTTPS/SOCKS proxy.
--geo-bypass
Bypass geographic restriction via faking X-Forwarded-For header.
-u _USER_, --username _USER_
Login with account username.
-p _PASS_, --password _PASS_
Login with account password.
-v, --verbose
Print debug information.
-h, --help
Display help message.

FAQ

What is the youtube-dl command used for?

youtube-dl is a command-line program to download videos from YouTube and hundreds of other video platforms. It supports playlists, channels, and individual videos, with options for format selection, audio extraction, and subtitle downloading. The output filename can be customized using templates with metadata variables. Configuration options can be stored in ~/.config/youtube-dl/config or /etc/youtube-dl.conf for persistent settings. The tool requires Python and works on Linux, macOS, and Windows.

How do I run a basic youtube-dl example?

Run `youtube-dl "[url]"` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -f, --format _format_ do in youtube-dl?

Video format code. Use -F to list available formats.