音视频环境安装

##!/bin/bash

##安装python3.6

echo "安装python3.6"

cd /opt/ && wget https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tar.xz

tar xvf Python-3.6.1.tar.xz

mv Python-3.6.1 /usr/local/src/

cd /usr/local/src/Python-3.6.1/

yum -y install wget sqlite-devel xz gcc automake zlib-devel openssl-devel epel-release git

yum install gcc c++ make cmake bzip2  -y

./configure --prefix=/usr/local/python3

make

make install

cd /usr/local/python3/bin

ln -s /usr/local/python3/bin/python3.6 /usr/bin/python3

##安装pip3

echo "安装pip3"

echo "下载安装setuptools"

cd /opt

wget --no-check-certificate  https://pypi.python.org/packages/source/s/setuptools/setuptools-19.6.tar.gz#md5=c607dd118eae682c44ed146367a17e26

tar zxvf setuptools-19.6.tar.gz -C /usr/local/src

cd /usr/local/src/setuptools-19.6

python3 setup.py build

python3 setup.py install

echo "下载安装pip3"

wget --no-check-certificate  https://pypi.python.org/packages/source/p/pip/pip-8.0.2.tar.gz#md5=3a73c4188f8dbad6a1e6f6d44d117eeb

tar -zxvf pip-8.0.2.tar.gz -C /usr/local/src

cd /usr/local/src/pip-8.0.2

python3 setup.py build

python3 setup.py install

ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3

echo "pip3安装完成"

echo "安装you-get"

pip3 install you-get

###安装ffmpeg(音频视频提取)

echo "安装ffmpeg"

cd /opt/

wget https://ffmpeg.org/releases/ffmpeg-4.0.2.tar.bz2

wget http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz

tar zxvf yasm-1.3.0.tar.gz -C /usr/local/src

cd /usr/local/src/yasm-1.3.0

./configure

make

make install

cd /opt

yum install bzip2

tar jxvf ffmpeg-4.0.2.tar.bz2

mv ffmpeg-4.0.2 /usr/local/src/

cd /usr/local/src/

cd ffmpeg-4.0.2/

./configure --enable-shared --prefix=/usr/local/ffmpeg

make

make install

echo "验证"

echo "/usr/local/ffmpeg/lib" >> /etc/ld.so.conf.d/ffmpeg.conf

cd /usr/local/ffmpeg/bin

###运行

###./ffmpeg -version

###报错:

###libavdevice.so.57: cannot open shared object file: No such file or directory,原因是lib目录未加载到链接到系统库中

###解决:

###vim /etc/ld.so.conf.d/ffmpeg.conf

###加入  /usr/local/ffmpeg/lib

###保存

echo "使配置生效ldconfig"

ldconfig

###运行

./ffmpeg -version

sleep 3

###vim /etc/profile

###加入: 

echo "传入环境变量""

####ffmpeg

echo "#ffmpeg" >> /etc/profile

###echo "export FFMPEG_HOME=/usr/local/ffmpeg/" >> /etc/profile

###echo "export PATH=$PATH:$FFMPEG_HOME/bin" >> /etc/profile

echo "export PATH=/usr/local/ffmpeg/bin:$PATH" >> /etc/profile

source /etc/profile

###音频格式转换测试:

###ffmpeg -i test.avi out.mp4

###opencv安装(视频提取)

echo "opencv安装"

yum install  gcc  gcc-c++ cmake* unzip -y

##yum install cmake gcc gcc-c++ gimp-devel gimp-devel-tools gimp-help-browser zlib-devel libtiff-devel libjpeg-devel libpng-devel gstreamer-devel libavc1394-devel libraw1394-devel libdc1394-devel jasper-devel jasper-utils swig  libtool nasm build-essential unzip

###gtk2.0使用yum安装

echo "gtk2.0使用yum安装"

yum install gtk2-devel -y

###安装ant,使得opencv编译java接口包

echo "安装ant,使得opencv编译java接口包"

yum install ant -y

##下载opencv安装包

echo "下载opencv安装包"

cd /opt

wget https://github.com/opencv/opencv/archive/3.4.1.zip

unzip 3.4.1.zip

mv opencv-3.4.1 /usr/local/src/

cd /usr/local/src/opencv-3.4.1

###判断文件是否存在CMakeCache.txt

echo "判断文件是否存在CMakeCache.txt,存在则删除"

if [ -f "/usr/local/src/opencv-3.4.1/CMakeCache.txt" ];then

echo "文件存在"

echo "rm -rf /usr/local/src/opencv-3.4.1/CMakeCache.txt"

else

echo "文件不存在"

fi

echo "创建build目录"

mkdir build

cd build

##编译

cmake -DBUILD_SHARED_LIBS=OFF -DBUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=/usr/local/opencv ..

###(如果报错:FATAL: In-source builds are not allowed , You should create a separate directory for build files.

###则把 opencv3.4.1/cMakeCache.txt 删除后再试)

###(IPPICV: Download: ippicv_2017u2_lnx_intel64_20170418.tgz ,速度有点慢,多等一会儿)

make

make install

ln -s /usr/local/src/opencv-3.4.1/build/lib/libopencv_java341.so /usr/local/lib/libopencv_java341.so

echo "安装完成"

echo "python3.6 pip3 ffmpeg4.0.2 opencv3.4.1已安装完成"

你可能感兴趣的:(音视频环境安装)