[TOC]

概述

Ubuntu环境搭建

安装指定版本

下载固定版本源码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
wget -c http://ffmpeg.org/releases/ffmpeg-3.4.11.tar.xz

cd ffmpeg-3.4.11/
sudo apt-get update

##安装依赖包
sudo apt-get -y install autoconf automake build-essential \
libass-dev libfreetype6-dev libsdl2-dev libtheora-dev \
libtool libva-dev libvdpau-dev libvorbis-dev libxcb1-dev \
libxcb-shm0-dev libxcb-xfixes0-dev pkg-config texinfo zlib1g-dev

##配置(生成动态库和指定安装位置)
./configure --enable-shared --prefix=/usr/local/ffmpeg

##编译安装
make -j2
make install

设置环境变量

1
2
3
# >>> FFMpeg  >>>
export LD_LIBRARY_PATH=/usr/local/ffmpeg/lib:$LD_LIBRARY_PATH
# <<< FFMpeg <<<

卸载ffmpeg

如果你像我一样,使用 apt-get install ffmpeg,不好意思,很大可能装的版本并不是最新版,因此可以使用以下命令卸载它:

1
2
sudo apt-get --purge remove ffmpeg
sudo apt-get --purge autoremove

如果你使用的是总网上下载安装包,然后编译安装的方法,则需要使用以下的方式卸载,此处以ffmpeg-4.1为例:

1
2
3
4
cd ffmpeg-4.1
make uninstall ##删除由make install命令安装的文件
make clean ##只删除make时产生的临时文件
make distclean ##同时删除configure和make产生的临时文件

问题解决

1
2
3
4
5
6
7
8
baiduiov@FreweniUbuntuBaidu:~/tools/ffmpeg-3.4.11$ ./configure --enable-shared --prefix=/usr/local/ffmpeg
nasm/yasm not found or too old. Use --disable-x86asm for a crippled build.

If you think configure made a mistake, make sure you are using the latest
version from Git. If the latest version fails, report the problem to the
ffmpeg-user@ffmpeg.org mailing list or IRC #ffmpeg on irc.libera.chat.
Include the log file "ffbuild/config.log" produced by configure as this will help
solve the problem.

文章参考:https://www.cpming.top/p/ffmpeg-nasm-yasm-not-found-or-too-old