Question

How can I install FFMpeg in my Digital Ocean app?

I am getting a server error(500) when I try to upload videos in mu Django app in production. The videos can upload in development. I ran my app with DEBUG set to True, and I got this detailed error on the browser(chrome)

FileNotFoundError at / [Errno 2] No such file or directory: 'ffmpeg' Request Method: POST Request URL: https://www.sportsfamly.com/ Django Version: 4.2.7 Exception Type: FileNotFoundError Exception Value: [Errno 2] No such file or directory: 'ffmpeg' Exception Location: /workspace/.heroku/python/lib/python3.11/subprocess.py, line 1950, in _execute_child Raised during: feed.views.feed Python Executable: /app/.heroku/python/bin/python Python Version: 3.11.5 Python Path: ['/workspace/.heroku/python/bin', '/workspace', '/workspace/.heroku/python/lib/python311.zip', '/workspace/.heroku/python/lib/python3.11', '/workspace/.heroku/python/lib/python3.11/lib-dynload', '/workspace/.heroku/python/lib/python3.11/site-packages'] Server time: Sun, 04 Feb 2024 04:37:29 +0000

I assume I have to install FFMpeg into the DO server via the console, which I did and it said its already satisfied, but when I run version it is not recognized:

apps@sportsfamly-d8d4bdb8b-dh5wv:~$ pip install FFMpeg
Requirement already satisfied: FFMpeg in ./.heroku/python/lib/python3.11/site-packages (1.4)

[notice] A new release of pip is available: 23.2.1 -> 24.0
[notice] To update, run: pip install --upgrade pip
apps@sportsfamly-d8d4bdb8b-dh5wv:~$ FFMpeg -version
bash: FFMpeg: command not found

When I try to install FFMpeg with sudo apt it says permission denied

apps@sportsfamly-d8d4bdb8b-dh5wv:~$ sudo apt update
bash: sudo: command not found
apps@sportsfamly-d8d4bdb8b-dh5wv:~$ sudo apt install ffmpeg
bash: sudo: command not found

So how can I install FFMpeg as I need my users to upload videos on my app?

Is Digital Ocean able to install FFMpeg for me from your end?

Show comments

Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

KFSys
Site Moderator
Site Moderator badge
February 5, 2024

Heya @geochanto,

To build on what already has been said in the thread, here is a similar question you can check from 2 years prior :

https://www.digitalocean.com/community/questions/how-to-install-ffmpeg-on-app-platform

It should help with figuring out how to proceed.

Bobby Iliev
Site Moderator
Site Moderator badge
February 4, 2024

Hello Chris,

The core of the problem lies in the difference between your development and production environments, especially regarding how external dependencies are managed in a containerized platform like DigitalOcean’s.

First, it’s essential to clarify that when you’re trying to use pip install FFmpeg, it doesn’t actually install the FFmpeg binary; instead, it might be installing a Python package related to FFmpeg, which doesn’t provide the FFmpeg command-line tool itself.

The error you’re encountering (FileNotFoundError: [Errno 2] No such file or directory: 'ffmpeg') indicates that the FFmpeg binary is not present in your app’s execution environment.

DigitalOcean App Platform uses buildpacks or Docker containers to deploy applications. For Python apps, it typically uses buildpacks, which automate the deployment process but can limit control over the environment. However installing custom binaries when using the native buildpacks is currently not supported.

The most flexible solution is to use Docker. You can create a Dockerfile for your Django application where you specify all the necessary dependencies, including FFmpeg:

https://docs.digitalocean.com/products/app-platform/reference/dockerfile/

Here’s a basic example of what your Dockerfile might look like:

FROM python:3.11
RUN apt-get update && apt-get install -y ffmpeg
# Copy your application code and install Python dependencies
COPY . /app
WORKDIR /app
RUN pip install -r requirements.txt
CMD ["gunicorn", "your_project.wsgi:application", "--bind", "0.0.0.0:8000"]

This Dockerfile updates the package list for the Debian-based Python image, installs FFmpeg, and then proceeds with the usual steps to deploy a Django app.

Once your Dockerfile is ready, you can configure your DigitalOcean app to deploy from a Docker container. This approach gives you full control over the environment, including the ability to install FFmpeg and any other custom dependencies that you might need.

Hope that this helps and let me know how it goes!

Best,

Bobby

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel