Documentatie bekijken
Handleidingen
Kopieer opdrachten voor video, audio, ondertitels, datasets en het hervatten van verzamelingen.
Op deze pagina
Instelling en bestelling conventies
python -m pip install -U --pre "yt-dlp[default,curl-cffi]"
deno --version
ffmpeg -version
python -m yt_dlp --list-impersonate-targetsDe downloadrecepten gebruiken Deno en --impersonate="" als de basislijn. De laatste vereist curl-cffi en laat het kiezen van een beschikbare browser vingerafdruk. Linux/macOS bevelen Bash syntax te gebruiken; voor een geplande werknemer, ook deze afhankelijkheden beschikbaar maken in die service omgeving.
Deze terminal voorbeelden gebruiken de Python-installatie van yt-dlp. Gebruik uw virtuele omgeving Python, of vervang python -m yt_dlp met de standaard yt-dlp-bestelling. Gebruik Linux eerst, met macOS en Windows-alternatieven in de installatiedijl. Installeren FFmpeg/ffprobe voor de fusie en Deno voor YouTube challenge solving. Vervang de URL met uw bron.
| Conventie | Waarom het belangrijk is |
|---|---|
| URL's en templates verwijzen | De shell anders interpreteert karakters zoals &, ruimtes en parenteses. |
| %(ext)s in filenamen houden | De geselecteerde media en post-verwerking bepalen de uitbreiding. |
| Gebruik --no-playlist voor een url | Een video die is gekoppeld aan een playlist, mag uw werk niet onverwacht uitbreiden. |
| Controleer uw beveiligde configuratie | Voorbeelden kunnen een wereldwijde config erven. gebruik --ignore-config voor een geïsoleerde test. |
| Windows .bat: dubbele template percentage tekens | Gebruik %%(id)s in een setbestand, maar %(id)s in interactieve PowerShell en normale configuratiebestanden. |
Video kwaliteit en MP4
Base line: laatste nachtelijk, Deno en FFmpeg, met --impersonate="". De recepten gebruiken Bash; vervangen de URL van het voorbeeld met uw bron.
python -m yt_dlp --js-runtimes deno --impersonate="" --no-playlist -P downloads \
-o "%(id)s.%(ext)s" "https://www.youtube.com/watch?v=jNQXAC9IVRw"python -m yt_dlp --js-runtimes deno --impersonate="" --no-playlist \
-F "https://www.youtube.com/watch?v=jNQXAC9IVRw"python -m yt_dlp --js-runtimes deno --impersonate="" --no-playlist -S "res:1080" \
"https://www.youtube.com/watch?v=jNQXAC9IVRw"python -m yt_dlp --js-runtimes deno --impersonate="" --no-playlist \
-f "bv*[height<=1080]+ba/b[height<=1080]" "https://www.youtube.com/watch?v=jNQXAC9IVRw"python -m yt_dlp --js-runtimes deno --impersonate="" --no-playlist \
-f "bv[vcodec^=avc1][height<=1080]+ba[acodec^=mp4a]/b[vcodec^=avc1][acodec^=mp4a][height<=1080]" \
--merge-output-format mp4 "https://www.youtube.com/watch?v=jNQXAC9IVRw"AI-dataset: MP4 + capties + metadata
python -m yt_dlp --js-runtimes deno --impersonate="" --no-playlist \
-f "bestvideo+bestaudio/best" --merge-output-format mp4 --remux-video mp4 \
--write-info-json --write-subs --write-auto-subs --sub-langs "en" --sub-format "vtt/best" \
--sleep-subtitles 5 --concurrent-fragments 1 -P dataset -o "%(id)s/%(id)s.%(ext)s" \
"https://www.youtube.com/watch?v=jNQXAC9IVRw"Externe downloader: aria2c
python -m yt_dlp --js-runtimes deno --impersonate="" --no-playlist --downloader aria2c \
--downloader "dash,m3u8:native" --downloader-args "aria2c:-x 2 -s 2 -j 1" \
--concurrent-fragments 1 -P downloads "https://www.youtube.com/watch?v=jNQXAC9IVRw"aria2 heeft zijn eigen netwerkimplementatie. yt-dlp's curl-cffi-impersoonlijn configureert aria2's vingerdruk niet. Als alleen de externe downloader mislukt, gebruik --downloader native en vergelijk dezelfde bron en proxy route.
Audio en MP3
python -m yt_dlp --js-runtimes deno --impersonate="" --no-playlist -f ba -P audio \
-o "%(id)s.%(ext)s" "https://www.youtube.com/watch?v=jNQXAC9IVRw"python -m yt_dlp --js-runtimes deno --impersonate="" --no-playlist -f ba -x \
--audio-format mp3 --audio-quality 192K -P audio \
"https://www.youtube.com/watch?v=jNQXAC9IVRw"python -m yt_dlp --js-runtimes deno --impersonate="" --no-playlist -f "ba[ext=m4a]" -P audio \
"https://www.youtube.com/watch?v=jNQXAC9IVRw"python -m yt_dlp --js-runtimes deno --impersonate="" --no-playlist -f ba -x \
--audio-format mp3 --embed-metadata --embed-thumbnail -P audio \
"https://www.youtube.com/watch?v=jNQXAC9IVRw"Capties en subtitels
python -m yt_dlp --js-runtimes deno --impersonate="" --no-playlist \
--list-subs "https://www.youtube.com/watch?v=jNQXAC9IVRw"python -m yt_dlp --js-runtimes deno --impersonate="" --skip-download --write-subs \
--sub-langs "en.*" --sub-format "vtt/best" -P captions -o "%(id)s.%(ext)s" \
"https://www.youtube.com/watch?v=jNQXAC9IVRw"python -m yt_dlp --js-runtimes deno --impersonate="" --skip-download --write-subs \
--write-auto-subs --sub-langs "en.*" --sub-format "vtt/best" -P captions \
-o "%(id)s.%(ext)s" "https://www.youtube.com/watch?v=jNQXAC9IVRw"python -m yt_dlp --js-runtimes deno --impersonate="" --skip-download --write-subs \
--write-auto-subs --sub-langs "en" --convert-subs srt -P captions \
"https://www.youtube.com/watch?v=jNQXAC9IVRw"python -m yt_dlp --js-runtimes deno --impersonate="" --write-subs --sub-langs "en" \
--embed-subs --remux-video mkv -P downloads "https://www.youtube.com/watch?v=jNQXAC9IVRw"Het aanvragen van alle opname talen kan het aantal verzoeken en bestanden aanzienlijk verhogen. Houd de aangevraagde talen uitdrukkelijk voor routinewerk. Bewaar de bron-ID en taal in uw dataset-inventory zodat transcripten niet worden afgescheiden van de media die ze beschrijven.
Metadata en outputpaden
python -m yt_dlp --js-runtimes deno --impersonate="" --no-playlist \
--dump-json "https://www.youtube.com/watch?v=jNQXAC9IVRw" > video.jsonpython -m yt_dlp --js-runtimes deno --impersonate="" --skip-download --write-info-json \
-P metadata -o "%(id)s.%(ext)s" "https://www.youtube.com/watch?v=jNQXAC9IVRw"python -m yt_dlp --js-runtimes deno --impersonate="" --skip-download --write-thumbnail \
-P thumbnails -o "%(id)s.%(ext)s" "https://www.youtube.com/watch?v=jNQXAC9IVRw"python -m yt_dlp --js-runtimes deno --impersonate="" --no-playlist \
--print after_move:filepath -P downloads -o "%(id)s.%(ext)s" \
"https://www.youtube.com/watch?v=jNQXAC9IVRw"python -m yt_dlp --js-runtimes deno --impersonate="" --no-playlist \
--print-to-file after_move:filepath completed-paths.txt -P downloads \
"https://www.youtube.com/watch?v=jNQXAC9IVRw"Tijd Rangen en hoofdstukken
python -m yt_dlp --js-runtimes deno --impersonate="" --no-playlist \
--download-sections "*00:00:05-00:00:10" -o "clips/%(id)s-%(section_start)s.%(ext)s" \
"https://www.youtube.com/watch?v=jNQXAC9IVRw"python -m yt_dlp --js-runtimes deno --impersonate="" --no-playlist \
--download-sections "*00:00:05-00:00:10" --force-keyframes-at-cuts \
-o "clips/%(id)s-%(section_start)s.%(ext)s" "https://www.youtube.com/watch?v=jNQXAC9IVRw"python -m yt_dlp --split-chapters -o "chapter:%(id)s-%(section_number)03d.%(ext)s" \
"https://www.youtube.com/watch?v=YOUR_VIDEO_ID"Gebruik een andere output- of archief voor clips en volledige video's. Een bron-niveau archief invoer codert niet de geselecteerde start/end tijden, dus één gedeelde archief kan een later clip die u bedoeld is om te maken te verwijderen.
Playlisten en URL's
python -m yt_dlp --no-playlist --batch-file urls.txt -P collection -o "%(id)s.%(ext)s"python -m yt_dlp --flat-playlist \
--dump-json "https://www.youtube.com/playlist?list=YOUR_PLAYLIST_ID" > playlist.jsonlpython -m yt_dlp --playlist-items 1:5 -P collection -o "%(playlist_index)03d-%(id)s.%(ext)s" \
"https://www.youtube.com/playlist?list=YOUR_PLAYLIST_ID"python -m yt_dlp --dateafter 20260101 --match-filters "!is_live & duration <= 1800" \
--batch-file urls.txtpython -m yt_dlp --download-archive archive.txt --max-downloads 10 --batch-file urls.txtArchief en herstel
python -m yt_dlp --download-archive archive.txt --continue --no-abort-on-error -P collection \
-o "%(id)s.%(ext)s" --batch-file urls.txtpython -m yt_dlp --sleep-requests 1 --sleep-interval 5 --max-sleep-interval 10 --retries 3 \
--fragment-retries 3 --socket-timeout 30 --batch-file urls.txtpython -m yt_dlp --js-runtimes deno --impersonate="" --limit-rate 2M \
"https://www.youtube.com/watch?v=jNQXAC9IVRw"python -m yt_dlp --js-runtimes deno --impersonate="" --concurrent-fragments 1 \
"https://www.youtube.com/watch?v=jNQXAC9IVRw"Configuratie en filenamen
python -m yt_dlp --ignore-config --config-locations yt-dlp-work.conf --batch-file urls.txtpython -m yt_dlp --js-runtimes deno --impersonate="" -P downloads \
-o "%(channel_id)s/%(upload_date)s-%(title).150B [%(id)s].%(ext)s" \
"https://www.youtube.com/watch?v=jNQXAC9IVRw"python -m yt_dlp --js-runtimes deno --impersonate="" -P "home:downloads" -P "temp:work" \
-o "%(id)s.%(ext)s" "https://www.youtube.com/watch?v=jNQXAC9IVRw"Voor langdurige collecties, beslissen of filenamen menselijk leesbaar of stabiele applicatie sleutels moeten zijn. De naam en titel kan veranderen. Channel/video ID's zijn betere sleutels voor de deduplicatie, met beschrijvende velden bewaard in metadata.
Cookies en runtime paden
python -m yt_dlp --js-runtimes deno --impersonate="" \
--cookies-from-browser "chrome:Profile 1" \
--no-playlist "https://www.youtube.com/watch?v=jNQXAC9IVRw"python -m yt_dlp --js-runtimes deno --impersonate="" --cookies private/youtube-cookies.txt \
--no-playlist "https://www.youtube.com/watch?v=jNQXAC9IVRw"python -m yt_dlp --js-runtimes "deno:/opt/deno/bin/deno" --impersonate="" \
--no-playlist "https://www.youtube.com/watch?v=jNQXAC9IVRw"Diagnose en verificatie
python -m yt_dlp --js-runtimes deno --impersonate="" --ignore-config --verbose --simulate \
--no-playlist "https://www.youtube.com/watch?v=jNQXAC9IVRw"python -m yt_dlp --js-runtimes deno --impersonate="" --ignore-config --verbose --simulate \
--no-playlist "https://www.youtube.com/watch?v=jNQXAC9IVRw" > diagnostic.log 2>&1ffprobe -v error -show_entries format=duration,size:stream=codec_type,codec_name,width,height -of json "YOUR_OUTPUT_FILE"ffmpeg -v error -i "YOUR_OUTPUT_FILE" -f null -python -m pip install -U --pre "yt-dlp[default,curl-cffi]"
python -m yt_dlp --version