youtube-dl

youtube-dl is a command-line program that lets you easily download videos and audio from more than a thousand websites. See the list of supported sites.

Installation

Install the yt-dlp package, or yt-dlp-gitAUR for the development version. It is recommended to also install FFmpeg as it is used for muxing for some sites. See the optional dependencies.

There are also various graphical frontends to youtube-dl and/or yt-dlp, such as tartubeAUR and yt-dlg (youtube-dl-gui-gitAUR). You can also install yt-dlp-drop-inAUR which provides a fake executable (that just redirects to yt-dlp) for outdated programs that still look for a youtube-dl executable.

Configuration

The system-wide configuration file is and the user-specific configuration file is . The syntax is simply one command-line option per line. Example configuration:

--ignore-errors
# --no-playlist

# Save in ~/Videos
-o ~/Videos/%(title)s.%(ext)s

# Prefer 1080p or lower resolutions
-f bestvideo[ext=mp4][width<2000][height<=1200]+bestaudio[ext=m4a]/bestvideo[ext=webm][width<2000][height<=1200]+bestaudio[ext=webm]/bestvideo[width<2000][height<=1200]+bestaudio/best[width<2000][height<=1200]/best

See for more information.

Usage

See for the manual.

$ yt-dlp [OPTIONS] URL
Tip: In some cases (like YouTube) URL can be substituted with the video ID.

Format selection

When multiple formats of a video are available, youtube-dl will download the best ones by default.

To select a specific one to download:

$ yt-dlp -f format URL

To get a list of the available formats:

$ yt-dlp -F URL

Extract audio

Use -x for audio-only downloads (requires FFmpeg):

$ yt-dlp -x -f bestaudio URL

Depending on the available source streams, this will often correct the audio-only container. If an audio-only stream is not available, exclude from the example above. This will download the video and copy its audio as post process. By default this will remove the downloaded video, include to keep it.

To also include album art (requires ):

$ yt-dlp -x -f bestaudio[ext=m4a] --add-metadata --embed-thumbnail URL

Subtitles

To see which languages are available:

$ yt-dlp --list-subs URL

To download a video with selected subtitles (comma separated):

$ yt-dlp --write-sub --sub-lang LANG URL

For auto-generated subtitles:

$ yt-dlp --write-auto-sub --sub-lang LANG URL

Add to get only subtitles.

Tips and tricks

Faster downloads

Some websites throttle transfer speeds. You can often get around this by choosing non DASH streams or by using aria2, an external downloader which supports multi-connection downloads. For example:

$ yt-dlp --external-downloader aria2c --external-downloader-args '-c -j 3 -x 3 -s 3 -k 1M' URL

Playlist

Using youtube-dl for a playlist usually boils down to the following options:

$ yt-dlp --ignore-errors --continue --no-overwrites --download-archive progress.txt usual options URL

This set of options allow for the download to effectively continue even after interruption. If you are archiving, add the usual and options you may have.

Trim (partial download)

Parts of videos can be downloaded by using the output of as ffmpeg input with the (for input), and -c copy options.

URL from clipboard

A shell alias, a desktop launcher or a keyboard shortcut can be set to download a video (or audio) of a selected (or copied) URL by outputting it from the X selection. See Clipboard#Tools.

gollark: Why write essays when you can make GPT-3 write essays for you?
gollark: That does explain your extremely vague explanation of any of its properties.
gollark: I guess that makes sense because something something trade.
gollark: Oh, so it's meant to be "probability of surviving X years"? How is it actually computed?
gollark: How does that work?

See also

This article is issued from Archlinux. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.