【发布时间】:2021-05-12 04:30:13
【问题描述】:
我不知道发生了什么。由 Django 运行的脚本可以正常工作,但不能通过 Docker 和 Django。返回错误:
Pic Errno 2 No such file or directory
下面是出现错误的函数代码和Dockerfile的代码。
'''
def mediainfo(filepath):
原码:
prober = get_prober_name() command_args = [ "-v", "quiet", "-show_format", "-show_streams", filepath ] command = [prober, '-of', 'old'] + command_args
修改代码:
command = f"ffprobe -v error -show_format -show_streams -select_streams v:0 {filepath}"
其余功能:
res = Popen(command, stdout=PIPE)
output = res.communicate()[0].decode("utf-8")
if res.returncode != 0:
output = Popen(command, stdout=PIPE).communicate()[0].decode("utf-8")
rgx = re.compile(r"(?:(?P<inner_dict>.*?):)?(?P<key>.*?)\=(?P<value>.*?)$")
info = {}
if sys.platform == 'win32':
output = output.replace("\r", "")
for line in output.split("\n"):
# print(line)
mobj = rgx.match(line)
if mobj:
# print(mobj.groups())
inner_dict, key, value = mobj.groups()
if inner_dict:
try:
info[inner_dict]
except KeyError:
info[inner_dict] = {}
info[inner_dict][key] = value
else:
info[key] = value
return info
'''
Dockerfile 的代码
'''
FROM python:3.7 as base
EXPOSE 80
WORKDIR /app
COPY . /app
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
RUN pip install --upgrade pip
RUN echo 'deb http://deb.debian.org/debian buster-backports main contrib non-free' >> /etc/apt/sources.list
RUN apt-get update
RUN apt-get -y install ffmpeg
RUN apt-get update
COPY requirements.txt .
RUN python -m pip install -r requirements.txt
FROM base as prod
ENTRYPOINT ["python","manage.py","runserver","0.0.0.0:80"]
'''
【问题讨论】:
标签: python-3.x django docker ffmpeg ffprobe