If you've tried to grab a YouTube live stream with yt-dlp and ended up with half a broadcast or just an error, the thing to know is that a live stream isn't a finished file - it's an ongoing feed, and a couple of flags decide what you actually get.
Here's what I've landed on.
Just record from now
yt-dlp "https://www.youtube.com/watch?v=VIDEO_ID"
Point it at a stream that's live and it records from the current moment until the broadcast ends (or you ctrl-c). No special flag needed for a basic capture - the live URL is the same /watch?v= one as any other video.
Catch it from the start
yt-dlp --live-from-start "https://www.youtube.com/watch?v=VIDEO_ID"
By default yt-dlp joins where the stream currently is, so anything broadcast before you ran the command is gone. --live-from-start rewinds to the beginning. It can pull a lot of data for a long stream and it's slower because it has to walk every fragment, but it's the only way to get the opening.
Wait for a stream that hasn't started yet
yt-dlp --wait-for-video 30-600 --live-from-start "URL"
A plain command just errors out if the stream isn't live yet. --wait-for-video MIN-MAX keeps re-checking (those are the min/max seconds between checks) and starts the moment it goes live. Handy to leave running ahead of a scheduled premiere.
Keep a playable file if the capture drops
yt-dlp --live-from-start --hls-use-mpegts -N 4 "URL"
A capture can run for hours, so assume it'll get interrupted. --hls-use-mpegts writes to an MPEG-TS container that stays playable even if the process dies mid-stream, so you keep what you recorded instead of a corrupt file. -N 4 grabs a few fragments at once to keep up with a high-bitrate stream. When it ends cleanly you can --remux-video mp4 if you need something more portable.
The honest caveats
- A live stream can't be retried. For a normal video a failed fragment is just re-requested. In a live capture there's no going back in time, so if the connection drops for a stretch, that part of the broadcast is simply gone.
- Some live formats need a PO token now. Missing it shows up as missing formats or a capture that stops after a short while.
-
Keep yt-dlp updated. Player changes break live extraction faster than they break normal downloads - run
yt-dlp -Ubefore a scheduled capture, not during one.
Why it's worse on a server
If you're running this from a VPS or a CI runner, you've got two problems stacked. YouTube throttles and blocks datacenter IPs harder than home connections, so a server capture is more likely to hit a mid-stream block. And because a live stream can't be replayed, that block turns into a permanent gap instead of a retry. The free fix is to run captures from a clean residential IP, keep yt-dlp current, and use --live-from-start --hls-use-mpegts so an interruption still leaves a usable partial file.
fwiw I run a hosted API for exactly this "works on my laptop, dies on the server" problem (I built importly.io - you POST a URL and get the file or transcript back from infra that isn't blocked), so if you're capturing from a server and don't want to babysit IPs it might save you some time. For a one-off from your own machine though, the flags above are all you need.
Full writeup with the related guides: https://ytdlp.org/guides/yt-dlp-download-youtube-live
Top comments (0)