π₯ yt-dlp Complete Guide for Termux (2025) yt-dlp is a feature-rich command-line tool to download videos from YouTube and 1000+ other sites. Itβs a fork of youtube-dl with additional features and fixes.
π Table of Contents Basic Usage Quality Selection Audio Downloads Playlists & Channels Subtitles & Captions Output Templates Speed & Performance Advanced Features Troubleshooting π Basic Usage Simple Download # Download a video (best quality) yt-dlp "https://www.youtube.com/watch?v=VIDEO_ID" # Download with custom filename yt-dlp -o "my_video.mp4" "VIDEO_URL" # Download to specific folder yt-dlp -o "~/storage/downloads/%(title)s.%(ext)s" "VIDEO_URL" Check Available Formats # List all available formats yt-dlp -F "VIDEO_URL" # Shows video quality, resolution, codec, file size π¬ Quality Selection Video Quality # Download best quality (video + audio) yt-dlp -f "bv*+ba/b" "VIDEO_URL" # Download specific resolution yt-dlp -f "bv*[height<=720]+ba/b[height<=720]" "VIDEO_URL" # Download 1080p (if available) yt-dlp -f "bv*[height<=1080]+ba/b" "VIDEO_URL" # Download 4K yt-dlp -f "bv*[height<=2160]+ba/b" "VIDEO_URL" # Download worst quality (save data) yt-dlp -f "wv*+wa/w" "VIDEO_URL" # Download specific format by ID (from -F list) yt-dlp -f 137+140 "VIDEO_URL" Recommended Quality Commands # Best quality under 500MB yt-dlp -f "bv*[filesize<500M]+ba/b[filesize<500M]" "VIDEO_URL" # Best quality MP4 format yt-dlp -f "bv*[ext=mp4]+ba[ext=m4a]/b[ext=mp4]" "VIDEO_URL" # 720p MP4 (most compatible) yt-dlp -f "bv*[height=720][ext=mp4]+ba[ext=m4a]" "VIDEO_URL" π΅ Audio Downloads Extract Audio Only # Best audio quality yt-dlp -x "VIDEO_URL" # Convert to MP3 yt-dlp -x --audio-format mp3 "VIDEO_URL" # MP3 with specific bitrate yt-dlp -x --audio-format mp3 --audio-quality 320K "VIDEO_URL" # Convert to M4A (AAC) yt-dlp -x --audio-format m4a "VIDEO_URL" # Convert to OPUS yt-dlp -x --audio-format opus "VIDEO_URL" # Best audio without conversion yt-dlp -f "ba" "VIDEO_URL" Audio with Metadata # Add metadata and thumbnail yt-dlp -x --audio-format mp3 --embed-thumbnail --add-metadata "VIDEO_URL" # Audio with thumbnail (for music players) yt-dlp -x --audio-format mp3 --embed-thumbnail --embed-metadata "VIDEO_URL" π Playlists & Channels Playlist Downloads # Download entire playlist yt-dlp "PLAYLIST_URL" # Download playlist with numbering yt-dlp -o "%(playlist_index)s-%(title)s.%(ext)s" "PLAYLIST_URL" # Download specific playlist items yt-dlp --playlist-items 1,5,10-15 "PLAYLIST_URL" # Download first 10 videos yt-dlp --playlist-items 1-10 "PLAYLIST_URL" # Download playlist in reverse order yt-dlp --playlist-reverse "PLAYLIST_URL" # Skip unavailable videos yt-dlp --ignore-errors "PLAYLIST_URL" Channel Downloads # Download all videos from channel yt-dlp "https://www.youtube.com/@CHANNEL_NAME/videos" # Download only videos uploaded this year yt-dlp --dateafter today-365days "CHANNEL_URL" # Download videos from last month yt-dlp --dateafter today-30days "CHANNEL_URL" # Download channel's latest 20 videos yt-dlp --playlist-end 20 "CHANNEL_URL" Archive Feature (Avoid Re-downloading) # Create download archive yt-dlp --download-archive downloaded.txt "PLAYLIST_URL" # Skip already downloaded videos yt-dlp --download-archive ~/yt-archive.txt "VIDEO_URL" π Subtitles & Captions Subtitle Downloads # Download with auto-generated subtitles yt-dlp --write-auto-subs "VIDEO_URL" # Download with manual subtitles (if available) yt-dlp --write-subs "VIDEO_URL" # Embed subtitles into video yt-dlp --embed-subs "VIDEO_URL" # Download specific subtitle language yt-dlp --write-subs --sub-langs "en,es" "VIDEO_URL" # List available subtitles yt-dlp --list-subs "VIDEO_URL" # Download all available subtitles yt-dlp --write-subs --sub-langs "all" "VIDEO_URL" # Convert subtitles to SRT format yt-dlp --write-subs --sub-format srt --convert-subs srt "VIDEO_URL" π Output Templates Custom Filenames # Title only yt-dlp -o "%(title)s.%(ext)s" "VIDEO_URL" # Title with uploader yt-dlp -o "%(uploader)s - %(title)s.%(ext)s" "VIDEO_URL" # Title with date yt-dlp -o "%(upload_date)s - %(title)s.%(ext)s" "VIDEO_URL" # Organized by uploader folder yt-dlp -o "~/storage/downloads/%(uploader)s/%(title)s.%(ext)s" "VIDEO_URL" # Playlist organized yt-dlp -o "~/storage/downloads/%(playlist)s/%(playlist_index)s-%(title)s.%(ext)s" "PLAYLIST_URL" # Clean filename (remove special characters) yt-dlp -o "%(title).200s.%(ext)s" --restrict-filenames "VIDEO_URL" Useful Template Variables %(title)s - Video title %(uploader)s - Channel name %(upload_date)s - Upload date (YYYYMMDD) %(duration)s - Video duration %(resolution)s - Video resolution %(playlist)s - Playlist name %(playlist_index)s - Video number in playlist %(id)s - Video ID %(ext)s - File extension β‘ Speed & Performance Download Speed Optimization # Limit download speed (to save bandwidth) yt-dlp --limit-rate 1M "VIDEO_URL" # Use multiple connections (faster downloads) yt-dlp -N 4 "VIDEO_URL" # Continue incomplete downloads yt-dlp -c "VIDEO_URL" # Show download progress yt-dlp --progress "VIDEO_URL" # Quiet mode (no output) yt-dlp -q "VIDEO_URL" # Verbose mode (detailed info) yt-dlp -v "VIDEO_URL" Batch Downloads # Download from a text file with URLs yt-dlp -a urls.txt # Format of urls.txt: # https://youtube.com/watch?v=VIDEO1 # https://youtube.com/watch?v=VIDEO2 π§ Advanced Features Cookies & Authentication # Use cookies from browser (for age-restricted content) yt-dlp --cookies-from-browser firefox "VIDEO_URL" yt-dlp --cookies-from-browser chrome "VIDEO_URL" # Use custom cookie file yt-dlp --cookies cookies.txt "VIDEO_URL" Geo-Restriction Bypass # Use a proxy yt-dlp --proxy socks5://127.0.0.1:1080 "VIDEO_URL" # Bypass geo-restriction yt-dlp --geo-bypass "VIDEO_URL" # Set custom geo-bypass country yt-dlp --geo-bypass-country US "VIDEO_URL" Post-Processing # Embed thumbnail in video file yt-dlp --embed-thumbnail "VIDEO_URL" # Add metadata yt-dlp --add-metadata "VIDEO_URL" # Merge video and audio (if downloaded separately) yt-dlp --merge-output-format mp4 "VIDEO_URL" # Re-encode video (fix compatibility issues) yt-dlp --recode-video mp4 "VIDEO_URL" # Remove sponsorblock segments yt-dlp --sponsorblock-remove all "VIDEO_URL" Live Streams # Download live stream (wait until finished) yt-dlp --wait-for-video 30 "LIVE_STREAM_URL" # Download ongoing live stream yt-dlp "LIVE_STREAM_URL" # Monitor and download when live yt-dlp --live-from-start "CHANNEL_URL" Update yt-dlp # Update to latest version pip install -U yt-dlp # Or using yt-dlp itself yt-dlp -U π― Practical Examples Example 1: Download Music Video as MP3 yt-dlp -x --audio-format mp3 --audio-quality 320K \ --embed-thumbnail --add-metadata \ -o "~/storage/music/%(artist)s - %(title)s.%(ext)s" \ "https://www.youtube.com/watch?v=VIDEO_ID" Example 2: Download Course Playlist yt-dlp -f "bv*[height<=720]+ba" \ -o "~/storage/downloads/Course/%(playlist_index)s - %(title)s.%(ext)s" \ --write-subs --embed-subs --sub-langs "en" \ --download-archive course-archive.txt \ "PLAYLIST_URL" Example 3: Download Channelβs Latest Videos yt-dlp -f "bv*[height<=1080]+ba" \ --dateafter today-30days \ -o "~/storage/downloads/%(uploader)s/%(upload_date)s - %(title)s.%(ext)s" \ --download-archive channel-archive.txt \ "https://www.youtube.com/@CHANNEL/videos" Example 4: Download 4K Video with Best Audio yt-dlp -f "bv*[height=2160]+ba" \ --merge-output-format mkv \ --embed-thumbnail --add-metadata \ -o "~/storage/movies/%(title)s.%(ext)s" \ "VIDEO_URL" Example 5: Download Entire Playlist as MP3 yt-dlp -x --audio-format mp3 --audio-quality 192K \ --embed-thumbnail --add-metadata \ -o "~/storage/music/%(playlist)s/%(playlist_index)s - %(title)s.%(ext)s" \ --ignore-errors \ "PLAYLIST_URL" π οΈ Troubleshooting Common Issues & Solutions 1. Unable to extract video data # Update yt-dlp pip install -U yt-dlp 2. 403 Forbidden / 429 Too Many Requests # Wait a bit and retry with different user-agent yt-dlp --user-agent "Mozilla/5.0" "VIDEO_URL" 3. No audio in downloaded video # Ensure audio is merged yt-dlp -f "bv*+ba" --merge-output-format mp4 "VIDEO_URL" 4. Age-restricted content # Use cookies from your browser yt-dlp --cookies-from-browser firefox "VIDEO_URL" 5. Slow downloads # Use multiple connections yt-dlp -N 8 "VIDEO_URL" 6. Storage permission denied in Termux # Grant storage permission termux-setup-storage π± Termux-Specific Tips 1. Setup Storage Access termux-setup-storage cd ~/storage/downloads 2. Default Download Location # Create downloads folder mkdir -p ~/storage/downloads # Set as default alias ytdl='yt-dlp -o "~/storage/downloads/%(title)s.%(ext)s"' 3. Save Aliases (Add to ~/.bashrc) # Quick download shortcuts echo 'alias ytdl="yt-dlp"' >> ~/.bashrc echo 'alias ytmp3="yt-dlp -x --audio-format mp3"' >> ~/.bashrc echo 'alias yt720="yt-dlp -f \"bv*[height<=720]+ba\""' >> ~/.bashrc source ~/.bashrc 4. Install FFmpeg (Required for merging/conversion) pkg install ffmpeg π Useful Command Combinations Complete Download Command yt-dlp \ -f "bv*[height<=1080]+ba" \ -o "~/storage/downloads/%(title)s.%(ext)s" \ --embed-thumbnail \ --add-metadata \ --write-subs \ --embed-subs \ --sub-langs "en" \ --ignore-errors \ --continue \ --no-overwrites \ "VIDEO_URL" Configuration File (~/.config/yt-dlp/config) # Create config directory mkdir -p ~/.config/yt-dlp # Create config file cat > ~/.config/yt-dlp/config << 'EOF' # Output location -o ~/storage/downloads/%(title)s.%(ext)s # Prefer 1080p or best -f bv*[height<=1080]+ba/b # Embed metadata --embed-thumbnail --add-metadata # Continue downloads --continue --no-overwrites --ignore-errors # Subtitles --write-subs --sub-langs en EOF Now you can simply run:
...