youtube-dl is a command-line program to download videos and subtitles from youtube. It works not only on youtube.com, but on many more sites. Supported sites To download the most recent version visit project page and follow the install instructions.

Example 1 - download English subtitles only

I borrowed from this discussion.

When you need to download only subtitles in a given or all languages you have the following options according to the documentations (man youtube-dl or youtube-dl -h depending on install method). screenshot

The following command will download subtitles this video (America’s Great Divide: Steve Bannon, 2nd Interview) Note: You can check the available languages and formats with youtube-dl --list-subs YOUR_URI. --sub-lang en specifies English langugage, and skip-download is the only part, that is an opt for subtitles only. In this way video content will not be downloaded.

youtube-dl --write-sub --sub-lang en --skip-download https://youtu.be/gDqAnOyAgt4                 

The result will be a WebVTT (with .vtt extension) text file, that can be process or use for one’s purpose.

WEBVTT
Kind: captions
Language: en

00:00:00.000 --> 00:00:03.580
 So we’re in the summer of 2017. 

00:00:03.580 --> 00:00:06.416
The president is waffling on DACA [Deferred Action for Childhood Arrivals]. 

00:00:06.416 --> 00:00:08.048
You recognize that. 

Example 2 Get only part of a video - TBC

How to download portion of video with youtube-dl command?

youtube-dl -g "https://www.youtube.com/watch?v=V_f2QkBdbRI"

-g, --get-url Simulate, quiet but print URL & cut out 10 seconds from the start at (15.00 second)

ffmpeg -ss 00:00:15.00 -i "OUTPUT-OF-FIRST URL" -t 00:00:10.00 -c copy out.mp4

superuser- Cutting Video guide says:

“The time values can either be seconds or in the form of HH:MM:SS.ms. So, you could also cut one minute, ten seconds and 500 milliseconds:”

ffmpeg -ss 00:01:30 -i input.mov -c:v copy -c:a copy -t 00:01:30.500 output.mov 

Posts in “Linux” category: