Install ffmpeg on elastic beanstalk using ebextensions config

空扰寡人 提交于 2019-11-29 23:19:49
user3581244

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

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"
  04-ln:
    command: "if [[ ! -f /usr/bin/ffmpeg ]] ; then ln -sf /opt/ffmpeg/ffmpeg-3.4-64bit-static/ffmpeg /usr/bin/ffmpeg; fi"
  05-ln:
    command: "if [[ ! -f /usr/bin/ffprobe ]] ; then ln -sf /opt/ffmpeg/ffmpeg-3.4-64bit-static/ffprobe /usr/bin/ffprobe; fi"
  06-pecl:
    command: "if [ `pecl list | grep imagick` ] ; then pecl install -f imagick; fi"

Edit: Changed the commands to install a "more official" static build linked from the FFMPEG web site. Also, the former static build from Gusari does not seem available anymore.

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

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"

add the following to your .ebextensions/packages.config

packages:
  yum:
    ImageMagick: []

sources:
  /usr/local/bin: http://ffmpeg.org/releases/ffmpeg-4.1.tar.gz

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

Untested, but shouldn't it be

tar xzf /usr/local/bin/ffmpeg

without a minus?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!