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

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.


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.


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