dockerffmpegfluent-ffmpeg

Could not find ffmpeg executable, tried "/srv/linux-x64/ffmpeg"


I am trying to run my docker image on AWS EC2 Instance. However, I am having a trouble with the image file. When I run a task in AWS ECS, it says:

Could not find ffmpeg executable, tried "/srv/linux-x64/ffmpeg", "/srv/app/node_modules/@ffmpeg-installer/linux-x64/ffmpeg" and "/srv/app/node_modules/@ffmpeg-installer/linux-x64/ffmpeg"

This is my Dockerfile:

FROM node:latest as server
WORKDIR /srv/app
COPY ./server/package*.json ./
RUN apt-get update && apt-get install -y 'ffmpeg'
RUN npm install
COPY ./server .
RUN npm run build

FROM node:latest as client
WORKDIR /srv/app
COPY ./client/package*.json ./
RUN npm install
COPY ./client .
RUN npm run build

FROM node:latest as production
WORKDIR /srv/app
RUN mkdir /public
COPY --from=server /srv/app/dist ./
COPY --from=client /srv/app/dist ./public
ENV NODE_ENV=production
EXPOSE 5000
CMD ["node", "app.js"]

This is my package.json:

  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@ffmpeg-installer/ffmpeg": "^1.1.0",
    "@types/ffmpeg": "^1.0.7",
    "@types/fluent-ffmpeg": "^2.1.24"
  }

This is how I used ffmpeg in my code:

import ffmpegPath from '@ffmpeg-installer/ffmpeg';
import ffmpeg from 'fluent-ffmpeg';
ffmpeg.setFfmpegPath(ffmpegPath.path);

Please help me fix this error.


Solution

  • @pdoherty926 was right. You have to install ffmpeg to all the images or at least the images that are using it and the production one. But in addition, you also have to change your code from: ffmpeg.setFfmpegPath(ffmpegPath.path); to ffmpeg.setFfmpegPath('/usr/bin/ffmpeg');

    This code might give you errors when running in your machine in dev mode but it should work when you run the docker image on EC2 Instance.