How to Download YouTube Videos in Linux Command Line?
The videos can be downloaded from the online source through the Linux terminal using the
youtube-dl tool. youtube-dl is a Python-based small command-line tool that makes it possible to download the videos from Youtube, Facebook, Dailymotion, and few more similar sites. It is written in PyGTK and requires Python interpreter to run this program, it’s not platform restricted.
The top feature of this tool is that it supports resuming the interrupted downloads. If the download process is killed in the middle, we can simply re-run it with the same video URL.
Features of youtube-dl:
- Allow download of videos from not only YouTube but other popular websites.
- Allows downloading videos in several available video formats such as MP4, WebM, etc.
- The quality of the video to be downloaded can also be chosen.
- Resume of the paused download.
The command for Ubuntu-based Linux distribution is:
sudo apt install youtube-dl
For other Linux distributions:
sudo wget https://yt-dl.org/downloads/latest/youtube-dl -O/usr/local/bin/youtube-dl
After downloading the files, we need to set executable permission on the script to execute properly.
sudo chmod a+rx /usr/bin/youtube-dl
Simply run the following command to download a video
where “video_url” is the URL of the video to be downloaded.
Download Subtitles of Videos
Downloading subtitles for video is a two-step process. First, we have to check whether there’s a subtitle for the given video or not using the command:
youtube-dl --list-subs video_url
Second step is to download the subtitle without downloading the video:
youtube-dl --all-subs --skip-download video_url
Download a YouTube Playlist
We can download an entire playlist from YouTube we want using the following command:
youtube-dl -cit playlit_url
Download Only Audio From Video
We can download only the audio of the video in the format we want using the following command:
youtube-dl -x --audio-format mp3 video_url
The format must be specified whatever user wants else the default Ogg file format will be downloaded.My Personal Notes arrow_drop_up