Yt DLC Tutorial
Yt DLC Tutorial
Have you ever wanted to save your favorite videos from the internet?
Whether it's a funny cat video or a tutorial you want to watch later, Yt-dlp is here
to help! In this comprehensive yt-dlp tutorial, we will explain what yt-dlp is, how
to install it on Linux, and the most commonly used yt-dlp commands to download
audio and video from YouTube and various other websites.
Table of Contents
1. WHAT IS YT-DLP? 3
4.4. Download a Video with Description, Metadata, Annotations, Subtitles, and Thumbnail 12
5. TROUBLESHOOTING YT-DLP 24
5.1. Fix "Unable to download video data: HTTP Error 403: Forbidden" Error 24
5.2. Error: Unable to Open for Writing: [Errno 36] File Name Too Long 24
CONCLUSION 29
1. What is yt-dlp?
yt-dlp is a free and open-source command-line tool that can be used to
download videos from YouTube and other video hosting websites.
yt-dlp is a fork of the now-discontinued youtube-dlc, with the goal of
adding new features and patches while also staying compatible with the original
project.
It supports a wide range of video and audio formats, and it can also be used
to download subtitles and metadata. yt-dlp is available for Windows, macOS, and
Linux.
For more key differences, please visit the yt-dlp GitHub repository. The link is
provided at the end of this guide.
Fedora:
openSUSE:
Please be aware that the version available in official repositories may sometimes be
slightly outdated. For access to the latest features and updates, it's often
recommended to use the officially recommend method involving curl or wget, as
shown above. These methods ensure you get the most up-to-date version of yt-dlp.
termux-setup-storage
Update all the packages in Termux to ensure you have the latest versions.
Install yt-dlp and ensure it's up to date. Pip is Python's package manager and will
handle the installation for you.
If you plan to work extensively with video operations, it's recommended to install
FFmpeg. This step is optional but useful for video-related tasks.
This ensures that you're always using the latest version of yt-dlp on your Android
device through Termux. You can now enjoy downloading your favorite content on
your Android with ease!
sudo yt-dlp -U
For those who installed yt-dlp using pip, use the following command to update:
If you installed yt-dlp using your distribution's package manager, update yt-dlp
according to your system's package manager. For example, on Arch Linux, update
yt-dlp with:
Keeping yt-dlp up to date ensures you have access to the latest features and bug
fixes.
yt-dlp https://www.youtube.com/watch?v=t5b20oLaIaw
To download a video or playlist with a custom name, use the -o flag followed by
the desired name. For example:
To include additional details in the filename, such as the title, uploader name,
upload date, and playlist name, use the following format:
This method allows you to fetch several videos in one go, simply by listing their
URLs.
Option 2: Use a Text File
Alternatively, you can create a text file containing all the video URLs you want to
download and then pass this file as an argument to Youtube-dl:
yt-dlp -a url.txt
By using this command, yt-dlp will automatically download all the videos listed in
the url.txt file. This approach is particularly handy when dealing with numerous
videos, as it streamlines the process for you.
yt-dlp -x https://www.youtube.com/watch?v=t5b20oLaIaw
You can also specify the output audio format using the -x --audio-format flag.
This command extracts and downloads only the audio from the given video.
[youtube] Extracting URL: https://www.youtube.com/watch?
v=t5b20oLaIaw
With this command, you can capture not only the video itself but also all the
associated elements that enhance your viewing experience.
yt-dlp -F https://www.youtube.com/watch?v=t5b20oLaIaw
These commands provide you with an overview of the various formats in which
the content is accessible, assisting you in making an informed selection.
yt-dlp -F https://www.youtube.com/watch?v=t5b20oLaIaw
This command downloads the best quality video-only and audio-only formats and
merges them using ffmpeg or avconv. Ensure you have one of these tools installed
on your system.
If you prefer not to merge the audio and video, replace the plus (+) operator with a
comma (,) like this:
This command downloads the best quality video and audio separately, resulting in
two files. In this case, it's recommended to use an output template (-o option)
because bestvideo and bestaudio may have the same file name.
You can even download a video or playlist in a specific quality with a defined
resolution. For example, to download the best quality video with a resolution of
480 pixels or lower (less than or equal to 480p), use this command:
As mentioned earlier, you can combine format selectors to target a specific video
quality. The following command downloads the best available format (both audio
and video) but no better than 480p:
yt-dlp -f 'bestvideo[height<=480]+bestaudio/best[height<=480]'
<URL>
You can confirm whether yt-dlp has downloaded the video in the desired quality by
examining the media file information with tools like mediainfo.
You also have the flexibility to use abbreviated flag names. For instance, instead
of typing out "bestvideo," you can use "bv." Similarly, you can use "w" for "worst"
and "wv" for "worstvideo."
Examples:
To download the best video-only format and best audio-only format or the best
combined format if video-only is unavailable, run:
yt-dlp -f "bv+ba/b" https://www.youtube.com/watch?v=t5b20oLaIaw
For more abbreviated flags examples, look at the Format Selection page.
This shorthand notation simplifies your commands for more efficient usage.
Or
yt-dlp -F https://www.youtube.com/watch?v=t5b20oLaIaw
The IDs for the available formats are listed in the first column. The best quality
format is typically found towards the end, often with an ID like 247. Therefore, to
download the best quality format, you can use the following command:
If you intend to download multiple videos, and they do not share the same
available formats, you can specify the order of preference using slashes. It's
important to note that formats on the left-hand side are prioritized.
For instance, using -f 22/17/18 means it will attempt to download format 22 if
available, then format 17 if format 22 is not available, and so on. If none of the
specified formats are available, it will notify you that no suitable formats for
download are found.
Please remember that the slash is left-associative, which means formats on the left-
hand side are given preference during the selection process.
4.10. Download Videos by File Extension
To download video(s) in your preferred format, such as MP4, simply execute the
following command:
As mentioned in the previous section, it's essential to note that not all videos may
be available in your desired formats. In such cases, yt-dlp will automatically
download the best available format.
For instance, the following command will download the best quality MP4 format
file. If the MP4 format is unavailable for the given video, it will download the best
alternative format:
yt-dlp -f
'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best'
https://www.youtube.com/watch?v=t5b20oLaIaw
If you prefer to save these files with custom filenames, you can do so using the
following command:
Conversely, if you wish to avoid downloading videos larger than a given size, you
can use:
yt-dlp --max-filesize 100M <playlist_url>
You also have the option to combine format selection operators to download videos
of a particular size. The subsequent command, for instance, will download the best
video-only format, as long as it doesn't exceed 100MB:
To download videos within a specified date range, such as from September 30,
2022, to September 30, 2023, use the following command:
You can also simultaneously download and convert the video to another format. In
the following example, the command will download the first video from the
playlist and convert it to .mp3 format:
Likewise, to download multiple random videos, simply specify the indices of the
videos in the playlist separated by commas, as shown below:
You can also define a range of videos to download. To download a video playlist
starting from a specific video, say the 10th one, and continuing until the end:
To download only the videos ranging from the 2nd to the 5th position in a playlist,
use:
This command ensures that only videos appropriate for a 7-year-old audience will
be downloaded, filtering out any "NSFW" or age-restricted content.
yt-dlp -c <URL>
This flag ensures that the download picks up from where it left off, even if it was
interrupted earlier.
So, when you run this command, yt-dlp will attempt to download the thumbnail
image for the specified YouTube video and save it to a file in the current directory.
It will skip downloading the actual video file, and it will continue even if some
errors occur during the process.
This command can be useful if you only need the thumbnail image of a YouTube
video and don't want to download the entire video file, which can save time and
disk space.
If you have ffmpeg installed, you can use the '-o - --downloader ffmpeg -f
"bv*+ba/b"' options when streaming to stdout to get the best available quality."
yt-dlp --help
5. Troubleshooting yt-dlp
Below, you'll find a list of common errors that you may encounter occasionally.
The majority of these issues can be resolved by updating yt-dlp to the latest
version.
However, there are a few errors, like the ones listed below, that may persist
even when using an updated version of Youtube-dl.
To fix this error, simply clear the yt-dlp cache using the following command:
$ yt-dlp --rm-cache-dir
Removing cache dir /home/ostechnix/.cache/yt-dlp …
ERROR: unable to open for writing: [Errno 36] File name too
long: '\xe0\xae\xa8\xe0\xaf\x8b
[...]
\xe0\xaf\x8d\xe0\xae\x95\xe0\xae\xae\xe0\xaf\x8d-
_XEgknKEBws.f136.mp4.part
To resolve this error, simply download the video with a shorter name of your
choice using the "-o" flag. For example:
yt-dlp <video_url>
Download a Playlist:
yt-dlp <playlist_url>
Format Selection:
Select Best Quality:
Audio-Only Format:
Download Options:
Limit Download Speed:
Resume Download:
yt-dlp -c <video_url>
Filtering:
Filter by Date:
yt-dlp --date 20230101 <video_url>
Filter by Title:
Advanced:
Download by Format Codes:
Download Thumbnails:
Remember to replace <video_url> and <playlist_url> with the actual URLs you
want to download from.
Conclusion
In this tutorial, we have learned some of the most commonly used yt-dlp
commands to download videos and audio from YouTube and various other
websites.
yt-dlp is one of my favorite downloader program for Linux. It offers a versatile
and comprehensive set of features for downloading videos and playlists from
hundreds of websites.
If you're looking for a best audio/video downloader for Linux, yt-dlp is worth
trying!
Resource:
yt-dlp GitHub Repository
Suggested read:
20+ FFmpeg Commands For Beginners