大家好,又见面了,我是你们的朋友全栈君。
安装FFMPEG需要的所有组件
代码语言:javascript复制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
为下面的安装源文件建立一个目录
代码语言:javascript复制mkdir ~/ffmpeg_sources
编译和安装
注:根据自己的需要来选择要安装的编解码器
Yasm
代码语言:javascript复制sudo apt-get install yasm
cd ~/ffmpeg_sources
wget http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz
tar xzvf yasm-1.3.0.tar.gz
cd yasm-1.3.0
./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin"
make
make install
make distclean
libx264
代码语言:javascript复制sudo apt-get install libx264-dev
cd ~/ffmpeg_sources
wget http://download.videolan.org/pub/x264/snapshots/last_x264.tar.bz2
tar xjvf last_x264.tar.bz2
cd x264-snapshot*
PATH="$HOME/bin:$PATH" ./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" --enable-static --disable-opencl
PATH="$HOME/bin:$PATH" make
make install
make distclean
libx265
代码语言:javascript复制sudo apt-get install libx265-dev
sudo apt-get install cmake mercurial
cd ~/ffmpeg_sources
hg clone https://bitbucket.org/multicoreware/x265
cd ~/ffmpeg_sources/x265/build/linux
PATH="$HOME/bin:$PATH" cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="$HOME/ffmpeg_build" -DENABLE_SHARED:bool=off ../../source
make
make install
make distclean
libfdk-aac
代码语言:javascript复制sudo apt-get install libfdk-aac-dev
cd ~/ffmpeg_sources
wget -O fdk-aac.tar.gz https://github.com/mstorsjo/fdk-aac/tarball/master
tar xzvf fdk-aac.tar.gz
cd mstorsjo-fdk-aac*
autoreconf -fiv
./configure --prefix="$HOME/ffmpeg_build" --disable-shared
make
make install
make distclean
libmp3lame
代码语言:javascript复制sudo apt-get install libmp3lame-dev
sudo apt-get install nasm
cd ~/ffmpeg_sources
wget http://downloads.sourceforge.net/project/lame/lame/3.99/lame-3.99.5.tar.gz
tar xzvf lame-3.99.5.tar.gz
cd lame-3.99.5
./configure --prefix="$HOME/ffmpeg_build" --enable-nasm --disable-shared
make
make install
make distclean
libopus
代码语言:javascript复制sudo apt-get install libopus-dev
cd ~/ffmpeg_sources
wget http://downloads.xiph.org/releases/opus/opus-1.1.4.tar.gz
tar xzvf opus-1.1.4.tar.gz
cd opus-1.1.4
./configure --prefix="$HOME/ffmpeg_build" --disable-shared
make
make install
make clean
libvpx
sudo apt-get install libvpx-dev
cd ~/ffmpeg_sources
wget http://storage.proxy.ustclug.org/downloads.webmproject.org/releases/webm/libvpx-1.6.1.tar.bz2
tar xjvf libvpx-1.6.1.tar.bz2
cd llibvpx-1.6.1
PATH="$HOME/bin:$PATH" ./configure --prefix="$HOME/ffmpeg_build" --disable-examples --disable-unit-tests
PATH="$HOME/bin:$PATH" make
make install
make clean
ffmpeg
代码语言:javascript复制cd ~/ffmpeg_sources
wget http://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2
tar xjvf ffmpeg-snapshot.tar.bz2
cd ffmpeg
PATH="$HOME/bin:$PATH" PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" ./configure
--prefix="$HOME/ffmpeg_build"
--pkg-config-flags="--static"
--extra-cflags="-I$HOME/ffmpeg_build/include"
--extra-ldflags="-L$HOME/ffmpeg_build/lib"
--bindir="$HOME/bin"
--enable-gpl
--enable-libass
--enable-libfdk-aac
--enable-libfreetype
--enable-libmp3lame
--enable-libopus
--enable-libtheora
--enable-libvorbis
--enable-libvpx
--enable-libx264
--enable-libx265
--enable-nonfree
PATH="$HOME/bin:$PATH" make
make install
make distclean
hash -r
当执行一下命令:
当执行./configure 时遇到 ERROR: x265 not found using pkg-config
代码语言:javascript复制PATH="$HOME/bin:$PATH" PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" ./configure
--prefix="$HOME/ffmpeg_build"
--pkg-config-flags="--static"
--extra-cflags="-I$HOME/ffmpeg_build/include"
--extra-ldflags="-L$HOME/ffmpeg_build/lib"
--bindir="$HOME/bin"
--enable-gpl
--enable-libass
--enable-libfdk-aac
--enable-libfreetype
--enable-libmp3lame
--enable-libopus
--enable-libtheora
--enable-libvorbis
--enable-libvpx
--enable-libx264
--enable-libx265
--enable-nonfree
解决方法;
查看 (~/ffmpeg_sources/ffmpeg/ffbuild/config.log)文件,此文件是./configure生成的log文件,直接拉到最后可以看到出问题的原因,我遇到的问题如下:
代码语言:javascript复制$(HOME)/lib/libx265.a(threading.cpp.o): In function `x265::Thread::start()':
threading.cpp:(.text 0x35): undefined reference to `pthread_create'
$(HOME)/ffmpeg_build/lib/libx265.a(threading.cpp.o): In function `x265::Thread::stop()':
threading.cpp:(.text 0x63): undefined reference to `pthread_join'
collect2: error: ld returned 1 exit status
ERROR: x265 not found using pkg-config
在libx265文件夹中(~/ffmpeg_sources/x265/source/common/threading.cpp)找到问题文件既 threading.cpp //在threading.cpp中包含pthread.h :
添加:#include “pthread.h”
然后继续执行 ./configure … && make && make isntall 完成libx265的安装 完成安装后 在 $(HOME)/ffmpeg_build/lib/pkg-config文件夹下找到 XXX.pc文件并打开,在Libs.private: -lstdc -lm -lrt -ldl后面添加 -lpthread 包含pthread库。
继续执行既可完成ffmpeg的安装。
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/194562.html原文链接:https://javaforall.cn