I was wondering is there a way to download a Youtube videos with 2 or more Subtitles using Youtube-DL and ignore auto-generated subtitles?
1 Answers
TL;DR
Is there a way to download a Youtube video with 2 or more subtitles using
youtuble-dland ignore auto-generated subtitles?
Yes. Use the --sub-lang option to specify the subtitle language(s) you are interested in, as implied in the chosen answer to this Super User question. Alternatively, you could also use the --all-subs option.
I'm trying to get 2+ subs of a YouTube video, that tutorial was only for 1 subtitle.
Referencing the official documentation for youtube-dl, the --sub-lang option takes:
Languages of the subtitles to download (optional) separated by commas, use --list-subs for available language tags
Practical Examples
Using this historical K-Drama episode as an example, we can see that there are 6 possible languages for subtitles available (YouTube Player > Settings > Subtitles/CC):
Arabic
English
Korean
Spanish
Turkish
Korean (auto-generated)
Using e.g.:
youtube-dl --list-subs https://www.youtube.com/watch?v=B6xGVEXcj3k
Will produce a list of subtitle options, including a list of those specific to the given video:
...
hmn vtt, ttml, srv3, srv2, srv1
Available subtitles for B6xGVEXcj3k:
Language formats
ko vtt, ttml, srv3, srv2, srv1
es vtt, ttml, srv3, srv2, srv1
tr vtt, ttml, srv3, srv2, srv1
en vtt, ttml, srv3, srv2, srv1
ar vtt, ttml, srv3, srv2, srv1
Note that only 5 relevant options are listed as the Korean (auto-generated) subtitles are omitted.
You can then download e.g. English and Spanish subtitles (along with the video) using:
youtube-dl --sub-lang en,es --write-sub https://www.youtube.com/watch?v=B6xGVEXcj3k
To skip downloading the video and get just the subtitles, add the --skip-download option e.g.:
youtube-dl --sub-lang en,es --write-sub --skip-download https://www.youtube.com/watch?v=B6xGVEXcj3k
You can even get all 5 available subtitle files at once with the --all-subs option:
youtube-dl --all-subs --skip-download https://www.youtube.com/watch?v=B6xGVEXcj3k
Converting Subtitles
Note that YouTube subtitles default to .vtt (WEBVTT) format. If you prefer not to have your subtitles in the .vtt format, you can use ffmpeg to convert them manually with e.g.:
ffmpeg -i input.vtt output.srt
There is also an option to --convert-subs automatically with youtube-dl/FFmpeg e.g.:
youtube-dl --sub-lang en,es --write-sub --convert-subs srt https://www.youtube.com/watch?v=B6xGVEXcj3k
However, there are several caveats to converting subtitles:
In either case,
ffmpegmust reside somewhere on your system. You can get Windows builds of FFmpeg from third-parties, such as the builds kindly provided by gyan.dev.The second automatic option (apparently) doesn't work with
--skip-downloadcurrently e.g.:# Fail! Subtitles will be downloaded but remain in their original e.g. # .vtt format. Confirmed with youtube-dl.exe v2021.05.16.youtube-dl --sub-lang en,es --write-sub --convert-subs srt --skip-download https://www.youtube.com/watch?v=B6xGVEXcj3k
Finally, while I don't know the source of this problem,
youtube-dl.exe(2021.05.16) on Windows 10 21H1 (May 2021) did not seem to recognizeffmpegin the System Path for me. Instead, a copy offfmpeg.exehad to be placed directly in the same folder asyoutube-dl.exefor it to be recognized as present during post-processing (you could also use a symbolic link with a proper file extension [i.e.ffmpeg.exe] if you wanted to save some space).
- 18,227