Home Linux DistributionsArch Linux Download YouTube Videos With Subtitles Using Youtube-dl
Download YouTube Videos with subtitles

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.

Install youtube-dl on Linux and Unix

Installing youtube-dl is fairly easy.

First download the youtube-dl script using curl or wget as shown below.

$ sudo curl -L https://yt-dl.org/downloads/latest/youtube-dl -o /usr/local/bin/youtube-dl

Or,

$ 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

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=smjfGmCn7x0

Sample output:

[youtube] 2hsWBXsNHnQ: Downloading webpage
[youtube] 2hsWBXsNHnQ: Downloading video info webpage
[youtube] 2hsWBXsNHnQ: Extracting video information
[youtube] 2hsWBXsNHnQ: Looking for automatic captions
[youtube] 2hsWBXsNHnQ: Downloading MPD manifest
[info] Writing video subtitles to: Dr Wayne Dyer - Improve Your Life Using The Wisdom Of The Age-2hsWBXsNHnQ.en.vtt
[download] Destination: Dr Wayne Dyer - Improve Your Life Using The Wisdom Of The Age-2hsWBXsNHnQ.f242.webm
[download] 11.9% of 119.06MiB at 214.24KiB/s ETA 08:21

To download the videos with actual sub-titles uploaded by the owner, run:

$ youtube-dl --write-srt --sub-lang en https://www.youtube.com/watch?v=smjfGmCn7x0

If you the video has subtitles, it be downloaded along with its sub-titles. Else, the following error message will appear.

Sample output:

[youtube] smjfGmCn7x0: Downloading webpage
[youtube] smjfGmCn7x0: Downloading video info webpage
WARNING: video doesn't have subtitles
[download] Destination: Memories - Dr. APJ Abdul  Kalam's speech at European Union-smjfGmCn7x0.f244.webm
[download] 100% of 3.18MiB in 00:02
[download] Destination: Memories - Dr. APJ Abdul  Kalam's speech at European Union-smjfGmCn7x0.f251.webm
[download] 100% of 1.12MiB in 00:01
[ffmpeg] Merging formats into "Memories - Dr. APJ Abdul  Kalam's speech at European Union-smjfGmCn7x0.webm"
Deleting original file Memories - Dr. APJ Abdul  Kalam's speech at European Union-smjfGmCn7x0.f244.webm (pass -k to keep)
Deleting original file Memories - Dr. APJ Abdul  Kalam's speech at European Union-smjfGmCn7x0.f251.webm (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.

Download Youtube videos with subtitles

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=2hsWBXsNHnQ

Sample output:

[youtube] 2hsWBXsNHnQ: Downloading webpage
[youtube] 2hsWBXsNHnQ: Downloading video info webpage
[youtube] 2hsWBXsNHnQ: Extracting video information
[youtube] 2hsWBXsNHnQ: Downloading MPD manifest
[download] Destination: Dr Wayne Dyer - Improve Your Life Using The Wisdom Of The Age-2hsWBXsNHnQ.f242.webm
[download] 2.6% of 119.06MiB at 260.88KiB/s ETA 07:35

The above command will immediately start downloading the specified video file in the best available format.


Recommended read:


For more details about youtube-dl command, check the man pages.

$ man youtube-dl

Reference links:

Thanks for stopping by!

Help us to help you:

Have a Good day!!

You May Also Like

4 comments

Anand May 5, 2020 - 7:18 am

This is excellent. Thank You !!

It would be great to embed the subtitles into the video instead of a separate .vtt file though. Would you kindly include that ability into this article.

Thanks Again.

Reply
Anand May 5, 2020 - 8:12 am

You may combine the separate .vtt subtitle file and .mp4 video file into a single video file.

1) Download the video in mp4

2) Use ffmpeg to combine the downloaded mp4 and vtt files into a single video

Using this article’s example:

1) youtube-dl –format mp4 –write-auto-sub https://www.youtube.com/watch?v=smjfGmCn7x0

2) ffmpeg -i Memories\ -\ Dr.\ APJ\ Abdul\ \ Kalam\’s\ speech\ at\ European\ Union-smjfGmCn7x0.mp4 -i Memories\ -\ Dr.\ APJ\ Abdul\ \ Kalam\’s\ speech\ at\ European\ Union-smjfGmCn7x0.en.vtt -c:s mov_text -c:v copy -c:a copy ‘video with embedded subtitles.mp4’

Reply
sk May 5, 2020 - 10:54 am

Thanks for the tip. I will check and update the guide accordingly.

Reply
Paul July 16, 2020 - 3:13 pm

Thanks. Is there a way to download only the subtitles as a .txt file using YouTube dl?

Reply

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More