Difference between revisions of "Youtube-dl"

From ArchWiki
Jump to: navigation, search
m (Format selection: rw)
m (Format selection: rw)
(One intermediate revision by the same user not shown)
Line 26: Line 26:
 
In cases where multiple formats of a video are available, youtube-dl will download the best ones by default.
 
In cases where multiple formats of a video are available, youtube-dl will download the best ones by default.
  
If you'd like to choose a specific format to download, first get a list of the available formats:
+
If you'd like to choose a specific one to download, first get a list of the available formats:
  
 
  $ youtube-dl -F ''URL''
 
  $ youtube-dl -F ''URL''
Line 60: Line 60:
 
Some websites throttle download speeds. You can often increase speeds by using [[Aria2]], an external downloader which supports multi-connection downloads. Example:
 
Some websites throttle download speeds. You can often increase speeds by using [[Aria2]], an external downloader which supports multi-connection downloads. Example:
  
  $ youtube-dl --external-downloader aria2c --external-downloader-args '-c -x 5 -k 2M' ''URL''
+
  $ youtube-dl --external-downloader aria2c --external-downloader-args '-c -j 3 -x 3 -s 3 -k 1M' ''URL''
  
 
=== Trim (partial download) ===
 
=== Trim (partial download) ===

Revision as of 10:35, 9 October 2018

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 youtube-dl package, or youtube-dl-gitAUR for the development version. It is recommended to also install ffmpeg as it is used for muxing for some sites.

Usage

See youtube-dl(1).

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

Format selection

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

If you'd like to choose a specific one to download, first get a list of the available formats:

$ youtube-dl -F URL

Note the format code for the version you want, and then run:

$ youtube-dl -f format URL

Extract audio

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

$ youtube-dl -x -f bestaudio URL

Configuration

The system-wide configuration file is /etc/youtube-dl.conf and the user-specific configuration file is ~/.config/youtube-dl/config. The syntax is simply one command-line option per line. Example configuration:

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

# Prefer 1080p or lower resolutions
-f (bestvideo[height<=1080]/bestvideo)+bestaudio/best[height<=1080]/best

See [1] for more information.

Tips and tricks

Increasing download speeds

Some websites throttle download speeds. You can often increase speeds by using Aria2, an external downloader which supports multi-connection downloads. Example:

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

Trim (partial download)

Parts of DASH videos can be downloaded by using the output of youtube-dl -g -f format URL as ffmpeg input with the -ss, -t and -c copy options.

URL from clipboard

A shell alias 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.

See also