So I'm trying to create a telegram bot using python and ffmpeg and I want to deploy it to a server through a docker image.
I already looked through a lot of resources as I've been looking at the same 5 lines of code for the past three days and neither discords, stack overflow previous answers have helped me.
This is my dockerfile where half of the program works (apart from the ffmpeg functionality).
FROM python:3.9
RUN mkdir /app
WORKDIR /app
COPY requirements.txt ./
RUN pip3 install --no-cache-dir --user -r requirements.txt
COPY . .
ENTRYPOINT ["/usr/bin/python3", "./app.py" ]
With this code I get the following error when trying to use a function that invokes ffmpeg functionality.
Traceback (most recent call last):
File "/root/.local/lib/python3.9/site-packages/pyrogram/dispatcher.py", line 240, in handler_worker
await handler.callback(self.client, *args)
File "/app/./app.py", line 274, in choice_from_inline
await helpers.trim_file(trim_length, "audio", chat_id_for_join.strip())
File "/app/helpers.py", line 53, in trim_file
output = ffmpeg.output(
File "/root/.local/lib/python3.9/site-packages/ffmpeg/_run.py", line 313, in run
process = run_async(
File "/root/.local/lib/python3.9/site-packages/ffmpeg/_run.py", line 284, in run_async
return subprocess.Popen(
File "/usr/lib/python3.9/subprocess.py", line 951, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/usr/lib/python3.9/subprocess.py", line 1823, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'ffmpeg'
Another issue is that when changing the ENTRYPOINT (or using CMD) to ["python3", "./app.py" ]
everything works well locally but as soon as I try to deploy, the deployment/docker container just doesn't work or crash because I get the error of ModuleNotFoundError: No module named 'ffmpeg'
.
I have already tried setting up different ENV PATH and ENV PYTHONPATH, does absolutely nothing.
I have tried to use COPY --from=jrottenberg/ffmpeg /usr/local ./
and it also doesn't work.
I have tried to explicitly use RUN apt-get install -y ffmpeg
and similar commands, pip, pip3, etc.. it just doesn't work.
I tried to use the copy command to access the /root/.local/lib/python3.9/site-packages/ffmpeg/_run.py
but I either get a permission denied or a file does not exist error.
I am also using the ffmpeg-python wrapper and am using a windows machine if that's of any importance.
At this point I'm contemplating of finding another way of implementing the functionality I want without using ffmpeg.
I think I added everything I had, if needed more I can provide.