ytdl-org / youtube-dl

Command-line program to download videos from YouTube.com and other video sites
http://ytdl-org.github.io/youtube-dl/
The Unlicense
131.2k stars 9.93k forks source link

Automatically download subtitles with --embed-subs (was: '--all-subs' downloads and embeds subtitles but '--sub-lang en' does not) #9548

Open expenses opened 8 years ago

expenses commented 8 years ago

Checks


Summary

I have

-o "~/Movies/%(uploader)s/%(title)s.%(ext)s"

# Subtitles
--sub-lang en
#--all-subs
--embed-subs

--embed-thumbnail
--add-metadata

in my ~/.config/youtube-dl/config file.

Running ~ ❯❯❯ youtube-dl "https://www.youtube.com/watch?v=P5-WGdiWAB4" -v on this video with English (en) and Portuguese (pt) subtitles will download and embed the subtitles when --all-subs is uncommented but --sub-lang en is works, but not the other way around. Additionally --sub-lang en,pt fails to download and embed either set of subtitles.

Logs

-all-subs:
[debug] System config: []
[debug] User config: ['-o', '~/Movies/%(uploader)s/%(title)s.%(ext)s', '--all-subs', '--embed-subs', '--embed-thumbnail', '--add-metadata']
[debug] Command-line args: ['https://www.youtube.com/watch?v=P5-WGdiWAB4', '-v']
[debug] Encodings: locale UTF-8, fs utf-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2016.05.10
[debug] Python version 3.5.1 - Linux-4.5.4-1-ARCH-x86_64-with-arch
[debug] exe versions: ffmpeg 3.0.2, ffprobe 3.0.2
[debug] Proxy map: {}
[youtube] P5-WGdiWAB4: Downloading webpage
[youtube] P5-WGdiWAB4: Downloading video info webpage
[youtube] P5-WGdiWAB4: Extracting video information
[youtube] P5-WGdiWAB4: Downloading MPD manifest
[info] Writing video subtitles to: /home/expenses/Movies/The Intercept/Excerpt of Glenn Greenwald's interview with Brazilian President Dilma Rousseff.en.vtt
[info] Writing video subtitles to: /home/expenses/Movies/The Intercept/Excerpt of Glenn Greenwald's interview with Brazilian President Dilma Rousseff.pt.vtt
[youtube] P5-WGdiWAB4: Downloading thumbnail ...
[youtube] P5-WGdiWAB4: Writing thumbnail to: /home/expenses/Movies/The Intercept/Excerpt of Glenn Greenwald's interview with Brazilian President Dilma Rousseff.jpg
[debug] Invoking downloader on 'https://r4---sn-uo1-jije.googlevideo.com/videoplayback?id=3f9f9619d896001e&itag=137&source=youtube&requiressl=yes&initcwndbps=1181250&mn=sn-uo1-jije&mm=31&mv=m&ms=au&pl=21&ratebypass=yes&mime=video/mp4&gir=yes&clen=18750294&lmt=1463722565073351&dur=80.121&fexp=9405973,9414672,9416126,9416891,9417703,9422596,9423554,9428398,9431012,9432565,9433096,9433700,9433946,9435876,9436606,9436795,9436824,9436958,9437066&key=dg_yt0&mt=1463736430&signature=9141645C1412576A8A52F832FDBA27E5275397C5.38C000C9458CF75FDE2AC6C3D47571C3BD27BEA6&upn=Xhy1zeMw6VU&sver=3&ip=219.89.38.110&ipbits=0&expire=1463758362&sparams=ip,ipbits,expire,id,itag,source,requiressl,initcwndbps,mn,mm,mv,ms,pl,ratebypass,mime,gir,clen,lmt,dur'
[download] Destination: /home/expenses/Movies/The Intercept/Excerpt of Glenn Greenwald's interview with Brazilian President Dilma Rousseff.f137.mp4
[download] 100% of 17.88MiB in 00:48
[debug] Invoking downloader on 'https://r4---sn-uo1-jije.googlevideo.com/videoplayback?id=3f9f9619d896001e&itag=140&source=youtube&requiressl=yes&initcwndbps=1181250&mn=sn-uo1-jije&mm=31&mv=m&ms=au&pl=21&ratebypass=yes&mime=audio/mp4&gir=yes&clen=1274165&lmt=1463722461754020&dur=80.178&fexp=9405973,9414672,9416126,9416891,9417703,9422596,9423554,9428398,9431012,9432565,9433096,9433700,9433946,9435876,9436606,9436795,9436824,9436958,9437066&key=dg_yt0&mt=1463736430&signature=2AA9513411B82F9A966A7B19CE90E7211814EB81.3DD95CD215461542B92D6F902D86EB3C8408C960&upn=Xhy1zeMw6VU&sver=3&ip=219.89.38.110&ipbits=0&expire=1463758362&sparams=ip,ipbits,expire,id,itag,source,requiressl,initcwndbps,mn,mm,mv,ms,pl,ratebypass,mime,gir,clen,lmt,dur'
[download] Destination: /home/expenses/Movies/The Intercept/Excerpt of Glenn Greenwald's interview with Brazilian President Dilma Rousseff.f140.m4a
[download] 100% of 1.22MiB in 00:03
[ffmpeg] Merging formats into "/home/expenses/Movies/The Intercept/Excerpt of Glenn Greenwald's interview with Brazilian President Dilma Rousseff.mp4"
[debug] ffmpeg command line: ffmpeg -y -i 'file:/home/expenses/Movies/The Intercept/Excerpt of Glenn Greenwald'"'"'s interview with Brazilian President Dilma Rousseff.f137.mp4' -i 'file:/home/expenses/Movies/The Intercept/Excerpt of Glenn Greenwald'"'"'s interview with Brazilian President Dilma Rousseff.f140.m4a' -c copy -map 0:v:0 -map 1:a:0 'file:/home/expenses/Movies/The Intercept/Excerpt of Glenn Greenwald'"'"'s interview with Brazilian President Dilma Rousseff.temp.mp4'
Deleting original file /home/expenses/Movies/The Intercept/Excerpt of Glenn Greenwald's interview with Brazilian President Dilma Rousseff.f137.mp4 (pass -k to keep)
Deleting original file /home/expenses/Movies/The Intercept/Excerpt of Glenn Greenwald's interview with Brazilian President Dilma Rousseff.f140.m4a (pass -k to keep)
[ffmpeg] Adding metadata to '/home/expenses/Movies/The Intercept/Excerpt of Glenn Greenwald's interview with Brazilian President Dilma Rousseff.mp4'
[debug] ffmpeg command line: ffmpeg -y -i 'file:/home/expenses/Movies/The Intercept/Excerpt of Glenn Greenwald'"'"'s interview with Brazilian President Dilma Rousseff.mp4' -c copy -metadata 'purl=https://www.youtube.com/watch?v=P5-WGdiWAB4' -metadata 'title=Excerpt of Glenn Greenwald'"'"'s interview with Brazilian President Dilma Rousseff' -metadata 'artist=The Intercept' -metadata date=20160518 -metadata 'comment=How did the now-suspended President react when she saw the corruption-implicated, right-wing all-white-male cabinet appointed by the substitute President who took her job? Watch the full interview at The Intercept.' -metadata 'description=How did the now-suspended President react when she saw the corruption-implicated, right-wing all-white-male cabinet appointed by the substitute President who took her job? Watch the full interview at The Intercept.' 'file:/home/expenses/Movies/The Intercept/Excerpt of Glenn Greenwald'"'"'s interview with Brazilian President Dilma Rousseff.temp.mp4'
[ffmpeg] Embedding subtitles in '/home/expenses/Movies/The Intercept/Excerpt of Glenn Greenwald's interview with Brazilian President Dilma Rousseff.mp4'
[debug] ffmpeg command line: ffmpeg -y -i 'file:/home/expenses/Movies/The Intercept/Excerpt of Glenn Greenwald'"'"'s interview with Brazilian President Dilma Rousseff.mp4' -i 'file:/home/expenses/Movies/The Intercept/Excerpt of Glenn Greenwald'"'"'s interview with Brazilian President Dilma Rousseff.en.vtt' -i 'file:/home/expenses/Movies/The Intercept/Excerpt of Glenn Greenwald'"'"'s interview with Brazilian President Dilma Rousseff.pt.vtt' -map 0 -c copy -map -0:s -c:s mov_text -map 1:0 -metadata:s:s:0 language=eng -map 2:0 -metadata:s:s:1 language=por 'file:/home/expenses/Movies/The Intercept/Excerpt of Glenn Greenwald'"'"'s interview with Brazilian President Dilma Rousseff.temp.mp4'
Deleting original file /home/expenses/Movies/The Intercept/Excerpt of Glenn Greenwald's interview with Brazilian President Dilma Rousseff.en.vtt (pass -k to keep)
Deleting original file /home/expenses/Movies/The Intercept/Excerpt of Glenn Greenwald's interview with Brazilian President Dilma Rousseff.pt.vtt (pass -k to keep)
[atomicparsley] Adding thumbnail to "/home/expenses/Movies/The Intercept/Excerpt of Glenn Greenwald's interview with Brazilian President Dilma Rousseff.mp4"
[debug] AtomicParsley command line: AtomicParsley '/home/expenses/Movies/The Intercept/Excerpt of Glenn Greenwald'"'"'s interview with Brazilian President Dilma Rousseff.mp4' --artwork '/home/expenses/Movies/The Intercept/Excerpt of Glenn Greenwald'"'"'s interview with Brazilian President Dilma Rousseff.jpg' -o '/home/expenses/Movies/The Intercept/Excerpt of Glenn Greenwald'"'"'s interview with Brazilian President Dilma Rousseff.temp.mp4'
--sub-lang en:
[debug] System config: []
[debug] User config: ['-o', '~/Movies/%(uploader)s/%(title)s.%(ext)s', '--sub-lang', 'en', '--embed-subs', '--embed-thumbnail', '--add-metadata']
[debug] Command-line args: ['https://www.youtube.com/watch?v=P5-WGdiWAB4', '-v']
[debug] Encodings: locale UTF-8, fs utf-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2016.05.10
[debug] Python version 3.5.1 - Linux-4.5.4-1-ARCH-x86_64-with-arch
[debug] exe versions: ffmpeg 3.0.2, ffprobe 3.0.2
[debug] Proxy map: {}
[youtube] P5-WGdiWAB4: Downloading webpage
[youtube] P5-WGdiWAB4: Downloading video info webpage
[youtube] P5-WGdiWAB4: Extracting video information
[youtube] P5-WGdiWAB4: Downloading MPD manifest
[youtube] P5-WGdiWAB4: Downloading thumbnail ...
[youtube] P5-WGdiWAB4: Writing thumbnail to: /home/expenses/Movies/The Intercept/Excerpt of Glenn Greenwald's interview with Brazilian President Dilma Rousseff.jpg
[debug] Invoking downloader on 'https://r4---sn-uo1-jije.googlevideo.com/videoplayback?id=3f9f9619d896001e&itag=137&source=youtube&requiressl=yes&initcwndbps=1176250&mv=m&ms=au&mm=31&mn=sn-uo1-jije&pl=21&ratebypass=yes&mime=video/mp4&gir=yes&clen=18750294&lmt=1463722565073351&dur=80.121&sver=3&key=dg_yt0&upn=mkfxKNChU6M&signature=74FA1D4A0269304A63AA76476AAC7389E0074FD1.61A5FB8EFEC4752F1E28FBE0F7AD56F14D0F0F5B&mt=1463736688&fexp=9416126,9416891,9422596,9428398,9431012,9433096,9433946,9435876&ip=219.89.38.110&ipbits=0&expire=1463758602&sparams=ip,ipbits,expire,id,itag,source,requiressl,initcwndbps,mv,ms,mm,mn,pl,ratebypass,mime,gir,clen,lmt,dur'
[download] Destination: /home/expenses/Movies/The Intercept/Excerpt of Glenn Greenwald's interview with Brazilian President Dilma Rousseff.f137.mp4
[download] 100% of 17.88MiB in 00:27
[debug] Invoking downloader on 'https://r4---sn-uo1-jije.googlevideo.com/videoplayback?id=3f9f9619d896001e&itag=140&source=youtube&requiressl=yes&initcwndbps=1176250&mv=m&ms=au&mm=31&mn=sn-uo1-jije&pl=21&ratebypass=yes&mime=audio/mp4&gir=yes&clen=1274165&lmt=1463722461754020&dur=80.178&sver=3&key=dg_yt0&upn=mkfxKNChU6M&signature=1B5EAA716262E47B2CB6F4BAEB69269E4C8D62BB.9029C4BCB45D8C2650CD07EFA0CBD1149DF9BF94&mt=1463736688&fexp=9416126,9416891,9422596,9428398,9431012,9433096,9433946,9435876&ip=219.89.38.110&ipbits=0&expire=1463758602&sparams=ip,ipbits,expire,id,itag,source,requiressl,initcwndbps,mv,ms,mm,mn,pl,ratebypass,mime,gir,clen,lmt,dur'
[download] Destination: /home/expenses/Movies/The Intercept/Excerpt of Glenn Greenwald's interview with Brazilian President Dilma Rousseff.f140.m4a
[download] 100% of 1.22MiB in 00:05
[ffmpeg] Merging formats into "/home/expenses/Movies/The Intercept/Excerpt of Glenn Greenwald's interview with Brazilian President Dilma Rousseff.mp4"
[debug] ffmpeg command line: ffmpeg -y -i 'file:/home/expenses/Movies/The Intercept/Excerpt of Glenn Greenwald'"'"'s interview with Brazilian President Dilma Rousseff.f137.mp4' -i 'file:/home/expenses/Movies/The Intercept/Excerpt of Glenn Greenwald'"'"'s interview with Brazilian President Dilma Rousseff.f140.m4a' -c copy -map 0:v:0 -map 1:a:0 'file:/home/expenses/Movies/The Intercept/Excerpt of Glenn Greenwald'"'"'s interview with Brazilian President Dilma Rousseff.temp.mp4'
Deleting original file /home/expenses/Movies/The Intercept/Excerpt of Glenn Greenwald's interview with Brazilian President Dilma Rousseff.f137.mp4 (pass -k to keep)
Deleting original file /home/expenses/Movies/The Intercept/Excerpt of Glenn Greenwald's interview with Brazilian President Dilma Rousseff.f140.m4a (pass -k to keep)
[ffmpeg] Adding metadata to '/home/expenses/Movies/The Intercept/Excerpt of Glenn Greenwald's interview with Brazilian President Dilma Rousseff.mp4'
[debug] ffmpeg command line: ffmpeg -y -i 'file:/home/expenses/Movies/The Intercept/Excerpt of Glenn Greenwald'"'"'s interview with Brazilian President Dilma Rousseff.mp4' -c copy -metadata 'purl=https://www.youtube.com/watch?v=P5-WGdiWAB4' -metadata 'description=How did the now-suspended President react when she saw the corruption-implicated, right-wing all-white-male cabinet appointed by the substitute President who took her job? Watch the full interview at The Intercept.' -metadata 'artist=The Intercept' -metadata 'comment=How did the now-suspended President react when she saw the corruption-implicated, right-wing all-white-male cabinet appointed by the substitute President who took her job? Watch the full interview at The Intercept.' -metadata 'title=Excerpt of Glenn Greenwald'"'"'s interview with Brazilian President Dilma Rousseff' -metadata date=20160518 'file:/home/expenses/Movies/The Intercept/Excerpt of Glenn Greenwald'"'"'s interview with Brazilian President Dilma Rousseff.temp.mp4'
[ffmpeg] There aren't any subtitles to embed
[atomicparsley] Adding thumbnail to "/home/expenses/Movies/The Intercept/Excerpt of Glenn Greenwald's interview with Brazilian President Dilma Rousseff.mp4"
[debug] AtomicParsley command line: AtomicParsley '/home/expenses/Movies/The Intercept/Excerpt of Glenn Greenwald'"'"'s interview with Brazilian President Dilma Rousseff.mp4' --artwork '/home/expenses/Movies/The Intercept/Excerpt of Glenn Greenwald'"'"'s interview with Brazilian President Dilma Rousseff.jpg' -o '/home/expenses/Movies/The Intercept/Excerpt of Glenn Greenwald'"'"'s interview with Brazilian President Dilma Rousseff.temp.mp4'
yan12125 commented 8 years ago

[ffmpeg] There aren't any subtitles to embed

You need to append --write-sub besides --sub-lang to download subtitles. --sub-lang itself just specifies the language to download in --write-sub.

expenses commented 8 years ago

Thank you! This seems like an inconsistency though, as all you need to download and embed thumbnails is --embed-thumbnail. When youtube-dl sees the --embed-subs flag, it should check for a --sub-lang and download and embed subtitles accordingly.

yan12125 commented 8 years ago

I changed the semantic of --embed-thumbnail in 8e595397529abc71093264e3695fb00d95be4d78.

When youtube-dl sees the --embed-subs flag, it should check for a --sub-lang and download and embed subtitles accordingly.

Agreed.