gpt4 book ai didi

Python Virtualenv & Youtube_dl : ffprobe or avprobe not found. 请安装一个

转载 作者:太空宇宙 更新时间:2023-11-03 19:50:11 25 4
gpt4 key购买 nike

  • 我的目标:将播客下载为 MP3
  • 在 Ubuntu 18.04 和 Nginx 上使用了 Python、Flask 和 Youtube_dl
  • 我按照本教程设置了我的服务器:Flask app with uSWGI and Nginx

第 1 点:部署成功,并且可以在浏览器中运行一个简单的 Flask 应用程序。
第 2 点:我将以下代码添加到要渲染的简单 Flask 路由中。

@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 脚本相同的代码,而不是使用 Flask 路径(从环境及其外部),它们都成功运行,没有错误并下载 MP3 文件。

我对 python virtualenv 不太熟悉,所以我相信这可能是一个配置错误。
五月这个Github solution对于类似的错误是否相关?
或者这个Stackoverflow solution ,但这并不能解释太多。

您知道如何解决这个问题或者知道从哪里开始吗? - 谢谢

最佳答案

临时解决方案:

在尝试了这么多不同的选项之后,我遵循了给出的所有错误,它引导我找到了这个文件:

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 or avprobe not found. 请安装一个,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59889757/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com