我在尝试
youtube-dl https://www.youtube.com/watch?v=0QRO3gKj3qw --write-sub --convert-subtitles srt -v
结果为阴性
[debug] System config: []
[debug] User config: []
[debug] Command-line args: [u'https://www.youtube.com/watch?v=0QRO3gKj3qw', u'--write-sub', u'--convert-subtitles', u'srt', u'-v']
[debug] Encodings: locale UTF-8, fs UTF-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2016.08.24.1
[debug] Python version 2.7.12 - Linux-4.4.0-36-generic-x86_64-with-Ubuntu-16.04-xenial
[debug] exe versions: avconv v12_dev0-3134-g6755eb5, avprobe v12_dev0-3134-g6755eb5, ffmpeg 3.1.2-1, ffprobe 3.1.2-1, rtmpdump 2.4
[debug] Proxy map: {}
[youtube] 0QRO3gKj3qw: Downloading webpage
[youtube] 0QRO3gKj3qw: Downloading video info webpage
[youtube] 0QRO3gKj3qw: Extracting video information
[youtube] 0QRO3gKj3qw: Downloading MPD manifest
[info] Writing video subtitles to: What is Google Chrome OS-0QRO3gKj3qw.en.vtt
[debug] Invoking downloader on u'https://r2---sn-hpa7zned.googlevideo.com/videoplayback?id=d1044ede02a3deac&itag=136&source=youtube&requiressl=yes&mv=m&ms=au&pl=19&mn=sn-hpa7zned&mm=31&initcwndbps=58750&nh=IgpwcjAxLm1pbDAyKgkxMjcuMC4wLjE&ratebypass=yes&mime=video/mp4&gir=yes&clen=10330102&lmt=1457610153524637&dur=200.916&mt=1472162919&sver=3&key=dg_yt0&signature=871A09D44DD94771EDE6E5D76843EE652268357E.5CE50080607644DD88125B0841D21F95B4C2BA01&upn=XhAQxU6qSMo&ip=41.200.192.33&ipbits=0&expire=1472185159&sparams=ip,ipbits,expire,id,itag,source,requiressl,mv,ms,pl,mn,mm,initcwndbps,nh,ratebypass,mime,gir,clen,lmt,dur'
[download] Destination: What is Google Chrome OS-0QRO3gKj3qw.f136.mp4
[download] 100% of 9.85MiB in 00:49
[debug] Invoking downloader on u'https://r2---sn-hpa7zned.googlevideo.com/videoplayback?id=d1044ede02a3deac&itag=140&source=youtube&requiressl=yes&mv=m&ms=au&pl=19&mn=sn-hpa7zned&mm=31&initcwndbps=58750&nh=IgpwcjAxLm1pbDAyKgkxMjcuMC4wLjE&ratebypass=yes&mime=audio/mp4&gir=yes&clen=3194068&lmt=1457610143781263&dur=201.061&mt=1472162919&sver=3&key=dg_yt0&signature=0DD64B9C971E69D61C6D7DD01C8884412CC05A0E.66C91FC66FAC5ECAC65901F4C3C7B60A2E5A6167&upn=XhAQxU6qSMo&ip=41.200.192.33&ipbits=0&expire=1472185159&sparams=ip,ipbits,expire,id,itag,source,requiressl,mv,ms,pl,mn,mm,initcwndbps,nh,ratebypass,mime,gir,clen,lmt,dur'
[download] Destination: What is Google Chrome OS-0QRO3gKj3qw.f140.m4a
[download] 100% of 3.05MiB in 00:18
[ffmpeg] Merging formats into "What is Google Chrome OS-0QRO3gKj3qw.mp4"
[debug] ffmpeg command line: avconv -y -i 'file:What is Google Chrome OS-0QRO3gKj3qw.f136.mp4' -i 'file:What is Google Chrome OS-0QRO3gKj3qw.f140.m4a' -c copy -map 0:v:0 -map 1:a:0 'file:What is Google Chrome OS-0QRO3gKj3qw.temp.mp4'
Deleting original file What is Google Chrome OS-0QRO3gKj3qw.f136.mp4 (pass -k to keep)
Deleting original file What is Google Chrome OS-0QRO3gKj3qw.f140.m4a (pass -k to keep)
[ffmpeg] Converting subtitles
[debug] ffmpeg command line: avconv -y -i 'file:What is Google Chrome OS-0QRO3gKj3qw.en.vtt' -f srt 'file:What is Google Chrome OS-0QRO3gKj3qw.en.srt'
ERROR: file:What is Google Chrome OS-0QRO3gKj3qw.en.vtt: Invalid data found when processing input
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/youtube_dl/YoutubeDL.py", line 1832, in post_process
files_to_delete, info = pp.run(info)
File "/usr/lib/python2.7/dist-packages/youtube_dl/postprocessor/ffmpeg.py", line 572, in run
self.run_ffmpeg(old_file, new_file, ['-f', new_format])
File "/usr/lib/python2.7/dist-packages/youtube_dl/postprocessor/ffmpeg.py", line 172, in run_ffmpeg
self.run_ffmpeg_multiple_files([path], out_path, opts)
File "/usr/lib/python2.7/dist-packages/youtube_dl/postprocessor/ffmpeg.py", line 168, in run_ffmpeg_multiple_files
raise FFmpegPostProcessorError(msg)
FFmpegPostProcessorError
答案1
1.问题:
您可以在调试中看到该问题。您拥有最新的youtube-dl
:
[debug] youtube-dl version 2016.08.24.1
这很好,但是你的调试日志显示你有两个都 avconv
并ffmpeg
安装:
[debug] exe versions: avconv v12_dev0-3134-g6755eb5, avprobe v12_dev0-3134-g6755eb5,
ffmpeg 3.1.2-1, ffprobe 3.1.2-1, rtmpdump 2.4
请注意,如果两者都安装,则将avconv
使用默认:
--prefer-avconv Prefer avconv over ffmpeg for running the postprocessors (default)
--prefer-ffmpeg Prefer ffmpeg over avconv for running the postprocessors
2.解决方案:
在我自己的系统上进行的测试表明,如果您使用ffmpeg
而不是avconv
您的下载和转换工作则完美无缺,因此您有两种解决方案可供选择:
- 添加
--prefer-ffmpeg
到命令行以执行一次性命令 - 添加
--prefer-ffmpeg
到文件~/.config/youtube-dl.conf
以获得更持久的结果。您可能需要创造首先通过运行命令来创建此文件:touch ~/.config/youtube-dl.conf
在我的系统上运行得很好......