Python Virtualenv 和 Youtube_dl:找不到 ffprobe 或 avprobe。请安装一个
Posted
技术标签:
【中文标题】Python Virtualenv 和 Youtube_dl:找不到 ffprobe 或 avprobe。请安装一个【英文标题】:Python Virtualenv & Youtube_dl: ffprobe or avprobe not found. Please install one 【发布时间】:2020-05-10 09:16:09 【问题描述】: 我的目标:将播客下载为 MP3 在 Ubuntu 18.04 和 nginx 上使用 Python、Flask 和 Youtube_dl 我按照本教程设置了我的服务器:Flask app with uSWGI and Nginx第 1 点:部署成功并且在浏览器中运行一个简单的烧瓶应用程序有效。 第 2 点:我将以下代码添加到要渲染的简单烧瓶路线中。
@app.route('/video', methods=['POST'])
def videoland():
ydl_opts =
'format': 'bestaudio/best',
'verbose': True,
'postprocessors': [
'key': 'FFmpegExtractAudio',
'preferredcodec': 'mp3',
'preferredquality': '192',
],
'postprocessor_args': [
'-ar', '16000'
],
'prefer_ffmpeg': True,
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
ydl.download(['http://www.youtube.com/watch?v=BaW_jenozKc'])
return Response('Response test')
问题是:当我呈现此页面时,我收到 500 错误,并且从未显示“响应测试”。 但是,MP3 文件可以毫无问题地下载到我的项目目录中(听起来很完美)
通过检查我的项目的“journalctl”,我发现以下内容:
[debug] Encodings: locale UTF-8, fs utf-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2019.11.28
[debug] Python version 3.6.9 (CPython) - Linux-4.15.0-1051-aws-x86_64-with-Ubuntu-18.04-bionic
[debug] exe versions: none
[debug] Proxy map:
[youtube] BaW_jenozKc: Downloading webpage
[youtube] BaW_jenozKc: Downloading video info webpage
[debug] Invoking downloader on 'https://r3---sn-aigl6nl7.googlevideo.com/videoplayback?expire=1579853383&ei=51EqXpe4HZiuxgKiz4SYBw&ip=35.178.16.206&id=o-AP8Cssz7OHlOd6PRswoEVAAVY7kfgYf0ZV-jL_TE9HZH&itag=140&source=youtube&requiressl=yes&mm=31%2C29&mn=sn-aigl6nl7%2Csn-aigzrn7z&ms=au%2Crdu&mv=m&mvi=2&pl=15&initcwndbps=860000&vprv=1&mime=audio%2Fmp4&gir=yes&clen=157753&dur=9.891&lmt=1387961817989105&mt=1579831690&fvip=3&keepalive=yes&fexp=23842630&c=WEB&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cgir%2Cclen%2Cdur%2Clmt&sig=ALgxI2wwRQIgI4XTN3uqTHc10HQcotiqwL8-hSqUwnop-mrrYaIwICsCIQCSeyXDEvxEVafgIOWkMloobolXXoWRYHqzPH3fh2OfOA%3D%3D&lsparams=mm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AHylml4wRQIgZKbNf2W3csHWf1leFuPJHx07S8sRJLL0-luUuXb5BqACIQD7WbHSG0E17nyoq0yTB8udlgt0-1drPysUoYKp0V539w%3D%3D&ratebypass=yes'
[download] youtube-dl test video ''_ä↭????-BaW_jenozKc.m4a has already been downloaded
[29B blob data]
WARNING: BaW_jenozKc: writing DASH m4a. Only some players support this container. Install ffmpeg or avconv to fix this automatically.
ERROR: ffprobe/avprobe and ffmpeg/avconv not found. Please install one.
Traceback (most recent call last):
File "/home/juan/mp3d/mp3denv/lib/python3.6/site-packages/youtube_dl/YoutubeDL.py", line 2064, in post_process
files_to_delete, info = pp.run(info)
File "/home/juan/mp3d/mp3denv/lib/python3.6/site-packages/youtube_dl/postprocessor/ffmpeg.py", line 272, in run
filecodec = self.get_audio_codec(path)
File "/home/juan/mp3d/mp3denv/lib/python3.6/site-packages/youtube_dl/postprocessor/ffmpeg.py", line 166, in get_audio_codec
raise PostProcessingError('ffprobe/avprobe and ffmpeg/avconv not found. Please install one.')
youtube_dl.utils.PostProcessingError: ffprobe/avprobe and ffmpeg/avconv not found. Please install one.
[2020-01-24 02:09:44,465] ERROR in app: Exception on /video [POST]
Traceback (most recent call last):
File "/home/juan/mp3d/mp3denv/lib/python3.6/site-packages/youtube_dl/YoutubeDL.py", line 2064, in post_process
files_to_delete, info = pp.run(info)
File "/home/juan/mp3d/mp3denv/lib/python3.6/site-packages/youtube_dl/postprocessor/ffmpeg.py", line 272, in run
filecodec = self.get_audio_codec(path)
File "/home/juan/mp3d/mp3denv/lib/python3.6/site-packages/youtube_dl/postprocessor/ffmpeg.py", line 166, in get_audio_codec
raise PostProcessingError('ffprobe/avprobe and ffmpeg/avconv not found. Please install one.')
youtube_dl.utils.PostProcessingError: ffprobe/avprobe and ffmpeg/avconv not found. Please install one.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/juan/mp3d/mp3denv/lib/python3.6/site-packages/flask/app.py", line 2446, in wsgi_app
response = self.full_dispatch_request()
File "/home/juan/mp3d/mp3denv/lib/python3.6/site-packages/flask/app.py", line 1951, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/juan/mp3d/mp3denv/lib/python3.6/site-packages/flask/app.py", line 1820, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/home/juan/mp3d/mp3denv/lib/python3.6/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/home/juan/mp3d/mp3denv/lib/python3.6/site-packages/flask/app.py", line 1949, in full_dispatch_request
rv = self.dispatch_request()
File "/home/juan/mp3d/mp3denv/lib/python3.6/site-packages/flask/app.py", line 1935, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "./mp3d.py", line 54, in videoland
ydl.download(['http://www.youtube.com/watch?v=BaW_jenozKc'])
File "/home/juan/mp3d/mp3denv/lib/python3.6/site-packages/youtube_dl/YoutubeDL.py", line 2018, in download
url, force_generic_extractor=self.params.get('force_generic_extractor', False))
File "/home/juan/mp3d/mp3denv/lib/python3.6/site-packages/youtube_dl/YoutubeDL.py", line 807, in extract_info
return self.process_ie_result(ie_result, download, extra_info)
File "/home/juan/mp3d/mp3denv/lib/python3.6/site-packages/youtube_dl/YoutubeDL.py", line 862, in process_ie_result
return self.process_video_result(ie_result, download=download)
File "/home/juan/mp3d/mp3denv/lib/python3.6/site-packages/youtube_dl/YoutubeDL.py", line 1643, in process_video_result
self.process_info(new_info)
File "/home/juan/mp3d/mp3denv/lib/python3.6/site-packages/youtube_dl/YoutubeDL.py", line 1999, in process_info
self.post_process(filename, info_dict)
File "/home/juan/mp3d/mp3denv/lib/python3.6/site-packages/youtube_dl/YoutubeDL.py", line 2066, in post_process
self.report_error(e.msg)
File "/home/juan/mp3d/mp3denv/lib/python3.6/site-packages/youtube_dl/YoutubeDL.py", line 624, in report_error
self.trouble(error_message, tb)
File "/home/juan/mp3d/mp3denv/lib/python3.6/site-packages/youtube_dl/YoutubeDL.py", line 594, in trouble
raise DownloadError(message, exc_info)
youtube_dl.utils.DownloadError: ERROR: ffprobe/avprobe and ffmpeg/avconv not found. Please install one.
[pid: 23571|app: 0|req: 4/6] 85.255.232.218 () 58 vars in 1170 bytes [Fri Jan 24 02:09:43 2020] POST /video => generated 290 bytes in 1047 msecs (HTTP/1.1 500) 2 headers in 84 bytes (1 switches on core 0)
这些是对路由 /video 的简单请求的所有日志 请注意,我尝试了以下方法:
sudo apt-get install ffmpeg 我测试了运行与简单 .py 脚本相同的代码而不是烧瓶路由(来自环境和外部)它们都成功运行且没有错误并下载 MP3 文件。我对python virtualenv不是很熟悉,所以我相信这是一个配置错误,也许。 这个Github solution 可能与类似的错误有关吗? 或者这个*** solution,但解释不多。
你知道如何解决它或知道从哪里开始吗? - 谢谢
【问题讨论】:
【参考方案1】:临时解决方案:
在尝试了这么多不同的选项后,我按照给出的所有错误进行操作,并找到了这个文件:
MYDIRECTORY/MYENVIROMENT/lib/python3.6/site-packages/youtube_dl/YoutubeDL.py
我在第 2061 行的一个名为“post_process”的函数中注释/删除了这段代码:
# for pp in pps_chain:
# files_to_delete = []
# try:
# files_to_delete, info = pp.run(info)
# except PostProcessingError as e:
# self.report_error(e.msg)
# if files_to_delete and not self.params.get('keepvideo', False):
# for old_filename in files_to_delete:
# self.to_screen('Deleting original file %s (pass -k to keep)' % old_filename)
# try:
# os.remove(encodeFilename(old_filename))
# except (IOError, OSError):
# self.report_warning('Unable to remove downloaded original file')
我知道这不是最好的解决方案,但它有效并且所有文件都已正确下载。我不知道它的作用,因此请随时发表评论并提出更好的解决方案。
【讨论】:
以上是关于Python Virtualenv 和 Youtube_dl:找不到 ffprobe 或 avprobe。请安装一个的主要内容,如果未能解决你的问题,请参考以下文章
python virtualenv和virtualenv的使用
python virtualenv和virtualenv的使用
[python] virtualenv和virtualenvwrapper管理python虚拟环境