14

I'm attempting to install an up to date version of ffmpeg on an elastic beanstalk instance on amazon servers. I've created my config file and added these container_commands:

    container_commands:
        01-ffmpeg:
            command: wget -O/usr/local/bin/ffmpeg http://ffmpeg.gusari.org/static/64bit/ffmpeg.static.64bit.2014-03-05.tar.gz
            leader_only: false
        02-ffmpeg:
            command: tar -xzf /usr/local/bin/ffmpeg
            leader_only: false
        03-ffmpeg:
            command: ln -s /usr/local/bin/ffmpeg /usr/bin/ffmpeg
            leader_only: false

Command 01 and 03 seems to work perfectly but 02 doesn't seem to work so ffmpeg doesn't unzip. Any ideas what the issue might be?

Thanks, Helen

user3581244
  • 527
  • 4
  • 10
  • 1
    Any help from anyone who has successfully installed an up to date version of ffmpeg and imagick on an eb instance is also welcome, whether it's completely different to the above or not. – user3581244 Apr 29 '14 at 22:22

8 Answers8

32

A kind person at Amazon helped me out and sent me this config file that works, hopefully some other people will find this useful:

# .ebextensions/packages.config
packages:
  yum:
    ImageMagick: []
    ImageMagick-devel: []
commands:
  01-wget:
    command: "wget -O /tmp/ffmpeg.tar.xz https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz"
  02-mkdir:
    command: "if [ ! -d /opt/ffmpeg ] ; then mkdir -p /opt/ffmpeg; fi"
  03-tar:
    command: "tar xvf /tmp/ffmpeg.tar.xz -C /opt/ffmpeg"
  04-ln:
    command: "if [[ ! -f /usr/bin/ffmpeg ]] ; then ln -sf /opt/ffmpeg/ffmpeg-4.2.2-amd64-static/ffmpeg /usr/bin/ffmpeg; fi"
  05-ln:
    command: "if [[ ! -f /usr/bin/ffprobe ]] ; then ln -sf /opt/ffmpeg/ffmpeg-4.2.2-amd64-static/ffprobe /usr/bin/ffprobe; fi"
  06-pecl:
    command: "if [ `pecl list | grep imagick` ] ; then pecl install -f imagick; fi"

Edit:
The above code works for me today 2020-01-03, in Elastic Beanstalk environment Python 3.6 running on 64bit Amazon Linux/2.9.17.
https://johnvansickle.com/ffmpeg/ is linked from the official ffmpeg site.
(The former static build from Gusari does not seem available anymore.)

Warning:
The above will always download the latest release when you deploy. You're also depending on johnvansickle's site being online (to deploy), and his URL not changing. Two alternative approaches would be:

  • Download the .tar.xz file to your own CDN, and let your deployment download from your own site. (That way, if John's site has a moment of downtime while you're deploying, you're unaffected. And you won't be surprised by the ffmpeg version changing without you realising.)
  • Specify a version number like https://johnvansickle.com/ffmpeg/old-releases/ffmpeg-4.2.2-amd64-static.tar.xz.
Mark
  • 1,285
  • 1
  • 19
  • 28
user3581244
  • 527
  • 4
  • 10
  • Hi I'm having this issue while installing ffmpeg using this extension: any help would be appreciated. ` Yum does not have commands-06-pecl available for installation. Package listed in EBExtension failed to install` – Aleem Nov 30 '16 at 15:12
  • Can i know whats the file name and folder structure that we need place write these commands..? – Jegan Jan 06 '18 at 07:47
  • 1
    Works great! Just small change: `command: "wget -O /tmp/ffmpeg.tar.xz https://johnvansickle.com/ffmpeg/releases/ffmpeg-3.4.1-64bit-static.tar.xz" ` To make release version and directory name correspondent. – Sergey Mell Jan 10 '18 at 14:07
  • You should specify the lib version. – Barış Özçelik Feb 02 '18 at 10:26
  • Isn't it better to use the official website instead of the johnvansickle guy? https://ffmpeg.org/releases/ffmpeg-4.1.tar.gz – Joel Hernandez Aug 21 '19 at 11:11
  • I recommend downloading the .tar.xz to a website/CDN you control, so your source URL doesn't break if the URL path on johnvansickle changes in future. It seems the johnvansickle URL path changes from `/releases/...` to `/old-releases/...` for hard-coded versions. My notes: https://cdn2.awesound.com/build/ffmpeg/README-ffmpeg-on-elastic-beanstalk.md – Mark May 29 '20 at 12:18
