Posted: . At: 8:00 AM. This was 2 years ago. Post ID: 15279
Page permalink. WordPress uses cookies, or tiny pieces of information stored on your computer, to verify who you are. There are cookies for logged in users and for commenters.
These cookies expire two weeks after they are set.



Sponsored



More useful tricks with youtube-dl on Linux.


  1. Download the subtitles from a Youtube video
  2. Download a Youtube video storyboard
  3. Download Youtube video comments

Download the subtitles from a Youtube video

The youtube-dl utility may be used to download more than just Youtube videos. You may also download just the subtitles and use them yourself.

The example below is how to download just the subtitles from a Youtube video with the bash command line.

┌──[jason@192.168.1.2][~/Documents]
└──╼  ╼ $ youtube-dl --sub-lang en --write-auto-sub --sub-format srt --skip-download https://www.youtube.com/watch?v=27CZB-rNU-I

This wrote a vtt formatted subtitle file. This would indeed be a very useful Linux trick. This allows downloading a Youtube subtitle file without downloading the whole video.

┌──(john㉿DESKTOP-PF01IEE)-[/mnt/c/Users/Intel i5/Videos/WWE]
└─$ yt-dlp --sub-lang en --write-auto-sub --sub-format srt --skip-download https://www.youtube.com/watch?v=QWCKAPHAfmE

As you can see above, this also works with yt-dlp.

This is what I got.

┌──[jason@192.168.1.2][~/Documents]
└──╼  ╼ $ ls -hula Thompson\ Model\ 1923\ Autorifle-27CZB-rNU-I.en.vtt 
-rw-rw-r-- 1 jason jason 135K Jul 26 19:17 'Thompson Model 1923 Autorifle-27CZB-rNU-I.en.vtt'

If you have downloaded the Youtube video and the subtitles file, you may then combine them into a WebM file.

┌──[jason@192.168.1.2][~/Documents]
└──╼  ╼ $ ffmpeg -i Thompson\ Model\ 1923\ Autorifle-27CZB-rNU-I.mp4 \
-i Thompson\ Model\ 1923\ Autorifle-27CZB-rNU-I.en.vtt \
-c:v libvpx -b:v 3200k -vf scale=-1:480 -ss 00:06:20 -t 32 -copyts \
-threads 4 thompson.webm

The command above will combine a subtitles file and a video into a short WebM clip with the subtitles synchronised correctly. This is very nice indeed.

Play the video WebM file with MPV and then select the correct subtitles channel to see the subtitles in action.

Download a Youtube video storyboard

To download a Youtube video storyboard as a compiled HTML file, use this command.

yt-dlp --keep-fragments -f sb0 LINK

The example below shows this in action. This works a treat. Another very useful Youtube trick with yt-dlp.

┌──(john㉿DESKTOP-PF01IEE)-[/mnt/c/Users/Intel i5/Videos/WWE]
└─$ yt-dlp --keep-fragments -f sb0 https://www.youtube.com/watch?v=QWCKAPHAfmE
[youtube] QWCKAPHAfmE: Downloading webpage
[youtube] QWCKAPHAfmE: Downloading android player API JSON
[info] QWCKAPHAfmE: Downloading 1 format(s): sb0
[mhtml] Total fragments: 5
[download] Destination: Camp Khitomer • Star Trek 6 [QWCKAPHAfmE].mhtml
[download] 100% of 193.63KiB in 00:01

Download Youtube video comments

To download Youtube comments from a Youtube video, use the –write-comments parameter to yt-dlp.

┌──(john㉿DESKTOP-PF01IEE)-[/mnt/c/Users/Intel i5/Videos/WWE]
└─$ yt-dlp --keep-fragments -f sb0 --write-comments https://www.youtube.com/watch?v=QWCKAPHAfmE
[youtube] QWCKAPHAfmE: Downloading webpage
[youtube] QWCKAPHAfmE: Downloading android player API JSON
[youtube] Downloading comment section API JSON
[youtube] Downloading ~454 comments
[youtube] Sorting comments by newest first
[youtube] Downloading comment API JSON page 1 (0/454)
[youtube] Downloading comment API JSON page 2 (20/454)
[youtube]     Downloading comment API JSON reply thread 1 (28/454)
[youtube]     Downloading comment API JSON reply thread 2 (32/454)
[youtube]     Downloading comment API JSON reply thread 3 (35/454)
[youtube] Downloading comment API JSON page 3 (43/454)
[youtube]     Downloading comment API JSON reply thread 1 (53/454)
[youtube]     Downloading comment API JSON reply thread 2 (62/454)
[youtube]     Downloading comment API JSON reply thread 3 (65/454)
[youtube] Downloading comment API JSON page 4 (67/454)
[youtube]     Downloading comment API JSON reply thread 1 (76/454)
[youtube]     Downloading comment API JSON reply thread 2 (80/454)
[youtube] Downloading comment API JSON page 5 (89/454)
[youtube] Downloading comment API JSON page 6 (109/454)
[youtube] Downloading comment API JSON page 7 (129/454)
[youtube]     Downloading comment API JSON reply thread 1 (133/454)
[youtube]     Downloading comment API JSON reply thread 2 (139/454)
[youtube]     Downloading comment API JSON reply thread 3 (143/454)
[youtube]     Downloading comment API JSON reply thread 4 (145/454)
[youtube] Downloading comment API JSON page 8 (154/454)

