如何使用youtube-dl为youtube视频嵌入字幕


1

如何使用youtube-dl为youtube视频嵌入字幕?使用 youtube-dl --embed-sub --write-auto-sub 产生错误显示 处理输入时找到无效数据

input = youtube-dl -v --write-auto-sub --embed-subs https://www.youtube.com/watch?v=4Flj9plmKGQ&list=PL19E79A0638C8D449&index=84

输出=

[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: [u'--prefer-ffmpeg', u'-v', u'--write-auto-sub', u'--embed-subs', u'https://www.youtube.com/watch?v=4Flj9plmKGQ']
[debug] Encodings: locale UTF-8, fs UTF-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2017.10.20
[debug] Python version 2.7.6 - Linux-3.19.0-32-generic-x86_64-with-LinuxMint-17.3-rosa
[debug] exe versions: avconv 11.3-6, avprobe 11.3-6
[debug] Proxy map: {}
[youtube] 4Flj9plmKGQ: Downloading webpage
[youtube] 4Flj9plmKGQ: Downloading video info webpage
[youtube] 4Flj9plmKGQ: Extracting video information
[youtube] 4Flj9plmKGQ: Looking for automatic captions
[youtube] 4Flj9plmKGQ: Downloading MPD manifest
[debug] Default format spec: bestvideo+bestaudio/best
[info] Writing video subtitles to: Solid of Revolution (part 8)-4Flj9plmKGQ.en.vtt
[debug] Invoking downloader on u'https://r3---sn-ax8xaj5ggpxg-jb2e.googlevideo.com/videoplayback?id=e05963f699662864&itag=133&source=youtube&requiressl=yes&pl=24&mm=31&mn=sn-ax8xaj5ggpxg-jb2e&ei=gln4WZGqI5KEogOA-5HwCQ&initcwndbps=303750&ms=au&mv=m&ratebypass=yes&mime=video/mp4&gir=yes&clen=6954370&lmt=1397542169304899&dur=254.401&signature=3F4DC3CCDDAFD8E9B5F358CC91891EDADDE12542.37F684FA470DDEB64BB3777D45DF7FEF38EDD1AC&key=dg_yt0&mt=1509447944&ip=122.152.55.249&ipbits=0&expire=1509469666&sparams=ip,ipbits,expire,id,itag,source,requiressl,pl,mm,mn,ei,initcwndbps,ms,mv,ratebypass,mime,gir,clen,lmt,dur'
[download] Destination: Solid of Revolution (part 8)-4Flj9plmKGQ.f133.mp4
[download] 100% of 6.63MiB in 00:14
[debug] Invoking downloader on u'https://r3---sn-ax8xaj5ggpxg-jb2e.googlevideo.com/videoplayback?id=e05963f699662864&itag=140&source=youtube&requiressl=yes&pl=24&mm=31&mn=sn-ax8xaj5ggpxg-jb2e&ei=gln4WZGqI5KEogOA-5HwCQ&initcwndbps=303750&ms=au&mv=m&ratebypass=yes&mime=audio/mp4&gir=yes&clen=4044718&lmt=1397542159299201&dur=254.630&signature=86C016C05BC94E8341FFB3AA5309EFC196BBE215.33CD4DB6498FCBA00014DFA2041E1E4C3DB45A48&key=dg_yt0&mt=1509447944&ip=122.152.55.249&ipbits=0&expire=1509469666&sparams=ip,ipbits,expire,id,itag,source,requiressl,pl,mm,mn,ei,initcwndbps,ms,mv,ratebypass,mime,gir,clen,lmt,dur'
[download] Destination: Solid of Revolution (part 8)-4Flj9plmKGQ.f140.m4a
[download] 100% of 3.86MiB in 00:08
[ffmpeg] Merging formats into "Solid of Revolution (part 8)-4Flj9plmKGQ.mp4"
[debug] ffmpeg command line: avconv -y -i 'file:Solid of Revolution (part 8)-4Flj9plmKGQ.f133.mp4' -i 'file:Solid of Revolution (part 8)-4Flj9plmKGQ.f140.m4a' -c copy -map '0:v:0' -map '1:a:0' 'file:Solid of Revolution (part 8)-4Flj9plmKGQ.temp.mp4'
Deleting original file Solid of Revolution (part 8)-4Flj9plmKGQ.f133.mp4 (pass -k to keep)
Deleting original file Solid of Revolution (part 8)-4Flj9plmKGQ.f140.m4a (pass -k to keep)
[ffmpeg] Embedding subtitles in 'Solid of Revolution (part 8)-4Flj9plmKGQ.mp4'
[debug] ffmpeg command line: avconv -y -i 'file:Solid of Revolution (part 8)-4Flj9plmKGQ.mp4' -i 'file:Solid of Revolution (part 8)-4Flj9plmKGQ.en.vtt' -map 0 -c copy -map '-0:s' '-c:s' mov_text -map '1:0' '-metadata:s:s:0' 'language=eng' 'file:Solid of Revolution (part 8)-4Flj9plmKGQ.temp.mp4'
ERROR: file:Solid of Revolution (part 8)-4Flj9plmKGQ.en.vtt: Invalid data found when processing input
Traceback (most recent call last):
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 2031, in post_process
    files_to_delete, info = pp.run(info)
  File "/usr/local/bin/youtube-dl/youtube_dl/postprocessor/ffmpeg.py", line 393, in run
    self.run_ffmpeg_multiple_files(input_files, temp_filename, opts)
  File "/usr/local/bin/youtube-dl/youtube_dl/postprocessor/ffmpeg.py", line 204, in run_ffmpeg_multiple_files
    raise FFmpegPostProcessorError(msg)
FFmpegPostProcessorError: file:Solid of Revolution (part 8)-4Flj9plmKGQ.en.vtt: Invalid data found when processing input

Answers:


0

该命令对我来说很好。 你最好使用ffmpeg和youtube-dl的最新版本 要选择更好的分辨率,请尝试** youtube-dl -F'url'**,列出所有可用的质量。选择视频和音频编号** youtube-dl -f 247 + 251 --write-auto-sub --embed-subs'url'**


这不是问题中提出的问题的真正解决方案。
fixer1234
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.