Yt-dlp Commands: The Complete Tutorial For Beginners (2024)
https://ostechnix.com/yt-dlp-tutorial/
yt-dlp is a free and open-source command-line tool that can be used to download videos from YouTube and other video hosting websites.
yt-dlp is a fork of the now-discontinued youtube-dl, with the goal of adding new features and patches while also staying compatible with the original projectls -l.
It supports a wide range of video and audio formats, and it can also be used to download subtitles and metadata. yt-dlp is available for Windows, macOS, and Linux.
The Officially Recommended Way to Install yt-dlp
sudo curl -L https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp -o ~/bin/yt-dlp
sudo wget https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp -O ~/bin/yt-dlp
python3 -m pip install -U yt-dlp
python3 -m pip install -U pip setuptools wheel
Display All Available Video or Playlist Formats
yt-dlp -F <URL>
Download a Video with Description, Metadata, Annotations, Subtitles, and Thumbnail
yt-dlp --write-description --write-info-json --write-annotations --write-sub --write-thumbnail <URL>

Moving from left to right, this display includes essential details such as
- ID,
- Extension (EXT),
- Resolution,
- Frames Per Second (FPS),
- Channel (CH),
- Filesize,
- Total Bitrate (TBR),
- Protocol (PROTO),
- Video Codec (VCODEC),
- Video Bitrate (VBR),
- Audio Codec (ACODEC),
- Audio Bitrate (ABR),
- Audio Sampling Rate (ASR),
- and additional information.
Download Videos in Specific Quality and Format
By default, yt-dlp will download videos in the best available quality if you don’t pass any options. However, you have the flexibility to download a video or playlist in a specific quality or format as per your preferences.
YouTube offers the following quality options for video downloads:
- best: This selects the highest quality format available, including both video and audio.
- worst: It picks the lowest quality format for both video and audio.
- bestvideo: This option selects the best quality video-only format (e.g., DASH video).
- worstvideo: Similar to bestvideo but chooses the lowest quality video-only format.
- bestaudio: This selects the best quality audio-only format.
- worstaudio: Similar to bestaudio but chooses the lowest quality audio-only format.
You can even download a video or playlist in a specific quality with a defined resolution. For example, to download the best quality video with a resolution of 480 pixels or lower (less than or equal to 480p), use this command:
yt-dlp -f "best[height<=480]" <URL>
yt-dlp -f 'bestvideo[height<=480]+bestaudio/best[height<=480]' <URL>
To download video(s) in your preferred format, such as MP4, simply execute the following command:
yt-dlp -f mp4 -o filename <URL>
yt-dlp -f 22 -o filename <URL>
You can use the -f- flag to interactively select the format for each video. This will prompt you with a list of available formats, along with their ID, extension, resolution, file size, and audio/video codec.
To download a specific format, type the ID of the file and press Enter.
if you wish to download multiple formats of the same video, you can use a comma as a separator. For example, using -f 22,17,18 will download all three of these formats, provided they are available.
Download from ArteTV
yt-dlp with an ArteTV link. By default, Arte provides separate video, audio, and subtitle streams, so you need to explicitly tell yt-dlp to grab subtitles and merge them into the video.
yt-dlp --list-subs URL
to see all available subtitle languagesDownload YouTube Video using youtube-dl
Project page at https://github.com/rg3/youtube-dl
Install youtube-dl command line application sudo pip install -U youtube-dl
IF you get Avconv warning while downloading YouTube video Your copy of avconv is outdated, update avconv to version 10-0 or newer if you encounter any errors. Then check version of avcon with avconv 2>&1| grep version | awk ‘{print $3}’ and update accordingly with sudo add-apt-repository ppa:heyarje/libav-11 && sudo apt-get update sudo apt-get install libav-tools
By default youtube-dl uses avconv, but you can tell it to use ffmpeg instead.
youtube-dl -f 137+140 —prefer-ffmpeg
Help youtube-dl —help
Get the hyperlink from the Share button http://youtu.be/98j7K_wgWgg
Download youtube-dl http://youtu.be/98j7K_wgWgg or simply youtube-dl 98j7K_wgWgg
To see available formats for the video add the -F parameter e.g.
youtube-dl xjDLakFBzWM -F
and then
youtube-dl xjDLakFBzWM -f 18 -o The_Joy_of_Data-BBC_Documentary-2016.mp4
To save the output with the title youtube-dl 98j7K_wgWgg -o ”%(title)s”
-rw-rw-r— 1 athanbuntu athanbuntu 113227793 Feb 2 2014 Μια φορά κι έναν καιρό ήταν ο άνθρωπος-01.mp4
Select mp4 format represented by a single file with the title and extention youtube-dl 98j7K_wgWgg -o ”%(title)s.%(ext)s” -f mp4
Extract title, duration, description, id, thumbnail, format youtube-dl -e —get-duration —get-description —get-id —get-thumbnail —get-format 98j7K_wgWgg
Μια φορά κι έναν καιρό ήταν ο άνθρωπος-01 98j7K_wgWgg https://i.ytimg.com/vi/98j7K_wgWgg/hqdefault.jpg Η Γη Γεννιέται 25:50 134 - 476x360 (DASH video)+141 - audio only (DASH audio)
Simulate download of three videos from a playlist with the -s option youtube-dl PLKVEvWID_1-1Rwx6T8h4UMbFKS-TB7WHo -s —playlist-items “2-4” [youtube:playlist] PLKVEvWID_1-1Rwx6T8h4UMbFKS-TB7WHo: Downloading webpage [download] Downloading playlist: Μια φορά κι έναν καιρό ήταν ο άνθρωπος [youtube:playlist] playlist Μια φορά κι έναν καιρό ήταν ο άνθρωπος: Downloading 3 videos [download] Downloading video 1 of 3
Download three videos from a playlist with title, video id and format extension youtube-dl PLKVEvWID_1-1Rwx6T8h4UMbFKS-TB7WHo —playlist-items “2-4” -o ”%(title)s-%(id)s.%(ext)s” -f mp4
Download video with subtitles youtube-dl https://youtu.be/LsExPrHCHbw —write-sub —embed-subs —sub-lang en_US,en-US,en -f 22 -o prof_sucharit_open_letter.mp4
You can leave out the —sub-lang option and it will grab the first subtitle it finds —sub-lang LANGS Languages of the subtitles to download (optional) separated by commas, use IETF language tags like ‘en,pt’ —all-subs Download all the available subtitles of the video —list-subs List all available subtitles for the video
Also when playing the captioned video, you have to turn on/switch subtitle tracks because it will not be on by default.
