youtube-dl – download video from YouTube with subtitles – Tutorial

All we need is an easy explanation of the problem, so here it is.

I downloaded Python and youtube-dl, on my desktop I saved the file yt-dl.py. My goal is to download video with subtitles. I opened cmd, wrote cd Desktop, pressed enter, after I dragged the file yt-dl.py on the cmd and then I don’t know how download video with subtitles (I only know how download video without subtitles: after dragged file, I enter a space and after the link of video). What command could I use to download video with subtitles?
(In the figure there is a mistake: the file is yt-dl.py instead of yt-dll.py)
enter image description here

Thank you for your time.

P.S. I tried the command –write-srt –sub-lang en ‘http://www.youtube.com/watch?v=RHy9_RQbrnQ‘ found on How to download videos from YouTube with subtitles? but it does not work. The link which I used is https://www.youtube.com/watch?v=DW5jfjN-5RI&t=1s instead of http://www.youtube.com/watch?v=RHy9_RQbrnQ.


In the file yt-dl.py there is https://raw.githubusercontent.com/rg3/youtube-dl/2012.02.27/youtube-dl.

How to solve :

I know you bored from this bug, So we are here to help you! Take a deep breath and look at the explanation of your problem. We have many solutions to this problem, But we recommend you to use the first method because it is tested & true method that will 100% work for you.

Method 1

According to the Readme file for youtube-dl (the program you run as the file yt-dl.py), --write-srt is not an option, but --write-sub is. The Readme file with all options is available here: https://github.com/rg3/youtube-dl/blob/master/README.md#readme

I successfully downloaded a video with subtitles using yt-dl.py --sub-lang en --convert-subs srt --write-sub <youtube url>. --sub-lang en chooses english subtitles, --convert-subs srt converts the subtitles to the common SubRib (.srt) format, --write-sub writes the subtitles to a .srt file and <youtube url> is simply the URL/web address of the youtube video page.

An example: yt-dl.py --sub-lang en --convert-subs srt --write-sub https://www.youtube.com/watch?v=sWAN0FwfD5M

If you use the windows executable, launch your DOS-prompt, navigate to your youtube-dl.exe file and write e.g: youtube-dl.exe --sub-lang en --convert-subs srt --write-sub https://www.youtube.com/watch?v=sWAN0FwfD5M. The --convert-subs command will not work if you do not have the ffmpeg program installed. If that is the case, you have to omit this option and youtube-dl will output .vtt subtitles instead.

Method 2

see Subtitle Options (https://github.com/ytdl-org/youtube-dl/#subtitle-options) and Post-processing Options (https://github.com/ytdl-org/youtube-dl/#post-processing-options)

My example on fedora 29. youtube-dl --help (youtube-dl --version 2019.08.13)

youtube-dl -ci -f "bestvideo[ext=mp4]"+"bestaudio[ext=m4a]" --write-sub --embed-subs --merge-output-format mp4 --proxy socks5://127.0.0.1:1080/ https://www.youtube.com/watch?v=psI7E_J1zPo

-c, –continue Force resume of partially downloaded files.
By default, youtube-dl will resume
downloads if possible.

~

-i, –ignore-errors Continue on download errors, for example to skip unavailable videos in a playlist

~

-f, –format FORMAT Video format code, see the “FORMAT
SELECTION” for all the info (requires ffmpeg or avconv installed)

~

–write-sub Write subtitle file

~

–embed-subs Embed subtitles in the video (only for mp4,
webm and mkv videos)

~

–proxy URL Use the specified HTTP/HTTPS/SOCKS proxy. To enable SOCKS proxy, specify a proper
scheme. For example socks5://127.0.0.1:1080/. Pass in an empty string (–proxy “”)
for direct connection

~

–merge-output-format FORMAT If a merge is required (e.g.
bestvideo+bestaudio), output to given
container format. One of mkv, mp4, ogg,
webm, flv. Ignored if no merge is required

ref:

https://ytdl-org.github.io/youtube-dl/index.html

https://github.com/ytdl-org/youtube-dl/blob/master/README.md

Note: Use and implement method 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply