T.Poe
T.Poe

Reputation: 2089

How to install ffmpeg in a docker container

I'm using aeneas python module which uses ffmpeg. I install ffmpeg in the dockerfile as follows:

RUN apt-get update && apt-get install -y ffmpeg

Now when I run the program, it fails with:

aeneas.ffprobewrapper.FFPROBEPathError: Unable to call the 'ffprobe' ffprobe executable : [Errno 2] No such file or directory: 'ffprobe'

and

aeneas.audiofile.AudioFileProbeError: Unable to call ffprobe executable

So my question is, how can I successfully use ffmpeg in a docker container? I'm running Ubuntu 16.04.

Upvotes: 12

Views: 36119

Answers (4)

ozgeneral
ozgeneral

Reputation: 6809

you can also find a compiled version somewhere online and use it like so:

RUN wget https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-i686-static.tar.xz
RUN tar -xvf ffmpeg-release-i686-static.tar.xz
RUN mv ffmpeg-7.0.2-i686-static/ffmpeg /usr/local/bin/
RUN mv ffmpeg-7.0.2-i686-static/ffprobe /usr/local/bin/

Upvotes: 0

Matt
Matt

Reputation: 1038

You can do it if you have linux. Or anywhere you can install X (haven't tested it). Basic idea is that linux is using X11, so you can fart out X data to your host machine's X server.

Dockerfile

FROM ubuntu:latest
RUN apt-get update -qq && apt-get install ffmpeg -y
ENTRYPOINT ["ffplay"]

Build that with

docker build -t ffplay:latest .

play.sh

docker run \
  --rm \
  -u `id -u` \
  -e DISPLAY \
  -v /tmp/.X11-unix:/tmp/.X11-unix \
  -v "$HOME/Desktop:/media" \
  ffplay:latest \
  -i /media/test.mp4

Upvotes: 3

James Bond
James Bond

Reputation: 3006

Install fresh ffmpeg version from sources in docker container on Debian 9/10/Ubuntu.

You can replace 4.2.2 version to any other available on https://ffmpeg.org/releases/

# Compile and install fresh ffmpeg from sources:
# See: https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu
RUN apt-get update -qq && apt-get -y install \
      autoconf \
      automake \
      build-essential \
      cmake \
      git-core \
      libass-dev \
      libfreetype6-dev \
      libsdl2-dev \
      libtool \
      libva-dev \
      libvdpau-dev \
      libvorbis-dev \
      libxcb1-dev \
      libxcb-shm0-dev \
      libxcb-xfixes0-dev \
      pkg-config \
      texinfo \
      wget \
      zlib1g-dev \
      nasm \
      yasm \
      libx265-dev \
      libnuma-dev \
      libvpx-dev \
      libmp3lame-dev \
      libopus-dev \
      libx264-dev \
      libfdk-aac-dev
RUN mkdir -p ~/ffmpeg_sources ~/bin && cd ~/ffmpeg_sources && \
    wget -O ffmpeg-4.2.2.tar.bz2 https://ffmpeg.org/releases/ffmpeg-4.2.2.tar.bz2 && \
    tar xjvf ffmpeg-4.2.2.tar.bz2 && \
    cd ffmpeg-4.2.2 && \
    PATH="$HOME/bin:$PATH" PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" ./configure \
      --prefix="$HOME/ffmpeg_build" \
      --pkg-config-flags="--static" \
      --extra-cflags="-I$HOME/ffmpeg_build/include" \
      --extra-ldflags="-L$HOME/ffmpeg_build/lib" \
      --extra-libs="-lpthread -lm" \
      --bindir="$HOME/bin" \
      --enable-libfdk-aac \
      --enable-gpl \
      --enable-libass \
      --enable-libfreetype \
      --enable-libmp3lame \
      --enable-libopus \
      --enable-libvorbis \
      --enable-libvpx \
      --enable-libx264 \
      --enable-libx265 \
      --enable-nonfree && \
    PATH="$HOME/bin:$PATH" make -j8 && \
    make install -j8 && \
    hash -r
RUN mv ~/bin/ffmpeg /usr/local/bin && mv ~/bin/ffprobe /usr/local/bin && mv ~/bin/ffplay /usr/local/bin

Upvotes: 7

Linux In Practice
Linux In Practice

Reputation: 33

It could be faulty library, then this should help:

apt-get install ffmpeg libavcodec-extra-53

If not it can be path problem:

$ffmpeg = FFMpeg\FFMpeg::create(array(
 'ffmpeg.binaries'  => '/usr/bin/ffmpeg',
 'ffprobe.binaries' => '/usr/bin/ffprobe'));

The similar issue resolved here: https://github.com/PHP-FFMpeg/PHP-FFMpeg/issues/172 in the last message on the bottom of the website.

Upvotes: 0

Related Questions