8

You can use a static build from ffmpeg gusari and the sources syntax to automagically download and extract the binaries from a static build tar to /usr/local/bin. Here's an extremely simple example that has worked for me:

sources:
    /usr/local/bin: https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-64bit-static.tar.xz
Vinay
  • 6,204
  • 6
  • 38
  • 55
  • 1
    Much simpler. Thanks! – pztrick Mar 04 '16 at 17:06
  • 1
    Together we shall be gloriously lazy! – Vinay Mar 04 '16 at 22:05
  • 1
    Great idea. A few notes, though. Unfortunately that kind of link is not official, and risks to become obsolete. This link is dead, now. Another problem is security, when not officially supported. Note that the official FFMPEG site does provide [static builds](https://ffmpeg.org/download.html), although from a third party. Problem is the compression format is `xz`. EB accepts only ZIP and TAR (gz). – Eric Platon May 18 '17 at 00:59
  • how to add multiple sources? want to have ffmpeg and ffprobe together in that same directory. – Sizzling Code Apr 25 '18 at 08:09
  • 1
    @SizzlingCode ffprobe should be included in the static build. – Vinay Apr 26 '18 at 16:28
  • The static package download url no longer exists. – bdombro Sep 10 '18 at 17:32
  • 1
    @vinay thanks! That works. Btw, I've now decided to compile myself though, so I can get AAC support. – bdombro Oct 11 '18 at 14:09
  • @bdombro definitely! If you want more control, definitely build with the proper codec support you need. – Vinay Oct 11 '18 at 18:55
  • the new url is https://johnvansickle.com/ffmpeg/builds/ffmpeg-git-amd64-static.tar.xz – Zahid Riaz Sep 17 '21 at 02:51
4

The version is not specified in the first command "01-wget ..." however, it is specified when linking the files. Since the publication of this the release has been changed from "ffmpeg-3.3.1-64bit-static" to "ffmpeg-3.3.3-64bit-static" there are two solutions to fix this problem:

  1. specify the version for wget
  2. strip the containing directory on unpacking.

    03-tar: command: "tar xvf /tmp/ffmpeg.tar.xz -C /opt/ffmpeg --strip 1"

Here is the full script:

packages:
  yum:
    ImageMagick: []
    ImageMagick-devel: []
commands:
  01-wget:
    command: "wget -O /tmp/ffmpeg.tar.xz https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-64bit-static.tar.xz"
  02-mkdir:
    command: "if [ ! -d /opt/ffmpeg ] ; then mkdir -p /opt/ffmpeg; fi"
  03-tar:
    command: "tar xvf /tmp/ffmpeg.tar.xz -C /opt/ffmpeg --strip 1"
  04-ln:
    command: "if [[ ! -f /usr/bin/ffmpeg ]] ; then ln -s /opt/ffmpeg/ffmpeg /usr/bin/ffmpeg; fi"
  05-ln:
    command: "if [[ ! -f /usr/bin/ffprobe ]] ; then ln -s /opt/ffmpeg/ffprobe /usr/bin/ffprobe; fi"
  06-pecl:
    command: "if [ `pecl list | grep imagick` ] ; then pecl install -f imagick; fi"
3

add the following to your .ebextensions/packages.config

packages:
  yum:
    ImageMagick: []

sources:
  /usr/local/bin: http://ffmpeg.org/releases/ffmpeg-4.1.tar.gz
a14m
  • 7,808
  • 8
  • 50
  • 67
0

Check cloud-init logs for messages. On a Linux instance, that would be:

grep "03-ffmpeg" /var/log/eb-cfn-init.log

Also, you can log to another file to make errors easier to find:

command: ln -s /usr/local/bin/ffmpeg /usr/bin/ffmpeg >> /var/log/my-init.log
Julio Faerman
  • 13,228
  • 9
  • 57
  • 75
0

Untested, but shouldn't it be

tar xzf /usr/local/bin/ffmpeg

without a minus?

marco
  • 685
  • 4
  • 18
0

In case there are others out there that prefers compiling from source, herewith steps I've actioned to do so (this worked for me using a Java Application with Maven)

  1. Inside your project root directory, create a ".ebextensions" folder containing a file name of your convenience but it must have the extension of ".config" (see example picture) example-ebextensions-config-file
  2. Specify the following as the contents of the .ebextensions/yourfilename.config file
packages:
    yum:
        autoconf: []
        automake: []
        cmake: []
        freetype-devel: []
        gcc: []
        gcc-c++: []
        git: []
        libtool: []
        make: []
        nasm: []
        pkgconfig: []
        zlib-devel: []
        ImageMagick: []
        ImageMagick-devel: []
commands:
    01-mkdir:
        command: |
            if [ ! -d /opt/bin ] ; then mkdir -p /opt/bin; fi
            if [ ! -d /opt/ffmpeg ] ; then mkdir -p /opt/ffmpeg; fi
            if [ ! -d /opt/ffmpeg/ffmpeg-5.1-build ] ; then mkdir -p /opt/ffmpeg/ffmpeg-5.1-build; fi
    02-wget:
        command: |
            if [ ! -d /opt/ffmpeg/ffmpeg-5.1 ] ; then
                if [ ! -d /tmp/ffmpeg-5.1.tar.gz ] ; then wget -O /tmp/ffmpeg-5.1.tar.gz https://ffmpeg.org/releases/ffmpeg-5.1.tar.gz; fi
                tar xvf /tmp/ffmpeg-5.1.tar.gz -C /opt/ffmpeg
            fi
    03-configure:
        cwd: /opt/ffmpeg/ffmpeg-5.1
        command: |
            if [[ ! -f /opt/bin/ffmpeg ]] ; then
                PKG_CONFIG_PATH="/opt/ffmpeg/ffmpeg-5.1-build/lib/pkgconfig" \
                ./configure \
                --prefix="/opt/ffmpeg/ffmpeg-5.1-build" \
                --pkg-config-flags="--static" \
                --bindir="/opt/ffmpeg/ffmpeg-5.1-build/bin" \
                --enable-gpl \
                --enable-libx264 \
            fi
    04-make:
        cwd: /opt/ffmpeg/ffmpeg-5.1
        command: |
            if [[ ! -f /opt/bin/ffmpeg ]] ; then
                make && make install
            fi
    05-link:
        command: if [[ ! -f /usr/bin/ffmpeg ]] ; then ln -sf /opt/ffmpeg/ffmpeg-5.1-build/bin/ffmpeg /usr/bin/ffmpeg; fi

Herewith a summary of the steps that will be executed when your update is deployed to elastic beanstalk

  1. Packages will be configured on your instance e.g in case your instance doesn't have cmake, it will be installed as per the "packages" section as per the configuration in .ebextensions/yourfilename.config file
  2. Once all dependencies are resolved, the commands section will execute (I've discovered that they don't depend on one another e.g. if step#1 fails, step#2 will still be executed)
  3. Command 01: Creates directories where your files will be unarchived to (amongst other things)
  4. Command 02: Downloads the tar from the release website, places it into your instance's temp folder then unarchives it into your instance's /opt/ffmpeg/ folder. It's worth mentioning that the archive contains a folder "ffmpeg-5.1". Thus, when it's unarchived, you'll have a directory "/opt/ffmpeg/ffmpeg-5.1". This entire step won't execute if the folder "/opt/ffmpeg/ffmpeg-5.1" already exists i.e. this step was most likely executed during a previous deploy/update to your instance
  5. Command 03 & Command 04: Configures ffmpeg. You can checkout the ffmpeg documentation for different configurations as per your requirement
  6. Command 05: Creates a symlink from the installation directory to your usr/bin folder. This is required as the /opt directory is not managed by your ec2-user (requires root access) and therefor when you run ffmpeg from /opt or its subdirectories, your Java application may throw an Access Denied or Permission relates issues
Eesa Jacobs
  • 81
  • 1
  • 3
0

This one worked fine with me, installed last ffmpeg version on AWS Elastic Beanstalk, just generate a folder with the name .ebextensions and name this file as: ffmpeg.config

# .ebextensions/ffmpeg.config

packages:
  yum:
    autoconf: []
    automake: []
    cmake: []
    freetype-devel: []
    gcc: []
    gcc-c++: []
    git: []
    libtool: []
    make: []
    nasm: []
    pkgconfig: []
    zlib-devel: []
sources:
  /usr/local/src: http://ffmpeg.org/releases/ffmpeg-4.2.9.tar.bz2
commands:
  ffmpeg_install:
      cwd: /usr/local/src/ffmpeg-4.2.9
      command: sudo ./configure --prefix=/usr && make && make install