https://blog.csdn.net/LclLsh/article/details/131770203
1:官网下载ffmpeg
https://ffmpeg.org//download.html
wcx@wcx:~/Downloads$ cd ffmpeg-6.1.1/
wcx@wcx:~/Downloads/ffmpeg-6.1.1$ ./configure --prefix="/usr/local/ffmpeg/" \
> --enable-gpl \
> --enable-nonfree \
> --enable-ffplay \
> --enable-libfdk-aac \
> --enable-libmp3lame \
> --enable-libx264 \
> --enable-libx265 \
> --enable-filter=delogo \
> --enable-debug \
> --disable-optimizations \
> --enable-libspeex \
> --enable-shared \
> --enable-pthreads \
> --enable-version3 \
> --enable-hardcoded-tables \
> --extra-ldflags=-L/usr/local/ffmpeg/lib
nasm/yasm not found or too old. Use --disable-x86asm for a crippled build.
安装yasm
wcx@wcx:~/Downloads/ffmpeg-6.1.1$ sudo apt-get install yasm
[sudo] password for wcx:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
yasm
0 upgraded, 1 newly installed, 0 to remove and 8 not upgraded.
Need to get 408 kB of archives.
After this operation, 2,180 kB of additional disk space will be used.
Get:1 http://mirrors.tuna.tsinghua.edu.cn/ubuntu focal/universe amd64 yasm amd64 1.3.0-2ubuntu1 [408 kB]
Fetched 408 kB in 1s (375 kB/s)
Selecting previously unselected package yasm.
(Reading database ... 249590 files and directories currently installed.)
Preparing to unpack .../yasm_1.3.0-2ubuntu1_amd64.deb ...
Unpacking yasm (1.3.0-2ubuntu1) ...
Setting up yasm (1.3.0-2ubuntu1) ...
Processing triggers for man-db (2.9.1-1) ...
wcx@wcx:~/Downloads/ffmpeg-6.1.1$ ./configure --prefix="/usr/local/ffmpeg/" --enable-gpl --enable-nonfree --enable-ffplay --enable-libfdk-aac --enable-libmp3lame --enable-libx264 --enable-libx265 --enable-filter=delogo --enable-debug --disable-optimizations --enable-libspeex --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --extra-ldflags=-L/usr/local/ffmpeg/lib
ERROR: libfdk_aac not found
2:安装fdk_aac
下载地址 https://sourceforge.net/projects/opencore-amr/files/fdk-aac/
wcx@wcx:~/Downloads$ cd fdk-aac-2.0.2/
wcx@wcx:~/Downloads/fdk-aac-2.0.2$ ./configure --prefix=/usr/local/ffmpeg --enable-shared
wcx@wcx:~/Downloads/fdk-aac-2.0.2$ sudo make install
make[1]: Entering directory '/home/wcx/Downloads/fdk-aac-2.0.2'
/usr/bin/mkdir -p '/usr/local/ffmpeg/lib'
/bin/bash ./libtool --mode=install /usr/bin/install -c libfdk-aac.la '/usr/local/ffmpeg/lib'
libtool: install: /usr/bin/install -c .libs/libfdk-aac.so.2.0.2 /usr/local/ffmpeg/lib/libfdk-aac.so.2.0.2
libtool: install: (cd /usr/local/ffmpeg/lib && { ln -s -f libfdk-aac.so.2.0.2 libfdk-aac.so.2 || { rm -f libfdk-aac.so.2 && ln -s libfdk-aac.so.2.0.2 libfdk-aac.so.2; }; })
libtool: install: (cd /usr/local/ffmpeg/lib && { ln -s -f libfdk-aac.so.2.0.2 libfdk-aac.so || { rm -f libfdk-aac.so && ln -s libfdk-aac.so.2.0.2 libfdk-aac.so; }; })
libtool: install: /usr/bin/install -c .libs/libfdk-aac.lai /usr/local/ffmpeg/lib/libfdk-aac.la
libtool: install: /usr/bin/install -c .libs/libfdk-aac.a /usr/local/ffmpeg/lib/libfdk-aac.a
libtool: install: chmod 644 /usr/local/ffmpeg/lib/libfdk-aac.a
libtool: install: ranlib /usr/local/ffmpeg/lib/libfdk-aac.a
libtool: finish: PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/sbin" ldconfig -n /usr/local/ffmpeg/lib
----------------------------------------------------------------------
Libraries have been installed in:
/usr/local/ffmpeg/lib
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the '-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the 'LD_LIBRARY_PATH' environment variable
during execution
- add LIBDIR to the 'LD_RUN_PATH' environment variable
during linking
- use the '-Wl,-rpath -Wl,LIBDIR' linker flag
- have your system administrator add LIBDIR to '/etc/ld.so.conf'
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
/usr/bin/mkdir -p '/usr/local/ffmpeg/include/fdk-aac'
/usr/bin/install -c -m 644 ./libSYS/include/machine_type.h ./libSYS/include/genericStds.h ./libSYS/include/FDK_audio.h ./libSYS/include/syslib_channelMapDescr.h ./libAACenc/include/aacenc_lib.h ./libAACdec/include/aacdecoder_lib.h '/usr/local/ffmpeg/include/fdk-aac'
/usr/bin/mkdir -p '/usr/local/ffmpeg/lib/pkgconfig'
/usr/bin/install -c -m 644 fdk-aac.pc '/usr/local/ffmpeg/lib/pkgconfig'
make[1]: Leaving directory '/home/wcx/Downloads/fdk-aac-2.0.2'
再次执行ffmpeg
需要在这里配置
wcx@wcx:~/Downloads/ffmpeg-6.1.1$ export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/ffmpeg/lib/pkgconfig/
wcx@wcx:~/Downloads/ffmpeg-6.1.1$ ./configure --prefix="/usr/local/ffmpeg/" --enable-gpl --enable-nonfree --enable-ffplay --enable-libfdk-aac --enable-libmp3lame --enable-libx264 --enable-libx265 --enable-filter=delogo --enable-debug --disable-optimizations --enable-libspeex --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --extra-ldflags=-L/usr/local/ffmpeg/lib
ERROR: libmp3lame >= 3.98.3 not found
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.
安装lame
下载地址 https://sourceforge.net/projects/lame/
wcx@wcx:~/Downloads$ cd lame-3.100/
wcx@wcx:~/Downloads/lame-3.100$ ./configure --prefix=/usr/local/ffmpeg --enable-shared
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
wcx@wcx:~/Downloads/lame-3.100$ make -j4
make all-recursive
make[1]: Entering directory '/home/wcx/Downloads/lame-3.100'
Making all in mpglib
make[2]: Entering directory '/home/wcx/Downloads/lame-3.100/mpglib'
/bin/bash ../libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I.. -I../include -I. -I../libmp3lame -I.. -MT common.lo -MD -MP -MF .deps/common.Tpo -c -o common.lo common.c
/bin/bash ../libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I.. -I../include -I. -I../libmp3lame -I.. -MT dct64_i386.lo -MD -MP -MF .deps/dct64_i386.Tpo -c -o dct64_i386.lo dct64_i386.c
wcx@wcx:~/Downloads/lame-3.100$ sudo make install
Making install in mpglib
make[1]: Entering directory '/home/wcx/Downloads/lame-3.100/mpglib'
make[2]: Entering directory '/home/wcx/Downloads/lame-3.100/mpglib'
make[2]: Nothing to be done for 'install-exec-am'.
make[2]: Nothing to be done for 'install-data-am'.
make[2]: Leaving directory '/home/wcx/Downloads/lame-3.100/mpglib'
make[1]: Leaving directory '/home/wcx/Downloads/lame-3.100/mpglib
再次执行ffmpeg
wcx@wcx:~/Downloads/ffmpeg-6.1.1$ ./configure --prefix="/usr/local/ffmpeg/" --enable-gpl --enable-nonfree --enable-ffplay --enable-libfdk-aac --enable-libmp3lame --enable-libx264 --enable-libx265 --enable-filter=delogo --enable-debug --disable-optimizations --enable-libspeex --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --extra-ldflags=-L/usr/local/ffmpeg/lib
ERROR: speex not found using pkg-config
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.
安装speex
下载地址 https://www.speex.org/downloads/
wcx@wcx:~/Downloads/speex-1.2.0$ ./configure --prefix=/usr/local/ffmpeg
checking whether make supports nested variables... yes
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
wcx@wcx:~/Downloads/speex-1.2.0$ make -j4
make all-recursive
make[1]: Entering directory '/home/wcx/Downloads/speex-1.2.0'
Making all in libspeex
make[2]: Entering directory '/home/wcx/Downloads/speex-1.2.0/libspeex'
CC cb_search.lo
CC exc_10_32_table.lo
wcx@wcx:~/Downloads/speex-1.2.0$ sudo make install
[sudo] password for wcx:
Making install in libspeex
make[1]: Entering directory '/home/wcx/Downloads/speex-1.2.0/libspeex'
make[2]: Entering directory '/home/wcx/Downloads/speex-1.2.0/libspeex'
/usr/bin/mkdir -p '/usr/local/ffmpeg/lib'
/bin/bash ../libtool --mode=install /usr/bin/install -c libspeex.la '/usr/local/ffmpeg/lib'
libtool: install: /usr/bin/install -c .libs/libspeex.so.1.5.1 /usr/local/ffmpeg/lib/libspeex.so.1.5.1
再次执行ffmpeg
wcx@wcx:~/Downloads/ffmpeg-6.1.1$ ./configure --prefix="/usr/local/ffmpeg/" --enable-gpl --enable-nonfree --enable-ffplay --enable-libfdk-aac --enable-libmp3lame --enable-libx264 --enable-libx265 --enable-filter=delogo --enable-debug --disable-optimizations --enable-libspeex --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --extra-ldflags=-L/usr/local/ffmpeg/lib
ERROR: x265 not found using pkg-config
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.
安装x265
下载地址 https://code.videolan.org/videolan/x264/-/archive/master/x264-master.tar.bz2
wcx@wcx:~/Downloads/x264-master$ ./configure --prefix=/usr/local/ffmpeg/ --enable-shared --disable-asm
platform: X86_64
byte order: little-endian
system: LINUX
cli: yes
libx264: internal
wcx@wcx:~/Downloads/x264-master$ make -j4
wcx@wcx:~/Downloads/x264-master$ sudo make install
[sudo] password for wcx:
install -d /usr/local/ffmpeg//bin
install x264 /usr/local/ffmpeg//bin
install -d /usr/local/ffmpeg//include
install -d /usr/local/ffmpeg//lib/pkgconfig
install -m 644 ./x264.h x264_config.h /usr/local/ffmpeg//include
install -m 644 x264.pc /usr/local/ffmpeg//lib/pkgconfig
install -d /usr/local/ffmpeg//lib
ln -f -s libx264.so.164 /usr/local/ffmpeg//lib/libx264.so
install -m 755 libx264.so.164 /usr/local/ffmpeg//lib
install -d /usr/share/bash-completion/completions
install -m 644 ./tools/bash-autocomplete.sh /usr/share/bash-completion/completions/x264
wcx@wcx:~/D
再次执行ffmpeg
wcx@wcx:~/Downloads/ffmpeg-6.1.1$ ./configure --prefix="/usr/local/ffmpeg/" --enable-gpl --enable-nonfree --enable-ffplay --enable-libfdk-aac --enable-libmp3lame --enable-libx264 --enable-libx265 --enable-filter=delogo --enable-debug --disable-optimizations --enable-libspeex --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --extra-ldflags=-L/usr/local/ffmpeg/lib
ERROR: x265 not found using pkg-config
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.
安装x265
http://ftp.videolan.org/pub/videolan/x265/
wcx@wcx:~/Downloads/x265_3.2$ cd build/
wcx@wcx:~/Downloads/x265_3.2/build$ ls
arm-linux msys-cl vc10-x86_64 vc12-x86 vc15-x86_64 xcode
linux README.txt vc11-x86 vc12-x86_64 vc9-x86
msys vc10-x86 vc11-x86_64 vc15-x86 vc9-x86_64
wcx@wcx:~/Downloads/x265_3.2/build$ cd linux/
wcx@wcx:~/Downloads/x265_3.2/build/linux$ ls
make-Makefiles.bash multilib.sh
wcx@wcx:~/Downloads/x265_3.2/build/linux$ ./make-Makefiles.bash
-- cmake version 3.16.3
-- Could NOT find NUMA (missing: NUMA_ROOT_DIR NUMA_INCLUDE_DIR NUMA_LIBRARY)
-- Could NOT find nasm (missing: NASM_EXECUTABLE)
-- Build files have been written to: /home/wcx/Downloads/x265_3.2/build/linux
./make-Makefiles.bash: line 3: ccmake: command not found
wcx@wcx:~/Downloads/x265_3.2/build/linux$ sudo apt-get install libnuma-dev
wcx@wcx:~/Downloads/x265_3.2/build/linux$ sudo apt-get install nasm
wcx@wcx:~/Downloads/x265_3.2/build/linux$ sudo apt install cmake-curses-gui
Reading package lists... Done
Building dependency tree
Reading state information... Done
wcx@wcx:~/Downloads/x265_3.2/build/linux$ ./make-Makefiles.bash
-- cmake version 3.16.3
CMake Deprecation Warning at CMakeLists.txt:10 (cmake_policy):
The OLD behavior for policy CMP0025 will be removed from a future version
of CMake.
The cmake-policies(7) manual explains that the OLD behaviors of all
policies are deprecated and that a policy should be set to OLD only under
specific short-term circumstances. Projects should be ported to the NEW
behavior and not rely on setting a policy to OLD.
CMake Deprecation Warning at CMakeLists.txt:16 (cmake_policy):
The OLD behavior for policy CMP0054 will be removed from a future version
of CMake.
The cmake-policies(7) manual explains that the OLD behaviors of all
policies are deprecated and that a policy should be set to OLD only under
specific short-term circumstances. Projects should be ported to the NEW
behavior and not rely on setting a policy to OLD.
-- Detected x86_64 target processor
-- Found NUMA: /usr
-- Looking for numa_node_of_cpu
-- Looking for numa_node_of_cpu - found
-- libnuma found, building with support for NUMA nodes
-- Found nasm: /usr/bin/nasm (found version "2.14.02")
-- Found Nasm 2.14.02 to build assembly primitives
-- x265 version 3.2
-- Configuring done
-- Generating done
-- Build files have been written to: /home/wcx/Downloads/x265_3.2/build/linux
wcx@wcx:~/Downloads/x265_3.2/build/linux$ make -j4
Scanning dependencies of target encoder
Scanning dependencies of target common
[ 5%] Building CXX object common/CMakeFiles/common.dir/primitives.cpp.o
[ 5%] Building CXX object common/CMakeFiles/common.dir/dct.cpp.o
[ 5%] Building CXX object common/CMakeFiles/common.dir/pixel.cpp.o
[ 6%] Building CXX object encoder/CMakeFiles/encoder.dir/analysis.cpp.o
[ 8%] Building CXX object common/CMakeFiles/common.dir/lowpassdct.cpp.o
[ 10%] Building CXX object common/CMakeFiles/common.dir/ipfilter.cpp.o
[ 11%] Building CXX object encoder/CMakeFiles/encoder.dir/search.cpp.o
[ 13%] Building CXX object common/CMakeFiles/common.dir/intrapred.cpp
[ 93%] Building CXX object CMakeFiles/cli.dir/output/reconplay.cpp.o
[ 95%] Building CXX object CMakeFiles/cli.dir/output/y4m.cpp.o
[ 96%] Building CXX object CMakeFiles/cli.dir/output/yuv.cpp.o
[ 98%] Building CXX object CMakeFiles/cli.dir/x265.cpp.o
[100%] Linking CXX executable x265
[100%] Built target cli
wcx@wcx:~/Downloads/x265_3.2/build/linux$ sudo make install
[ 50%] Built target common
[ 80%] Built target encoder
[ 81%] Built target x265-shared
[ 98%] Built target cli
[100%] Built target x265-static
Install the project...
-- Install configuration: "Release"
-- Installing: /usr/local/lib/libx265.a
-- Installing: /usr/local/include/x265.h
-- Installing: /usr/local/include/x265_config.h
-- Installing: /usr/local/lib/libx265.so.179
-- Installing: /usr/local/lib/libx265.so
-- Installing: /usr/local/lib/pkgconfig/x265.pc
-- Installing: /usr/local/bin/x265
-- Set runtime path of "/usr/local/bin/x265" to ""
再次执行ffmpeg
再执行 没有报错
wcx@wcx:~/Downloads/ffmpeg-6.1.1$ ./configure --prefix="/usr/local/ffmpeg/" --enable-gpl --enable-nonfree --enable-ffplay --enable-libfdk-aac --enable-libmp3lame --enable-libx264 --enable-libx265 --enable-filter=delogo --enable-debug --disable-optimizations --enable-libspeex --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --extra-ldflags=-L/usr/local/ffmpeg/lib
install prefix /usr/local/ffmpeg/
source path .
C compiler gcc
C library glibc
ARCH x86 (generic)
big-endian no
runtime cpu detection yes
wcx@wcx:~/Downloads/ffmpeg-6.1.1$ sudo make -j4
wcx@wcx:~/Downloads/ffmpeg-6.1.1$ sudo make install
[sudo] password for wcx:
INSTALL libavdevice/libavdevice.a
INSTALL libavdevice/libavdevice.so
STRIP install-libavdevice-shared
INSTALL libavfilter/libavfilter.a
INSTALL libavfilter/libavfilter.so
STRIP install-libavfilter-shared
INSTALL libavformat/libavformat.a
INSTALL libavformat/libavformat.so
STRIP install-libavformat-shared
INSTALL libavcodec/libavcodec.a
INSTALL libavcodec/libavcodec.so
STRIP install-libavcodec-shared
INSTALL libpostproc/libpostproc.a
INSTALL libpostproc/libpostproc.so
STRIP install-libpostproc-shared
wcx@wcx:~/Downloads/ffmpeg-6.1.1$ sudo vi /etc/profile
文件最后加上
export PATH="/usr/local/ffmpeg/bin:$PATH"
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/ffmpeg/lib/pkgconfig
wcx@wcx:~/Downloads/ffmpeg-6.1.1$ sudo vi /etc/ld.so.conf
文件最后一行加上/usr/local/ffmpeg/lib
wcx@wcx:~/Downloads/ffmpeg-6.1.1$ sudo ldconfig
环境变量
wcx@wcx:/usr/local/ffmpeg$ vi ~/.bashrc
在末尾添加
export PATH="/usr/local/ffmpeg/bin:${PATH}"
export LD_LIBRARY_PATH="/usr/local/ffmpeg/lib:{LD_LIBRARY_PATH}"
wcx@wcx:/usr/local/ffmpeg$ source ~/.bashrc
测试是否成功
wcx@wcx:/usr/local/ffmpeg$ ffmpeg -verison
ffmpeg version 6.1.1 Copyright (c) 2000-2023 the FFmpeg developers
built with gcc 9 (Ubuntu 9.4.0-1ubuntu1~20.04.2)
configuration: --prefix=/usr/local/ffmpeg/ --enable-gpl --enable-nonfree --enable-ffplay --enable-libfdk-aac --enable-libmp3lame --enable-libx264 --enable-libx265 --enable-filter=delogo --enable-debug --disable-optimizations --enable-libspeex --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --extra-ldflags=-L/usr/local/ffmpeg/lib
libavutil 58. 29.100 / 58. 29.100
libavcodec 60. 31.102 / 60. 31.102
libavformat 60. 16.100 / 60. 16.100
libavdevice 60. 3.100 / 60. 3.100
libavfilter 9. 12.100 / 9. 12.100
libswscale 7. 5.100 / 7. 5.100
libswresample 4. 12.100 / 4. 12.100
libpostproc 57. 3.100 / 57. 3.100
wcx@wcx:/usr/local/ffmpeg$ which ffmpeg
/usr/local/ffmpeg/bin/ffmpeg