Index of every page on this site: llms.txt
All skills
Run it yourself

Download a video or audio from YouTube or any other yt-dlp site, at a quality the user picks from a menu. Installs yt-dlp and ffmpeg first if the machine does not have them. Use this skill whenever the user gives a video URL and wants a local copy, says "download this video", "grab this clip", "save this to my machine", "rip the audio", "get this in 4K", or asks for a specific resolution such as 1080p, 1440p or 2160p. Also use it when the user wants their own channel uploads on disk, or wants only the audio track from a video. Use it as well when the user wants one part of a video rather than the whole file, for example "grab the bit at 1:12:30", "clip from 4:10 to 6:30", or a section of a long stream or VOD.

  • 4 files
  • 22.2 KB
  • Updated 3 months ago
  • GitHub
Use this Skill: https://skilld.dev/gh/wilpat/skills/yt-download

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

SKILL.md

≈183 tokens for metadata: the name and description. ≈2.5k when used: this file. ≈998 more on demand in 1 file.

Description uses 9.2% of example budget

Before choosing a Skill, your Agent reads its name and description. All available Skills share that space.

  • A shorter description leaves more room for other Skills. This entry exceeds our 1% size suggestion.

In our Claude Code example, all Skill names and descriptions share 8,000 characters. This Skill uses ≈732 characters, or 9.2%.

The 1% threshold is a size suggestion. Longer descriptions can still fit.

Your model, settings, and other Skills decide how much text your Agent can read.

Example settings and source

The example uses a 200k-token context and default Claude Code settings. The count includes the name, description, separators, and when_to_use when present. Codex also counts local file paths.

Skit's source and limits: Codex 0.160.1, Claude Code 2.1.292.

yt-download

Take a URL, show the user the qualities that really exist for it, and download the one they choose.

Script paths below are relative to this skill directory. Run them from here, or prefix them with the skill's own path.

Step 1: Check the tools

bash scripts/check_deps.sh

The last status: line says ready or missing: ....

ffmpeg matters as much as yt-dlp. Above 1080p, YouTube sends video and audio as two separate streams, and only ffmpeg can merge them. Without ffmpeg the user silently gets 1080p or less.

If anything is missing, run the installer:

bash scripts/check_deps.sh --install

The script picks the right installer for the OS: Homebrew on macOS, pipx or pip on Linux, winget or scoop on Windows. It never calls sudo, because a password prompt would hang. It prints manual step: lines instead. Pass those lines to the user and wait for them to run those commands.

The script also warns when yt-dlp is more than 90 days old. Sites change often and a stale yt-dlp breaks. Offer the upgrade before downloading: brew upgrade yt-dlp on macOS, or re-run the install command on Linux and Windows.

Step 2: List the real qualities

Never guess what a video offers. A 4K upload and a 480p upload take the same command, so read the formats first:

python3 scripts/list_qualities.py "URL"

It prints one row per resolution, with the codec and the true download size:

resolution  fps  codec  container  approx size
2160p       60   av1    mp4        2.16 GiB
1080p       60   av1    mp4        420.74 MiB
audio only  -    aac    m4a        15.28 MiB
max_height: 2160

If python3 is missing, fall back to yt-dlp -F "URL" and read the table.

If the script says the URL is a playlist or channel, go to "Playlists and channels" below.

Step 3: Ask which quality

Use AskUserQuestion. It holds four options, so build them from the rows that exist, best first:

  1. the highest resolution, labelled with its real size, e.g. 2160p60 (2.16 GB)
  2. 1080p60 if the video has it
  3. 720p for a small file
  4. Audio only (m4a)

Put the size in every label. A user who sees 2.16 GB makes a different choice than one who sees 4K. Skip rows the video does not have rather than offering a resolution that will silently fall back.

Skip the question and go straight to the download when the user already named a quality in their request, such as "get this in 4K" or "just the audio".

Step 4: Download

Run the command from the folder the user wants the file in. Ask where to save it if the working directory is not an obvious fit.

Highest available quality:

yt-dlp -f "bv*+ba/b" -S "res,fps,vcodec:av01,acodec:aac,br" --merge-output-format mp4/mkv "URL"

A chosen resolution, for example 1080p:

yt-dlp -f "bv*[height<=1080]+ba/b[height<=1080]" -S "res,fps,vcodec:av01,acodec:aac,br" --merge-output-format mp4/mkv "URL"

Audio only:

yt-dlp -f "ba" -x --audio-format m4a "URL"

Why these flags:

  • -f "bv*[height<=H]+ba" sets a hard ceiling. -S res:H only prefers a height and can go above it, which surprises a user who asked for a small file.
  • -S vcodec:av01 prefers AV1. It is the only codec above 1080p that fits an mp4 container, so the file stays playable in QuickTime and most editors.
  • -S acodec:aac avoids Opus audio, which mp4 accepts but QuickTime will not play.
  • --merge-output-format mp4/mkv writes mp4 when the codecs allow it, and falls back to mkv instead of producing a file that will not play.

Report the real result when it finishes: the file name, the resolution and the size. Confirm it with ffprobe if the user cares about the exact codec:

ffprobe -v error -show_entries stream=codec_name,width,height -of default=noprint_wrappers=1 "FILE"

Part of a video

A user who wants one moment out of a two hour stream does not need the whole file. --download-sections fetches only that range, which turns a 2 GB download into a 100 MB one.

yt-dlp --download-sections "*1:12:30-1:15:00" --force-keyframes-at-cuts \
  -f "bv*+ba/b" -S "res,fps,vcodec:av01,acodec:aac,br" \
  --merge-output-format mp4/mkv "URL"

