gemlog/public/en/youtube-downloads-with-yt-dlp.gmi

67 lines
No EOL
1.6 KiB
Text

# YouTube downloads with yt-dlp
## Download in max resolution
``` bash
yt-dlp CHANNEL_URL|PLAYLIST_URL|VIDEO_URL
```
## Change default resolution to 1080
``` bash
yt-dlp CHANNEL_URL|PLAYLIST_URL|VIDEO_URL -S res:1080
```
## Download to location by source meta mask
``` bash
yt-dlp CHANNEL_URL/playlists -o '%(uploader)s/%(playlist)s/%(title)s.%(ext)s'
```
## Download video with multiple audio streams
* tested on yt-dlp v2025.12.08
### Download best video, best audio (original + uk) and subs
``` bash
yt-dlp -f "bv+ba+ba[language=uk]" \
--audio-multistreams \
--embed-metadata \
--embed-subs \
--all-subs \
--merge-output-format mkv \
URL
```
* it's important to provide the `--embed-metadata` flag to prevent all audio options from being marked as 'English'
* the `--merge-output-format mkv` argument is recommended, as the MKV container provides the necessary features for built-in audio and subtitle options
### Fix audio stream names using post-processing
If the `--embed-metadata` argument is missing, you can fix the names for audio options after by using ffmpeg:
``` bash
ffmpeg -i input.mkv \
-map 0 -metadata:s:a:0 language=en -metadata:s:a:1 language=uk \
-c copy output.mkv
```
* it's important to keep the previous `-f` order
or just inline:
``` bash
yt-dlp ... \
--exec "ffmpeg -i {} -map 0 -metadata:s:a:0 language=en -metadata:s:a:1 language=uk -c copy output.mkv" URL
```
## Extract audio
``` bash
yt-dlp CHANNEL_URL|PLAYLIST_URL|VIDEO_URL --extract-audio --audio-format vorbis
```
## Get help
``` bash
yt-dlp --help
```