linux 设置ffmpeg权限,linux安装ffmpeg最全配置步骤

#!/bin/bash

# Bash script to install latest version of ffmpeg and its dependencies on Ubuntu 12.04 or 14.04

# Inspired from https://gist.github.com/faleev/3435377

# Remove any existing packages:

sudo apt-get -y remove ffmpeg x264 libav-tools libvpx-dev libx264-dev

# Get the dependencies (Ubuntu Server or headless users):

sudo apt-get update

sudo apt-get -y install build-essential checkinstall git libfaac-dev libgpac-dev \

libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev librtmp-dev libtheora-dev \

libvorbis-dev pkg-config texi2html yasm zlib1g-dev

# Install x264

sudo apt-get -y install libx264-dev

cd

git clone --depth 1 git://git.videolan.org/x264

cd x264

./configure --enable-static

make

sudo checkinstall --pkgname=x264 --pkgversion="3:$(./version.sh | \

awk -F'[" ]' '/POINT/{print $4"+git"$5}')" --backup=no --deldoc=yes \

--fstrans=no --default

# Install AAC audio decoder

cd

wget http://downloads.sourceforge.net/opencore-amr/fdk-aac-0.1.0.tar.gz

tar xzvf fdk-aac-0.1.0.tar.gz

cd fdk-aac-0.1.0

./configure

make

sudo checkinstall --pkgname=fdk-aac --pkgversion="0.1.0" --backup=no \

--deldoc=yes --fstrans=no --default

# Install VP8 video encoder and decoder.

cd

git clone --depth 1 https://chromium.googlesource.com/webm/libvpx

cd libvpx

./configure

make

sudo checkinstall --pkgname=libvpx --pkgversion="1:$(date +%Y%m%d%H%M)-git" --backup=no \

--deldoc=yes --fstrans=no --default

# Add lavf support to x264

# This allows x264 to accept just about any input that FFmpeg can handle and is useful if you want to use x264 directly. See a more detailed explanation of what this means.

cd ~/x264

make distclean

./configure --enable-static

make

sudo checkinstall --pkgname=x264 --pkgversion="3:$(./version.sh | \

awk -F'[" ]' '/POINT/{print $4"+git"$5}')" --backup=no --deldoc=yes \

--fstrans=no --default

#downloaded rtmpdump

http://rtmpdump.mplayerhq.hu/

git clone git://git.ffmpeg.org/rtmpdump

cd rtmpdump

为了得到调试信息,这里简单修改一下文件夹rtmpdump和librtmp的Makefile文件,添加-g参数,注意去掉优化参数-O2那项

在rtmpdump的Makefile中的

OPT=-O2

CFLAGS=-Wall -g $(XCFLAGS) $(INC) $(DEF) $(OPT)

在librtmp的Makefile中的

CFLAGS=-Wall ....  -g

2.安装相关依赖类

需要用到的依赖库是zlib, openssl库,使用如下命令安装

sudo apt-get install openssl

sudo apt-get install libssl-dev

sudo apt-get install zlib1g-dev

可以先查看可用的安装包

sudo apt-cache search openssl

通过阅读Makefile文件,我发现rtmpdump需要引用的动态库如下

-lz -lssl -lcrypto -lrtmp -lpthread

make后会生成4个可执行文件, 分别是rtmpdump,rtmpsvr, rtmpsuck, rtmpgw, 其中pthread直会在rtmpsvr, rtmpsuck, rtmpgw这3个程序中用到.

3.编译安装

make

sudo make install

首先要保证相关库已经成功安装到/usr/local/lib下面

再要保证/usr/local/lib在/etc/ld.so.conf配置文件中,然后

sudo ldconfig

来更新动态库缓存

检查rtmpdump所有依赖库是否都引用成功

ldd rtmpdump

#downloaded libogg

wget https://downloads.xiph.org/releases/ogg/libogg-1.3.2.tar.xz

Installation of libogg

Install libogg by running the following commands:

./configure --prefix=/usr    \

--disable-static \

--docdir=/usr/share/doc/libogg-1.3.2 &&

make

To test the results, issue: make check.

Now, as the root user:

make install

#downloaded libvorbis-1.3.5

wget https://downloads.xiph.org/releases/vorbis/libvorbis-1.3.5.tar.xz

Installation of libvorbis

Optionally fix installation of the package when --enable-docs is added to the configure switches:

sed -i '/components.png \\/{n;d}' doc/Makefile.in

Install libvorbis by running the following commands:

./configure --prefix=/usr --disable-static &&

make

To test the results, issue: make LIBS=-lm check.

Now, as the root user:

make install &&

install -v -m644 doc/Vorbis* /usr/share/doc/libvorbis-1.3.5

#downloaded libtheora

wget https://downloads.xiph.org/releases/theora/libtheora-1.1.1.tar.xz

Installation of libtheora

Install libtheora by running the following commands:

sed -i 's/png_\(sizeof\)/\1/g' examples/png2theora.c &&

./configure --prefix=/usr --disable-static &&

make

If you wish to run the tests, issue: make check.

Now, as the root user:

make install

# Installing FFmpeg

cd

git clone --depth 1 git://source.ffmpeg.org/ffmpeg

cd ffmpeg

./configure --enable-gpl --enable-libfdk-aac --enable-libmp3lame

--enable-libopencore-amrnb   --enable-libopencore-amrwb --enable-librtmp

--enable-libtheora --enable-libvorbis     --enable-libvpx --enable-libx264

--enable-nonfree --enable-version3

make

sudo checkinstall --pkgname=ffmpeg --pkgversion="5:$(date +%Y%m%d%H%M)-git" --backup=no \

--deldoc=yes --fstrans=no --default

hash x264 ffmpeg ffplay ffprobe

# Optional: install qt-faststart

# This is a useful tool if you're showing your H.264 in MP4 videos on the web. It relocates some data in the video to allow playback to begin before the file is completely downloaded. Usage: qt-faststart input.mp4 output.mp4.

cd ~/ffmpeg

make tools/qt-faststart

sudo checkinstall --pkgname=qt-faststart --pkgversion="$(date +%Y%m%d%H%M)-git" --backup=no \

--deldoc=yes --fstrans=no --default install -Dm755 tools/qt-faststart \

/usr/local/bin/qt-faststart

我用一段转码测试了一下

#ffmpeg -i file.avi output.flv

发现报了一个库找不到的错

0197248f79230608d3a57db683355235.png

去搜索了一下相关问题

0b2e97b7b724a7e492257098a8f76e1d.png

于是乎我就

782b98e1ee48cd9a5077bb46cd4561ef.png

软链接了一下,再次测试就通过了

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值