Skip to main content

Live Stream Handling

yt-dlp provides robust support for downloading live streams, including ongoing broadcasts and scheduled streams. This guide covers the various options and techniques for handling live content.

Basic Live Stream Download​

Download Current Live Stream​

# Download live stream from current point
yt-dlp "https://example.com/live-stream"

Download from Beginning​

# Download livestream from the start (experimental)
yt-dlp --live-from-start "https://example.com/live-stream"

Waiting for Scheduled Streams​

Wait for Stream to Start​

# Wait for scheduled stream with default retry interval
yt-dlp --wait-for-video 30 "https://example.com/scheduled-stream"

# Wait with custom retry range (min-max seconds)
yt-dlp --wait-for-video 30-120 "https://example.com/scheduled-stream"

Live Stream Formats​

HLS Stream Handling​

# Use mpegts container for HLS (default for live streams)
yt-dlp --hls-use-mpegts "https://example.com/live-stream"

# Disable mpegts container
yt-dlp --no-hls-use-mpegts "https://example.com/live-stream"

Protocol Selection​

# Prefer specific protocol for live streams
yt-dlp -f 'best[protocol^=m3u8]' "https://example.com/live-stream"

# Use native HLS downloader
yt-dlp --downloader m3u8:native "https://example.com/live-stream"

Fragment Management​

Concurrent Fragment Downloads​

# Download multiple fragments simultaneously
yt-dlp --concurrent-fragments 4 "https://example.com/live-stream"

Fragment Retry Options​

# Set fragment retry attempts
yt-dlp --fragment-retries 10 "https://example.com/live-stream"

# Skip unavailable fragments (default)
yt-dlp --skip-unavailable-fragments "https://example.com/live-stream"

# Abort on unavailable fragments
yt-dlp --abort-on-unavailable-fragments "https://example.com/live-stream"

Output and Organization​

Live Stream Output Templates​

# Include timestamp in filename
yt-dlp -o "%(title)s_%(upload_date>%Y%m%d_%H%M%S)s.%(ext)s" "https://example.com/live-stream"

# Organize by date
yt-dlp -o "%(upload_date>%Y/%m/%d)s/%(title)s.%(ext)s" "https://example.com/live-stream"

Keep Fragments​

# Keep downloaded fragments for debugging
yt-dlp --keep-fragments "https://example.com/live-stream"

Platform-Specific Features​

YouTube Live Streams​

# Download YouTube live stream with chat
yt-dlp --write-subs --sub-langs live_chat "https://youtube.com/watch?v=LIVE_ID"

# Extract live stream without chat
yt-dlp --sub-langs all,-live_chat "https://youtube.com/watch?v=LIVE_ID"

Twitch Streams​

# Download Twitch VOD from live stream
yt-dlp "https://twitch.tv/username"

# Download with specific quality
yt-dlp -f 'best[height<=720]' "https://twitch.tv/username"

Recording Options​

Time-based Recording​

# Record specific duration
yt-dlp --download-sections "*0:10:00" "https://example.com/live-stream"

# Record from specific time
yt-dlp --download-sections "*10:00-20:00" "https://example.com/live-stream"

Continuous Recording​

# Monitor and download automatically
yt-dlp --wait-for-video 60 --live-from-start "https://example.com/channel/live"

Quality and Performance​

Buffer Management​

# Adjust buffer size for live streams
yt-dlp --buffer-size 16K "https://example.com/live-stream"

# Enable buffer resizing
yt-dlp --resize-buffer "https://example.com/live-stream"

Rate Limiting​

# Limit rate to match stream bitrate
yt-dlp --limit-rate 2M "https://example.com/live-stream"

# Set throttled rate detection
yt-dlp --throttled-rate 100K "https://example.com/live-stream"

Monitoring and Automation​

Batch Live Stream Download​

# Download multiple live streams
yt-dlp --wait-for-video 30 \
--output "%(uploader)s/%(upload_date>%Y%m%d)s/%(title)s.%(ext)s" \
--batch-file live_channels.txt

Scheduled Recording Script​

#!/bin/bash
# Simple live stream recorder
while true; do
yt-dlp --wait-for-video 300 \
--live-from-start \
--output "recordings/%(title)s_%(timestamp)s.%(ext)s" \
"https://example.com/live-channel"
sleep 3600 # Check hourly
done

Troubleshooting Live Streams​

Common Issues​

  • Stream not available: Use --wait-for-video
  • Fragment errors: Adjust --fragment-retries
  • Quality issues: Check available formats with -F
  • Connection problems: Use --socket-timeout

Debug Live Streams​

# Verbose output for debugging
yt-dlp -v --live-from-start "https://example.com/live-stream"

# Check available live formats
yt-dlp -F "https://example.com/live-stream"