Skip to content

Instantly share code, notes, and snippets.

@phonchi
Created May 19, 2017 00:24
Show Gist options
  • Save phonchi/d9756c48c9b04afaf54ed5ae9d0bb742 to your computer and use it in GitHub Desktop.
Save phonchi/d9756c48c9b04afaf54ed5ae9d0bb742 to your computer and use it in GitHub Desktop.
Intall FFmepg and OpenCV on AWS EMR
sudo yum -y update
sudo yum -y groupinstall 'Development Tools'
sudo yum install -y cmake git pkgconfig
sudo yum install -y libpng-devel libjpeg-turbo-devel jasper-devel openexr-devel libtiff-devel libwebp-devel
sudo yum install -y libdc1394-devel libv4l-devel gstreamer-plugins-base-devel
sudo yum install -y gtk2-devel
sudo yum install -y tbb-devel eigen3-devel
wget https://bootstrap.pypa.io/get-pip.py
sudo python get-pip.py
sudo yum install -y python-devel python3-dev python-numpy python3-numpy
cd ~
git clone https://github.com/Itseez/opencv.git
cd opencv
git checkout 3.1.0
cd ~
git clone https://github.com/Itseez/opencv_contrib.git
cd opencv_contrib
git checkout 3.1.0
cd ~/opencv
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE \
    -D CMAKE_INSTALL_PREFIX=/usr/local \
    -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules \
    -D INSTALL_C_EXAMPLES=OFF \
    -D INSTALL_PYTHON_EXAMPLES=ON \
    -D BUILD_EXAMPLES=ON \
    -D BUILD_OPENCV_PYTHON2=ON ..

sudo resize2fs /dev/xvda1 
make -j $(($(nproc) + 1))
sudo make install -j $(($(nproc) + 1))
sudo ldconfig
sudo cp /home/hadoop/opencv/build/lib/cv2.so /usr/local/lib/python2.7/site-packages/

sudo yum install -y autoconf automake bzip2 cmake freetype-devel gcc gcc-c++ git libtool make mercurial nasm pkgconfig zlib-devel
cd ~
mkdir ffmpeg_sources
cd ffmpeg_sources
git clone --depth 1 git://github.com/yasm/yasm.git
cd yasm
autoreconf -fiv
./configure 
sudo make -j $(($(nproc) + 1))
sudo make install -j $(($(nproc) + 1))

cd ~/ffmpeg_sources
git clone --depth 1 git://git.videolan.org/x264
cd x264
./configure --enable-shared
make -j $(($(nproc) + 1))
sudo make install -j $(($(nproc) + 1))

cd ~/ffmpeg_sources
hg clone https://bitbucket.org/multicoreware/x265
cd ~/ffmpeg_sources/x265/build/linux
cmake -G "Unix Makefiles" -DENABLE_SHARED:bool=on  ../../source
make -j $(($(nproc) + 1))
sudo make install -j $(($(nproc) + 1))


cd ~/ffmpeg_sources
git clone --depth 1 git://git.code.sf.net/p/opencore-amr/fdk-aac
cd fdk-aac
autoreconf -fiv
./configure --enable-shared
make -j $(($(nproc) + 1))
sudo make install -j $(($(nproc) + 1))

cd ~/ffmpeg_sources
curl -L -O http://downloads.sourceforge.net/project/lame/lame/3.99/lame-3.99.5.tar.gz
tar xzvf lame-3.99.5.tar.gz
cd lame-3.99.5
./configure --enable-shared --enable-nasm
make -j $(($(nproc) + 1))
sudo make install -j $(($(nproc) + 1))

cd ~/ffmpeg_sources
curl -O http://downloads.xiph.org/releases/ogg/libogg-1.3.2.tar.gz
tar xzvf libogg-1.3.2.tar.gz
cd libogg-1.3.2
./configure --enable-shared
make -j $(($(nproc) + 1))
sudo make install -j $(($(nproc) + 1))

export LD_LIBRARY_PATH=/usr/local/lib/
sudo ldconfig -vvvvv

cd ~/ffmpeg_sources
curl -O http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.5.tar.gz
tar xzvf libvorbis-1.3.5.tar.gz
cd libvorbis-1.3.5
./configure --enable-shared
make -j $(($(nproc) + 1))
sudo make install -j $(($(nproc) + 1))



cd ~/ffmpeg_sources
git clone --depth 1 https://chromium.googlesource.com/webm/libvpx.git
cd libvpx
./configure --enable-shared
make -j $(($(nproc) + 1))
sudo make install -j $(($(nproc) + 1))


export LD_LIBRARY_PATH=/usr/local/lib/
sudo ldconfig -vvvvv

cd ~/ffmpeg_sources
git clone https://github.com/FFmpeg/FFmpeg.git
cd FFmpeg
PKG_CONFIG_PATH="/usr/local/lib/pkgconfig/" ./configure --enable-shared --enable-gpl --enable-nonfree --enable-libfdk_aac --enable-libfreetype --enable-libmp3lame --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265
make -j $(($(nproc) + 1))
sudo make install -j $(($(nproc) + 1))

sudo rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-5.el7.nux.noarch.rpm
sudo yum install -y faac-devel

Note the pip has some issue on some of current AWS EMR machines. Use sudo easy_install --upgrade pip and sudo vim /usr/bin/pip change 6.0.x to 9.0.1.

Remember to add path into dynamic library search path echo "/usr/local/lib" >> /etc/ld.so.conf or export LD_LIBRARY_PATH=/usr/local/lib/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment