Default video download codec for yt-dlp was downloading videos in webm format that was super small in size but when I wanted to play those in my Plex Media server, it was converting those for my Samsung TV. the default command simply downloads it into current folder which I didn’t like. Also I wanted subtitles which the default command doesn’t do. So the problem was three fold; find the correct codec, download subtitles and create organised folder structure. After few testing, I found these yt-dlp commands for subtitles, selecting codec, creating organised folder structures that worked quite well for me. Also default subtitle was VTT format and I prefer SRT format, so I kind of decided to add that into the command to convert that as well. In summary, this detailed guide covers essential commands for downloading videos with proper codec selection, subtitle integration, and automated folder organisation ideal for Plex media servers using yt-dlp.
A detailed guide on how to download YouTube videos using yt-dlp Commands for Subtitles, Codec & Folder
Before diving into specific yt-dlp commands, understanding the basic command structure helps you customise downloads effectively:
yt-dlp [OPTIONS] URL
Options control everything from video quality to subtitle languages and output locations. Let’s explore the most useful commands for organised media management.
yt-dlp URL
yt-dlp -f "bestvideo+bestaudio" URL
This downloads the highest quality video and audio streams available, merging them into a single file.
yt-dlp -S "codec:h265" -f "bestvideo*+bestaudio/best" URL
Prioritises H.265 (HEVC) codec for better compression whilst maintaining quality—perfect for reducing storage requirements.
yt-dlp -F URL
Displays all available video and audio formats with their IDs, resolutions, and codecs before downloading. So you might select e.g. MKV instead.
I prefer H.265 codec. H.265 codec provides approximately 50% better compression than H.264 whilst maintaining video quality, making it ideal for large media libraries and Plex servers. If you have a different opinion, leave a comment and I will test that.
yt-dlp -S "codec:h265" -f "bestvideo*+bestaudio/best" URL
This command prioritises H.265 encoded videos but falls back to the best available format if H.265 isn’t available.
yt-dlp -S "res:1080,codec:h265" -f "bestvideo[height<=1080]+bestaudio/best" URL
Limits download to 1080p maximum with H.265 codec preference, perfect for balancing quality and file size.
yt-dlp -S "res:2160,codec:h265" -f "bestvideo[height<=2160]+bestaudio/best" URL
Downloads 4K content when available, prioritising H.265 encoding for manageable file sizes.
Subtitles enhance accessibility and are essential for foreign language content. These commands for subtitles download handle various subtitle scenarios.
yt-dlp --write-subs --sub-langs "en" URL
Downloads English subtitles as a separate file alongside the video.
yt-dlp --write-subs --sub-langs "en,es,fr,de" URL
Downloads subtitles in English, Spanish, French, and German, creating separate files for each language.
yt-dlp --write-subs --sub-langs "en" --convert-subs srt URL
Downloads subtitles and converts them to SRT format, offering the widest compatibility with media players and Plex.
yt-dlp --write-auto-subs --sub-langs "en" --convert-subs srt URL
Downloads YouTube’s automatically generated subtitles when manual subtitles aren’t available.
yt-dlp --embed-subs --sub-langs "en" URL
Embeds subtitles directly into the video file (works with MKV and MP4 containers).
yt-dlp --write-subs --sub-langs "all" --convert-subs srt URL
Downloads subtitles in every available language, useful for international content collections.
Proper organisation is crucial for maintaining large media libraries, especially when integrating with Plex. These yt-dlp commands creates nicely organised folder hierarchies.
yt-dlp -o "%(uploader)s/%(title)s/%(title)s.%(ext)s" URL
Creates structure:
Channel Name/
└── Video Title/
└── Video Title.mp4
yt-dlp -S "codec:h265" -f "bestvideo*+bestaudio/best" --write-subs --sub-langs "en" -o "%(uploader)s/%(title)s/%(title)s.%(ext)s" URL
yt-dlp -S "codec:h265" -f "bestvideo*+bestaudio/best" --write-subs --sub-langs "en" --convert-subs srt -o "%(uploader)s/%(title)s/%(title)s.%(ext)s" URL
This command:
The best command to download YouTube videos with correct codec, subtitles and a very organised folder structure
yt-dlp -S "codec:h265" -f "bestvideo*+bestaudio/best" --write-subs --sub-langs "en" --convert-subs srt -o "%(uploader)s/%(title)s/%(title)s.%(ext)s" URL
Result:
Tech Channel/
└── Amazing Tutorial/
├── Amazing Tutorial.mp4
└── Amazing Tutorial.en.srt/vtt yt-dlp -S "codec:h265" -f "bestvideo*+bestaudio/best" --write-subs --sub-langs "en" -o "%(playlist_uploader)s/%(playlist)s/%(title)s.%(ext)s" PLAYLIST_URL
yt-dlp -S "codec:h265" -f "bestvideo*+bestaudio/best" --write-subs --sub-langs "en" --convert-subs srt -o "%(playlist_uploader)s/%(playlist)s/%(title)s.%(ext)s" PLAYLIST_URL
Creates playlist-based structure:
Channel Name/
└── Playlist Name/
├── Video 1.mp4
├── Video 1.en.srt/vtt
├── Video 2.mp4
└── Video 2.en.srt/vtt Download multiple videos efficiently whilst maintaining organisation.
yt-dlp -S "codec:h265" -f "bestvideo*+bestaudio/best" --write-subs --sub-langs "en" --convert-subs srt -o "%(uploader)s/%(title)s/%(title)s.%(ext)s" CHANNEL_URL
yt-dlp --playlist-items 1,5,7-10 -o "%(uploader)s/%(playlist)s/%(title)s.%(ext)s" PLAYLIST_URL
Downloads videos 1, 5, 7, 8, 9, and 10 from the playlist.
yt-dlp --playlist-end 5 -o "%(uploader)s/%(title)s/%(title)s.%(ext)s" CHANNEL_URL
yt-dlp --playlist-reverse -o "%(uploader)s/%(playlist)s/%(title)s.%(ext)s" PLAYLIST_URL
Create a persistent configuration file for default settings.
Linux/macOS: ~/.config/yt-dlp/config
Windows: %APPDATA%\yt-dlp\config.txt
Example configuration:
# Video quality and codec -S codec:h265 -f bestvideo*+bestaudio/best # Subtitles --write-subs --sub-langs en --convert-subs srt # Organisation -o %(uploader)s/%(title)s/%(title)s.%(ext)s # Metadata --embed-metadata --embed-thumbnail # Download archive --download-archive ~/.yt-dlp-archive.txt
With this configuration, simply run:
yt-dlp URL
All settings apply automatically.
Now that you’ve pretty much covered yt-dlp commands for subtitles, codec selection and creating folder structures:
For home server setups, check out our Unraid NAS installation guide covering complete media server infrastructure.
The above yt-dlp commands for subtitles, codecs and creating organised folder strcutures provides good control over your video library management. From codec selection to subtitle handling and folder organisation, these commands create professional-grade media collections compatible with Plex and other media servers. For me, the key to successfully playing videos without buffering was using quality control (H.265 codec), accessibility (subtitles), and organisation (structured folders).
That’s it, Enjoy!