yt-dlp is a fork from the now troubled youtube-dl, the best part about yt-dlp aside from being actively maintained is that it follows similar commands to youtube-dl.
Installing yt-dlp can simply be done with:
sudo wget https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp -O /usr/local/bin/yt-dlp
Followed by:
sudo chmod a+rx /usr/local/bin/yt-dlp
If you ever need to update yt-dlp use:
yt-dlp -U
Some common usage examples for yt-dlp:
Print out the available formats with:
yt-dlp --list-formats https://www.youtube.com/watch?v=1La4QzGeaaQ
Print JSON information for the video and audio streams:
yt-dlp --dump-json https://www.youtube.com/watch?v=1La4QzGeaaQ
Download the best format (video + audio) that is equal to or greater than 720p width. Save this file as video_id.extension (1La4QzGeaaQ.mp4):
yt-dlp -f "best[height>=720]" https://www.youtube.com/watch?v=1La4QzGeaaQ -o '%(id)s.%(ext)s'
Download and merge the best video stream with the best audio stream:
yt-dlp -f 'bv*+ba' https://www.youtube.com/watch?v=1La4QzGeaaQ -o '%(id)s.%(ext)s'
Download 1080p video and merge with best audio stream:
yt-dlp -f 'bv*[height=1080]+ba' https://www.youtube.com/watch?v=1La4QzGeaaQ -o '%(id)s.%(ext)s'
Download 1080p video that is mp4 format and merge with best m4a audio format:
yt-dlp -f 'bv[height=1080][ext=mp4]+ba[ext=m4a]' --merge-output-format mp4 https://www.youtube.com/watch?v=1La4QzGeaaQ -o '%(id)s.mp4'
Embed video thumbnail into video file use --embed-thumbnail
:
yt-dlp -f 'bv[height=1080][ext=mp4]+ba[ext=m4a]' --embed-thumbnail --merge-output-format mp4 https://www.youtube.com/watch?v=1La4QzGeaaQ -o '%(id)s.mp4'
Embed subtitles to video file (if they exist) --embed-subs
:
yt-dlp -f 'bv[height=1080][ext=mp4]+ba[ext=m4a]' --embed-subs --merge-output-format mp4 https://www.youtube.com/watch?v=1La4QzGeaaQ -o '%(id)s.mp4'
Embed metadata about the video --embed-metadata
:
yt-dlp -f 'bv[height=1080][ext=mp4]+ba[ext=m4a]' --embed-metadata --merge-output-format mp4 https://www.youtube.com/watch?v=1La4QzGeaaQ -o '%(id)s.mp4'
Get the best audio into mp3 file:
yt-dlp -f 'ba' -x --audio-format mp3 https://www.youtube.com/watch?v=1La4QzGeaaQ -o '%(id)s.mp3'
All the options for format selection and filtering can be found here, There are a lot.
Download a YouTube playlist with the videos being 1080p and the best audio. Save into channel_id/playlist_id directory with the video added to an archive text file:
yt-dlp -f 'bv*[height=1080]+ba' --download-archive videos.txt https://www.youtube.com/playlist?list=PLlVlyGVtvuVnUjA4d6gHKCSrLAAm2n1e6 -o '%(channel_id)s/%(playlist_id)s/%(id)s.%(ext)s'
Download an entire YouTube channel as 720p video with best audio. Save into a folder named after the channel name with the video files being the title of the video (Foo the Flowerhorn/5 Months Update – Flowerhorn Foods.webm).
yt-dlp -f 'bv*[height=720]+ba' --download-archive videos.txt https://www.youtube.com/c/FootheFlowerhorn/videos -o '%(channel)s/%(title)s.%(ext)s'
A drained and empty Kennington reservoir images from a drone in early July 2024. The…
Merrimu Reservoir from drone. Click images to view larger.
Using FTP and PHP to get an array of file details such as size and…
Creating and using Laravel form requests to create cleaner code, separation and reusability for your…
Improving the default Laravel login and register views in such a simple manner but making…
Laravel validation for checking if a field value exists in the database. The validation rule…