linux安装ffmpeg的详细步骤

发布时间:2021-08-16 23:44:00 作者:chen
来源:亿速云 阅读:124

本篇内容介绍了“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  

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

linux安装ffmpeg的详细步骤

去搜索了一下相关问题

linux安装ffmpeg的详细步骤

于是乎我就

linux安装ffmpeg的详细步骤

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

“linux安装ffmpeg的详细步骤”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注亿速云网站,小编将为大家输出更多高质量的实用文章!

推荐阅读:
  1. 安装mysql的详细步骤
  2. Linux安装phpMyAdmin详细步骤

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

linux

上一篇:KVM虚拟机怎么扩展磁盘空间

下一篇:怎么利用rman传输表空间

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》