In this article, we’re going to take a look at how you can download YouTube videos using subtitles. You probably have some favorite videos that you want to record for later viewing, but the trouble is that YouTube doesn’t have a good way of storing them. It turns out that there is a solution to this problem, and it involves using the command line. We’re also going to show you how to download YouTube videos in full as well as how to download them in full HD.
For those who don’t know, youtube-dl is a free, open source, command line downloader written using Python programming language. Using Youtube-dl program, we can easily download YouTube videos. Not only YouTube videos, we can also download videos from other popular websites such as Dailymotion, Vimeo, BBC, Bloomberg, CNN, ESPN, FOX News, and many more. The complete list of supported websites are given in this link. Youtube-dl is platform independent, so it will work on almost all modern operating systems including Linux, Microsoft Windows, and Mac OS X. In this tutorial, we will see how to install youtube-dl and how to download YouTube videos with subtitle or without subtitle.
How to Install YouTube-dl on Linux and Unix
Installing youtube-dl is fairly easy. To install it right away for all UNIX users (Linux, macOS, etc.), type:
$ sudo curl -L https://yt-dl.org/downloads/latest/youtube-dl -o /usr/local/bin/youtube-dl
Or you can use wget as shown below,
$ sudo wget https://yt-dl.org/downloads/latest/youtube-dl -O /usr/local/bin/youtube-dl
After downloading youtube-dl program, run the following command to install it.
$ sudo chmod a+rx /usr/local/bin/youtube-dl
Windows users can download an .exe file and place it in any location on their PATH except for %SYSTEMROOT%\System32
(e.g. do not put in C:\Windows\System32
).
You can also use pip:
$ sudo -H pip install --upgrade youtube-dl
This command will update youtube-dl if you have already installed it. See the pypi page for more information.
macOS users can install youtube-dl with Homebrew:
$ brew install youtube-dl
Or with MacPorts:
$ sudo port install youtube-dl
Youtube-dl downloader has been installed now. Let us go ahead and see how to download videos.
Download YouTube videos with subtitles
Let us download the following YouTube video with automatically generated subtitle files.
To do so, run the following command. Replace the URL with your own.
$ youtube-dl --write-auto-sub https://www.youtube.com/watch?v=LGz0Io_dh_I
Sample output:
[youtube] LGz0Io_dh_I: Downloading webpage [info] Writing video subtitles to: BIOS, CMOS, UEFI - What's the difference-LGz0Io_dh_I.en.vtt WARNING: Requested formats are incompatible for merge and will be merged into mkv. [download] Destination: BIOS, CMOS, UEFI - What's the difference-LGz0Io_dh_I.f271.webm [download] 100% of 21.55MiB in 00:02 [download] Destination: BIOS, CMOS, UEFI - What's the difference-LGz0Io_dh_I.f140.m4a [download] 100% of 5.20MiB in 00:00 [ffmpeg] Merging formats into "BIOS, CMOS, UEFI - What's the difference-LGz0Io_dh_I.mkv" Deleting original file BIOS, CMOS, UEFI - What's the difference-LGz0Io_dh_I.f271.webm (pass -k to keep) Deleting original file BIOS, CMOS, UEFI - What's the difference-LGz0Io_dh_I.f140.m4a (pass -k to keep)
To download the videos with actual sub-titles uploaded by the owner, run:
$ youtube-dl --write-auto-sub --sub-lang en --convert-subs=srt https://www.youtube.com/watch?v=LGz0Io_dh_I
If you the video has subtitles, it be downloaded along with its sub-titles. Else, the following error message will appear.
Sample output:
[youtube] LGz0Io_dh_I: Downloading webpage [youtube] LGz0Io_dh_I: Downloading video info webpage WARNING: video doesn't have subtitles [download] Destination: BIOS, CMOS, UEFI - What's the difference-LGz0Io_dh_I.f271.webm [download] 100% of 3.18MiB in 00:02 [download] Destination: BIOS, CMOS, UEFI - What's the difference-LGz0Io_dh_I.f140.m4a [download] 100% of 1.12MiB in 00:01 [ffmpeg] Merging formats into "BIOS, CMOS, UEFI - What's the difference-LGz0Io_dh_I.mkv" Deleting original file BIOS, CMOS, UEFI - What's the difference-LGz0Io_dh_I.f271.webm (pass -k to keep) Deleting original file BIOS, CMOS, UEFI - What's the difference-LGz0Io_dh_I.f140.m4a (pass -k to keep)
As you see in the above output, the command displays that there is no subtitle files for the specific video.
Now, play the downloaded video to verify whether the subtitle has been downloaded or not.
Great! As you see in the above video, the subtitle has been downloaded.
Download YouTube videos without subtitles
To download any video without sub-titles, just mention the URL without any options like below.
$ youtube-dl https://www.youtube.com/watch?v=8DvywoWv6fI
Sample output:
[youtube] 8DvywoWv6fI: Downloading webpage WARNING: Requested formats are incompatible for merge and will be merged into mkv. [download] Destination: Python for Everybody - Full University Python Course-8DvywoWv6fI.f248.webm [download] 100% of 2.72GiB in 04:49 [download] Destination: Python for Everybody - Full University Python Course-8DvywoWv6fI.f140.m4a [download] 100% of 759.51MiB in 01:18 [ffmpeg] Merging formats into "Python for Everybody - Full University Python Course-8DvywoWv6fI.mkv" Deleting original file Python for Everybody - Full University Python Course-8DvywoWv6fI.f248.webm (pass -k to keep) Deleting original file Python for Everybody - Full University Python Course-8DvywoWv6fI.f140.m4a (pass -k to keep)
The above command will immediately start downloading the specified video file in the best available format.
Recommended read:
- Youtube-dl Tutorial With Examples For Beginners
- How to Fix “Unable to download video data: HTTP Error 403: Forbidden” Error
For more details about youtube-dl command, check the man pages.
$ man youtube-dl
Reference links: