Difference between revisions of "Youtube-dl"

From ArchWiki
Jump to: navigation, search
(Remove archive note, see talk)
(Tips and tricks: added tip for a bash alias)
 
Line 64: Line 64:
  
 
Parts of [[wikipedia:Dynamic_Adaptive_Streaming_over_HTTP|DASH]] videos can be downloaded by using the output of {{ic|youtube-dl -g -f ''format'' ''URL''}} as ''ffmpeg'' input with the {{ic|-ss}}, {{ic|-t}} and {{ic|-c copy}} [http://ffmpeg.org/ffmpeg.html#Main-options options].
 
Parts of [[wikipedia:Dynamic_Adaptive_Streaming_over_HTTP|DASH]] videos can be downloaded by using the output of {{ic|youtube-dl -g -f ''format'' ''URL''}} as ''ffmpeg'' input with the {{ic|-ss}}, {{ic|-t}} and {{ic|-c copy}} [http://ffmpeg.org/ffmpeg.html#Main-options options].
 +
 +
=== Alias to download url from xclip ===
 +
 +
You can set an alias in {{ic|~/.bashrc}} or {{ic|~/.zshrc}} to download a video/audio file from a url in the clipboard. For example:
 +
 +
    alias yt='youtube-dl "$(xclip -o)"'
  
 
== See also ==
 
== See also ==
  
 
* [https://github.com/rg3/youtube-dl GitHub repository] for documentation.
 
* [https://github.com/rg3/youtube-dl GitHub repository] for documentation.

Latest revision as of 20:46, 12 August 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.

Usage

See the youtube-dl(1) man page.

$ youtube-dl [OPTIONS] URL

Format selection

In cases where multiple formats of a video are available, youtube-dl will default to downloading the best possible version. If you'd like to choose a specific format 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

You can often download audio-only or video-only formats this way. If you have FFmpeg, you can download both a video-only and audio-only format and mux them together into a single file:

$ youtube-dl -f video_format+audio_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. See the youtube-dl(1) man page for supported options. 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

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 -x 5 -k 2M' URL

Trim

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.

Alias to download url from xclip

You can set an alias in ~/.bashrc or ~/.zshrc to download a video/audio file from a url in the clipboard. For example:

    alias yt='youtube-dl "$(xclip -o)"'

See also