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.
- How to download Youtube videos?
- Pytube | Python library to download youtube videos
- Youtube Data API for handling videos | Set-1
- Youtube Data API for handling videos | Set-4
- HTML | Adding Youtube videos
- Youtube Data API for handling videos | Set-3
- Youtube Data API for handling videos | Set-2
- Is downloading YouTube videos legal?
- Youtube Data API for handling videos | Set-5
- Linux Operating System | CLI (Command Line Interface) and GUI (Graphic User Interface)
- How to execute PHP code using command line ?
- du Command in LINUX
- who command in Linux
- od command in Linux with example
- SED command in Linux | Set 2
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.