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

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

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

输入 = youtube-dl -v --write-auto-sub --embed-subshttps://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

答案1

尝试这个:

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

需要获取字幕轨道然后嵌入。

相关内容