Skip to content

Enhance Your Video Downloading Experience with youtube-dl: Advanced Techniques

Unlock the full potential of youtube-dl with advanced techniques. Explore methods to download specific segments of videos and parallel download playlists.


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

Download Video and extract only a specific time of it

  • -ss 00:10 → seek to 10 seconds
  • -t 00:10 → extract 10 seconds (ends at 00:20)
  • -c copy → no re-encoding (fast, lossless)
ffmpeg -ss 00:10 -i "$(yt-dlp -g 'https://de.pornhub.com/view_video.php?viewkey=ph637366806d6eb')" \
   -t 00:10 -c copy out.mp4

Parallel downloading playlists

youtube-dl --get-id "$PLAYLIST_URL" | xargs -I '{}' -P 5 youtube-dl 'https://youtube.com/watch?v={}'

Listing and Selecting Available Video Formats with yt-dlp

$ yt-dlp --list-formats 'https://www.youtube.com/watch?v=c6rP-YP4c5I'
[youtube] Extracting URL: https://www.youtube.com/watch?v=c6rP-YP4c5I
[youtube] c6rP-YP4c5I: Downloading webpage
[youtube] c6rP-YP4c5I: Downloading tv client config
[youtube] c6rP-YP4c5I: Downloading tv player API JSON
[youtube] c6rP-YP4c5I: Downloading ios player API JSON
[youtube] c6rP-YP4c5I: Downloading player afc53320-player_es6_vflset_en_US_base
WARNING: [youtube] c6rP-YP4c5I: Signature extraction failed: Some formats may be missing
WARNING: [youtube] c6rP-YP4c5I: Some web client https formats have been skipped as they are missing a url. YouTube is forcing SABR streaming for this client. See  https://github.com/yt-dlp/yt-dlp/issues/12482  for more details
[youtube] c6rP-YP4c5I: Downloading m3u8 information
[info] Available formats for c6rP-YP4c5I:
ID  EXT   RESOLUTION FPS    FILESIZE   TBR PROTO  VCODEC          VBR ACODEC     MORE INFO
────────────────────────────────────────────────────────────────────────────────────────────────
sb3 mhtml 48x27        0                   mhtml  images                         storyboard
sb2 mhtml 80x45        1                   mhtml  images                         storyboard
sb1 mhtml 160x90       1                   mhtml  images                         storyboard
sb0 mhtml 320x180      1                   mhtml  images                         storyboard
233 mp4   audio only                       m3u8   audio only          unknown    Default, low
234 mp4   audio only                       m3u8   audio only          unknown    Default, high
602 mp4   256x144     12  ~  2.08MiB   86k m3u8   vp09.00.10.08   86k video only
269 mp4   256x144     24  ~  4.06MiB  169k m3u8   avc1.4D400C    169k video only
603 mp4   256x144     24  ~  3.97MiB  165k m3u8   vp09.00.11.08  165k video only
229 mp4   426x240     24  ~  7.45MiB  310k m3u8   avc1.4D4015    310k video only
604 mp4   426x240     24  ~  7.22MiB  300k m3u8   vp09.00.20.08  300k video only
230 mp4   640x360     24  ~ 18.72MiB  777k m3u8   avc1.4D401E    777k video only
605 mp4   640x360     24  ~ 18.00MiB  748k m3u8   vp09.00.21.08  748k video only
231 mp4   854x480     24  ~ 27.04MiB 1123k m3u8   avc1.4D401E   1123k video only
606 mp4   854x480     24  ~ 27.71MiB 1151k m3u8   vp09.00.30.08 1151k video only
232 mp4   1280x720    24  ~ 36.62MiB 1521k m3u8   avc1.4D401F   1521k video only
609 mp4   1280x720    24  ~ 47.34MiB 1966k m3u8   vp09.00.31.08 1966k video only
270 mp4   1920x1080   24  ~112.95MiB 4691k m3u8   avc1.640028   4691k video only
614 mp4   1920x1080   24  ~ 72.91MiB 3028k m3u8   vp09.00.40.08 3028k video only
616 mp4   1920x1080   24  ~137.72MiB 5719k m3u8   vp09.00.40.08 5719k video only Premium

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

Download as "Artist - Title

yt-dlp -x --audio-format mp3 -o "%(track)s - %(artist)s.%(ext)s" https://www.youtube.com/watch?v=26tzRuurdgo&list=RD26tzRuurdgo&start_radio=1

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"