The comments are saved in a json formatted file, so you need a json viewer to view the file easily, but this does work very well. If the file is opened with Firefox, then you may view the file easily.

You can use bash and Python to parse the json file and extract all comments easily.

┌──(john㉿DESKTOP-PF01IEE)-[/mnt/c/Users/Intel i5/Videos/WWE]
└─$ cat Camp\ Khitomer\ •\ Star\ Trek\ 6\ \[QWCKAPHAfmE\].info.json | python3.9 -mjson.tool | grep "\"text\":"

This works just fine.

To return multiple options, use grep like this.

┌──(john㉿DESKTOP-PF01IEE)-[/mnt/c/Users/Intel i5/Videos/WWE]
└─$ cat Camp\ Khitomer\ •\ Star\ Trek\ 6\ \[QWCKAPHAfmE\].info.json | python3.9 -mjson.tool | grep -E '\"text\"|\"author\"|\"time_text\":'

This is great for parsing a json file.

            "time_text": "1 day ago",
            "author": "Christopher Bloom",
            "text": "Well I guess by 2293 that kind of engine room design and warp core had JUST came out.",
            "time_text": "1 day ago",
            "author": "Wizardof87 1987",
            "text": "Is is true that the Excelsior was supposed to have the final shot to destroy the Bird of Prey?",
            "time_text": "3 days ago",
            "author": "Matthew Pittard",
            "text": "I am constant as the northern star!",
            "time_text": "3 days ago",
            "author": "Straight White Male News",
            "text": "\"I'd give real money if he'd shut up.\"",
            "time_text": "3 days ago",
            "author": "Timothy Harris",
            "text": "Fix the Title. It's KHITOMER, not KITOMER.",
            "time_text": "4 days ago",
            "author": "cleekmaker00",
            "text": "Fixed!",
            "time_text": "3 days ago",
            "author": "Picard + Discovery Fandom",
            "text": "Can someone answer WHY the scene with the sniper being unmasked (klingon disguise) was edited out in some versions?  Has anyone else noticed this? Please tell me I'm not crazy",
            "time_text": "4 days ago",
            "author": "drockjr",
            "text": "You're not crazy.\n\nThe theatrical version doesn't have it because it shows human blood which would have gotten it an 'R' rating in theaters.  \n\nThe directors cut DVD readded it.  Plus the directors version has a few other extended scenes as well.  But the Blu-ray doesn't have it since it's the theatrical version.",
            "time_text": "4 days ago (edited)",
            "author": "Picard + Discovery Fandom",
            "text": "That was Colonel West. He disguise himself as a Klingon.",
            "time_text": "4 days ago",
            "author": "Jonathan Myers",
            "text": "Thanks for the replies. I guess blood is a good answer.  I just remember it was weird, scooby-do esque scene.  All in all, this is such an amazing scene though",
            "time_text": "4 days ago",
            "author": "drockjr",
            "text": "\u00a0@Jonathan Myers\u00a0 And on DS9, he was known as Odo.\n\nRIP Ren\u00e9.",
            "time_text": "4 days ago",
            "author": "cleekmaker00",
            "text": "\u00a0@Picard + Discovery Fandom\u00a0 \u2026which was also why the Klingon blood was pepto pink.",
            "time_text": "3 days ago",
            "author": "tateria",
            "text": "Yeah, I wish the blu-ray had both versions.",
            "time_text": "3 days ago",
            "author": "Maximus Prime",
            "text": "CAPTAIN KIRK: Where's that damned torpedo?!\n\nDR. McCOY: She's ready, Jim. Lock and load!\n\nCAPTAIN KIRK: Fire!\n\nGENERAL CHANG: 'To be, or not ...to be.'\n\nCAPTAIN SULU: Target that explosion and fire!\n\nCAPTAIN KIRK: Fire!",
            "time_text": "4 days ago (edited)",
            "author": "Jonathan Myers",
            "text": "Prick do we not bleed   wronus and cry slip dogs war havoc",
            "time_text": "4 days ago",
            "author": "Ian Conder",

Leave a Comment

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