The * marks a plain timestamp range. Times take HH:MM:SS, MM:SS or bare seconds, and inf means the end of the video, as in "*1:12:30-inf". Pass the flag more than once for several ranges in one run, and each range becomes its own file.

--force-keyframes-at-cuts gives the user the exact frame they named, but it costs a re-encode. yt-dlp hands the section to ffmpeg, which writes it with its default h264 encoder, so the codec preferences above do not survive the cut. A measured 10 second section of an AV1 source came back as h264 and exactly 10.000 seconds long. The same cut without the flag stayed AV1 and ran 10.009 seconds, because yt-dlp cut at the nearest keyframe instead.

Choose by what the user needs:

  • Frame-accurate start, and h264 is good enough: keep the flag.
  • Original codec, and a second of slack is fine: drop it.

Setting --postprocessor-args does not change the encoder for this cut, so do not offer it as a way to have both. The height ceiling does hold either way, so a section of a 4K video is still 4K.

For a stream that is still running, --live-from-start begins at the opening instead of the current moment:

yt-dlp --live-from-start -f "bv*+ba/b" -S "res,fps,vcodec:av01,acodec:aac,br" "URL"

Expect it to be slow. yt-dlp collects every fragment the live server has published so far, one at a time.

Step 5: Offer an edit-friendly copy

Skip this step unless the user says they will edit the file. For someone who only wants to watch it, the download is already finished work.

Editing is different. Apple Silicon has no hardware decoder for VP9, so a 4K60 VP9 file decodes on the CPU. On an editing timeline that means dropped frames and a scrub that stutters, even on a fast machine. AV1 decodes in hardware on M3 and later, but not on M1 or M2.

A transcode trades disk space for smooth playback:

ffmpeg -i "INPUT" -c:v hevc_videotoolbox -q:v 55 -tag:v hvc1 -c:a copy "OUTPUT-edit.mp4"

HEVC decodes in hardware on every Apple Silicon Mac. -q:v runs from 1 to 100, and 55 holds up well at 4K. The -tag:v hvc1 flag is not optional. Without it ffmpeg writes the hev1 tag, and QuickTime and Final Cut refuse the file even though the video inside is sound.

Some ffmpeg builds reject -q:v on this encoder. Give it a bitrate instead:

ffmpeg -i "INPUT" -c:v hevc_videotoolbox -b:v 40M -tag:v hvc1 -c:a copy "OUTPUT-edit.mp4"

For heavy grading or effects work, ProRes is the safer intermediate. It is roughly ten times larger than HEVC, so check the free disk space first:

ffmpeg -i "INPUT" -c:v prores_ks -profile:v 3 -pix_fmt yuv422p10le -c:a pcm_s16le "OUTPUT-edit.mov"

Profile 3 is ProRes 422 HQ. Keep the original download either way. A transcode loses quality, and the edit copy cannot give it back.

Things that go wrong

Only 1080p offered on a video that should have 4K. ffmpeg is missing, or the user is looking at h264 rows. YouTube drops h264 above 1080p, so anything larger is VP9 or AV1 only.

4K missing on a video that just finished streaming. YouTube publishes the renditions one at a time, and the big ones land last. A stream that ended an hour ago may offer nothing above 1080p, with 1440p and 2160p appearing hours later. The formats list is the truth here. Tell the user the resolution does not exist yet and offer to try again later. Quietly stepping down to 1080p and calling it 4K is the one outcome to avoid.

HTTP 429 on subtitles. YouTube rate-limits caption requests hard and the error can stop the whole download. Leave subtitles off unless the user asks. When they do ask, add --write-auto-subs --sub-langs "en.*" --embed-subs and warn them it may fail.

Private, unlisted, members-only or age-gated video. The user must be signed in. Add their browser session:

yt-dlp --cookies-from-browser chrome -f "bv*+ba/b" "URL"

Swap chrome for safari, firefox or brave. Close the browser first on some systems, because the cookie database locks.

"Sign in to confirm you're not a bot". YouTube is blocking the request. Try --cookies-from-browser, then a browser impersonation build if it persists: pipx install "yt-dlp[default,curl-cffi]".

The user has a config file. ~/.config/yt-dlp/config on macOS and Linux sets defaults for every run. Command line flags win over it, so the commands above still hold, but its -o template decides the file name. Read it when a file lands somewhere unexpected.

Their own channel, and they want the master file. yt-dlp can only fetch the copy YouTube re-encoded for viewers. Tell them Google Takeout returns the original uploads, and that YouTube Studio's own download button caps at 720p.

Playlists and channels

A per-video quality menu makes no sense across hundreds of videos. Set one quality ceiling for the whole run instead, and keep a record so the command resumes:

yt-dlp -f "bv*[height<=1080]+ba/b[height<=1080]" -S "res,fps,vcodec:av01,acodec:aac,br" \
  --merge-output-format mp4/mkv \
  --download-archive archive.txt \
  -o "%(upload_date>%Y-%m-%d)s - %(title)s [%(id)s].%(ext)s" \
  "https://www.youtube.com/@HANDLE/videos"

--download-archive records every finished video. Run the same command later and it fetches only the new ones.

Warn the user about total size before starting. Count the videos first:

yt-dlp --flat-playlist --print "%(title)s" "URL" | wc -l

Credits

This skill is a wrapper around yt-dlp, which does the downloading, and ffmpeg, which merges and converts the streams. yt-dlp is a fork of youtube-dl and is public domain under the Unlicense. Neither tool is bundled here; the skill only calls them.

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No third-party reports yet.

Signed by skilld at 83ac99d. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 months ago.

Steadyupdated 3 months ago

README badge

README badge for wilpat/skills/yt-download