Install FFMPEG in the v2

I am fairly new to, my python backend deploys using the default settings without any problem by using the flyctl launch.
However, i want to use a python module that uses ffmpeg, i suppose the linux command will be apt-get update && apt-get install -y ffmpeg libavcodec-extra.

I tried to add a section in fly.toml but it doesnt seem to do much.

# Install FFmpeg using the package manager
command = "apt-get update && apt-get install -y ffmpeg libavcodec-extra"

Could anyone shine some light? I am using the default builder option, btw. Do i have to make my own dockerfile etc?

builder = "paketobuildpacks/builder:base"

I don’t think there is an easy “official” way to install packages without a custom Dockerfile (I can’t find any documentation for “build.pre” in fly.toml).

However, there is an unofficial buildpack called fagiani/apt that might be useful – just add the line buildpacks = ["fagiani/apt"] to your fly.toml in the [build] section and create a file called Aptfile with the names of your packages. That should get the job done ;‍)

(Note that this buildpack doesn’t install the packages using apt-get directly and instead extracts them into a custom location. The packages won’t show up in the output of dpkg -l, but they should still be usable because the buildpack sets PATH, LD_LIBRARY_PATH etc. to include that custom location.)

For completeness, I’ll mention that it’s relatively easy to create a custom local buildpack, however installing apt packages is difficult because the build script doesn’t run as root (and can only output to the app directory or to a layer). Here is a minimal example.


  builder = "paketobuildpacks/builder:base"
  buildpacks = ["./buildpack"]


api = "0.9"

id = "local.buildpack"
version = "0.0.1"

id = "*"


exit 0


set -eu
# write your custom build commands here

I end up using a simple dockerfile.

FROM python:3.9-bullseye


COPY ./ /code/

# install dependencies
RUN apt-get update && apt-get install -y ffmpeg libavcodec-extra libssl-dev libasound2

# use pipenv to install dependencies
RUN pip3 install pipenv
RUN pipenv install --system --deploy --ignore-pipfile

CMD ["uvicorn", "main:app", "--host", "", "--port", "8080"]

This is my Dockerfile for Node. Works like a charm.

FROM node:18-alpine3.15

USER root

RUN apk add -u ffmpeg

WORKDIR /usr/src/app

COPY package.json .
COPY package-lock.json .
RUN npm i --production

COPY . .

ENV NODE_ENV production

CMD ["node", "src/index.js"]
1 Like

Hi Pier!

How do you use ffmpeg in nodejs code?

I just use spawn() as if I was using FFmpeg from the command line.

1 Like

I deleted my app and relaunched it using fly launch instead of flyctl launch and it works like a charm thank you!