Skip to content

Instantly share code, notes, and snippets.

@devinschumacher
Last active November 3, 2025 16:26
Show Gist options
  • Save devinschumacher/86d2843f0e1f150d79356494bc0b1a1a to your computer and use it in GitHub Desktop.
Save devinschumacher/86d2843f0e1f150d79356494bc0b1a1a to your computer and use it in GitHub Desktop.
How to Download TikTok Videos

How to Download TikTok Videos

TikTok stores videos on short-lived CDN links — those long URLs with v16-webapp-prime.us.tiktok.com and ?expire= tokens.

Those links expire quickly and won’t work by themselves.

The easiest way is to use the video page URL, which yt-dlp can automatically resolve into the proper stream.

1. Copy the TikTok Video URL

Open the video in your browser and copy the main video page link — not the direct .mp4.

2. Download with yt-dlp

Run this simple command:

yt-dlp "https://www.tiktok.com/@dvnschmchr/video/7473513210667339054"

That’s it — yt-dlp handles redirects, cookies, and merges the audio/video tracks automatically.

3. If You Get “403 Forbidden”

TikTok sometimes restricts downloads to sessions with valid cookies or headers. You can fix that by letting yt-dlp use your browser cookies:

yt-dlp \
  --cookies-from-browser chrome \
  --add-header "Referer: https://www.tiktok.com/" \
  --user-agent "Mozilla/5.0 (Windows NT 10.0; Win64; x64)" \
  --merge-output-format mp4 \
  -o "%(title)s.%(ext)s" \
  "https://www.tiktok.com/@dvnschmchr/video/7473513210667339054"

Replace chrome with safari or firefox depending on your browser.

4. Downloading from Direct CDN Links

If you’ve already copied a URL that ends in .mp4?expire=..., you can use ffmpeg directly — just include the same headers:

ffmpeg \
  -headers "User-Agent: Mozilla/5.0\r\nReferer: https://www.tiktok.com/\r\n" \
  -i "https://v16-webapp-prime.us.tiktok.com/video/tos/.../file.mp4?expire=..." \
  -c copy tiktok_video.mp4

These links expire fast, so you’ll need a new one if it stops working.

5. Pro Tips

  • -N 8 → parallel downloads, faster for long videos.
  • --postprocessor-args "ffmpeg:-movflags +faststart" → makes the MP4 instantly seekable.
  • -o "%(title)s.%(ext)s" → names files after the TikTok title automatically.
  • yt-dlp -F URL → lists all formats/resolutions before downloading.

TikTok Download Method 2: yt-dlp Hardened Session

If TikTok returns 403 Forbidden, it means your session isn’t authorized — you need your browser cookies and headers.

This “hardened” yt-dlp method authenticates as your real browser, allowing downloads of restricted or private videos.

1. Copy the TikTok video link

https://www.tiktok.com/@dvnschmchr/video/7473513210667339054

2. Run yt-dlp with your browser session

yt-dlp \
  --cookies-from-browser chrome \
  --add-header "Referer: https://www.tiktok.com/" \
  --merge-output-format mp4 \
  -N 8 \
  -o "%(title)s.%(ext)s" \
  "https://www.tiktok.com/@dvnschmchr/video/7473513210667339054"

🧠 Why It Works

TikTok validates requests against your authenticated browser session. Supplying cookies and headers allows yt-dlp to mimic that context safely — effectively downloading videos that would otherwise be blocked.

Download TikTok Videos the Easy Way

If you don’t want to touch the command line, try the web version instead:

👉 TikTok Video Downloader — paste any TikTok link, download instantly (no watermark, no setup).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment