Skip to content

Unlock the Full Potential of yt-dlp: Comprehensive Guide and Advanced Techniques

yt-dlp provides a variety of commands and options that you can use to extract information about videos or to customize your downloads. Explore advanced techniques to optimize your video downloading workflow.

Download Zara Larsson with Enforcment highest quality (4K)

yt-dlp -f "bestvideo[height=2160]+bestaudio/best[height=2160]" -o "%(title)s.%(ext)s" https://www.youtube.com/watch?v=t_Ns0r02iik

Discover the available formats for a specific video and choose the one that best suits your needs.

List avialable formats for an url

yt-dlp --list-formats https://www.youtube.com/watch?v=f-_93i5Yy38
[youtube] Extracting URL: https://www.youtube.com/watch?v=f-_93i5Yy38
[youtube] f-_93i5Yy38: Downloading webpage
[youtube] f-_93i5Yy38: Downloading ios player API JSON
[youtube] f-_93i5Yy38: Downloading android player API JSON
[youtube] f-_93i5Yy38: Downloading m3u8 information
[info] Available formats for f-_93i5Yy38:
ID  EXT   RESOLUTION FPS CH     FILESIZE  TBR PROTO  VCODEC         VBR ACODEC      ABR ASR MORE INFO
───────────────────────────────────────────────────────────────────────────────────────────────────────────────
sb3 mhtml 48x27        1                      mhtml  images                                 storyboard
sb2 mhtml 60x45        1                      mhtml  images                                 storyboard
sb1 mhtml 120x90       1                      mhtml  images                                 storyboard
sb0 mhtml 240x180      1                      mhtml  images                                 storyboard
233 mp4   audio only                          m3u8   audio only         unknown             Default
234 mp4   audio only                          m3u8   audio only         unknown             Default
139 m4a   audio only      2    643.49KiB  48k https  audio only         mp4a.40.5   48k 22k low, m4a_dash
249 webm  audio only      2   1005.18KiB  76k https  audio only         opus        76k 48k low, webm_dash
250 webm  audio only      2      1.15MiB  89k https  audio only         opus        89k 48k low, webm_dash
140 m4a   audio only      2      1.67MiB 129k https  audio only         mp4a.40.2  129k 44k medium, m4a_dash
251 webm  audio only      2      1.82MiB 140k https  audio only         opus       140k 48k medium, webm_dash
17  3gp   176x144     12  1    903.28KiB  68k https  mp4v.20.3          mp4a.40.2       22k 144p
269 mp4   192x144     13     ~   2.34MiB 176k m3u8   avc1.4D400C   176k video only
160 mp4   192x144     13         1.36MiB 105k https  avc1.4D400C   105k video only          144p, mp4_dash
603 mp4   192x144     25     ~   1.48MiB 111k m3u8   vp09.00.11.08 111k video only
278 webm  192x144     25       422.23KiB  32k https  vp09.00.11.08  32k video only          144p, webm_dash
229 mp4   320x240     25     ~   4.66MiB 350k m3u8   avc1.4D400D   350k video only
133 mp4   320x240     25         2.82MiB 218k https  avc1.4D400D   218k video only          240p, mp4_dash
604 mp4   320x240     25     ~   2.54MiB 191k m3u8   vp09.00.20.08 191k video only
242 webm  320x240     25       645.08KiB  49k https  vp09.00.20.08  49k video only          240p, webm_dash
230 mp4   480x360     25     ~   5.95MiB 447k m3u8   avc1.4D4015   447k video only
134 mp4   480x360     25         1.60MiB 124k https  avc1.4D4015   124k video only          360p, mp4_dash
18  mp4   480x360     25  2     3.33MiB 250k https  avc1.42001E        mp4a.40.2       44k 360p
605 mp4   480x360     25     ~   5.00MiB 376k m3u8   vp09.00.21.08 376k video only
243 webm  480x360     25       916.84KiB  69k https  vp09.00.21.08  69k video only          360p, webm_dash
231 mp4   640x480     25     ~   9.99MiB 751k m3u8   avc1.4D401E   751k video only
135 mp4   640x480     25         3.19MiB 247k https  avc1.4D401E   247k video only          480p, mp4_dash
606 mp4   640x480     25     ~   8.26MiB 621k m3u8   vp09.00.30.08 621k video only
244 webm  640x480     25         1.47MiB 113k https  vp09.00.30.08 113k video only          480p, webm_dash

Customization Options

Command Options Description
–list-formats or -F This command lists all available formats for the video.
–write-description Saves the video description to a .description file.
–write-info-json Writes video metadata to a JSON file.
–write-annotations Writes video annotations to an .annotations.xml file.
–write-thumbnail Downloads the video thumbnail image.
–write-sub Downloads the subtitle file(s) if available.
–all-subs Downloads all the available subtitles of the video.
–skip-download Retrieves all information (like descriptions, thumbnails, subtitles) without downloading the video.
–print-json Prints video metadata in JSON format to the console instead of downloading.
–get-description Gets video description and prints it to the console.
–get-thumbnail Prints the URL of the thumbnail to the console.
–get-title Prints the video title to the console.
–get-id Prints the video ID to the console.
–get-duration Prints the video duration in seconds to the console.
–get-filename Prints the final filename (after all processing) to the console.
–get-format Prints the format string that will be used for downloading to the console.

Audio Extraction

  • If you prefer a different format, like the WEBM format with a bitrate of 140kbps
yt-dlp -f 251 https://www.youtube.com/watch?v=f-_93i5Yy38
  • Here is a simple command in yt-dlp to always pick the highest quality audio available and extract it
yt-dlp -x --audio-format opus -o "%(title)s.%(ext)s" "URL" && \
for f in *.opus; do \
  newname=$(echo "$f" | sed -e 's/ /_/g' -e 's/_-_/ - /g' -e 's/\[[^][]*\]//g' -e 's/__*/_/g' -e 's/_\.opus$/.opus/' | tr '[:upper:]' '[:lower:]'); \
  mv -- "$f" "$newname"; \
done

Video Download

  • To download the best available video quality using yt-dlp, you can use the bestvideo argument.
yt-dlp -f bestvideo+bestaudio --merge-output-format mkv "URL"
  • Download videos with the best available quality or specify a specific resolution, like 720p.
yt-dlp -f 'bestvideo[height<=720]+bestaudio/best' --merge-output-format mp4 "URL"