2021-05-12 14:32:11
Ubuntu 16.04安裝編譯FFmpeg
在Ubuntu 16.04環境下安裝編譯FFmpeg過程步驟,本文主要基於此官方指導編譯。
1. 安裝依賴
sudo apt-get update
sudo apt-get -y install autoconf automake build-essential libass-dev libfreetype6-dev libsdl1.2-dev libtheora-dev libtool libva-dev libvdpau-dev libvorbis-dev libxcb1-dev libxcb-shm0-dev libxcb-xfixes0-dev pkg-config texinfo zlib1g-dev
mkdir ~/ffmpeg_sources //根目錄下建立資料夾
2. Compilation & Installation
Yasm
sudo apt-get install yasm
libx264
sudo apt-get install libx264-dev
libx265
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
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
sudo apt-get install libmp3lame-dev
libopus
sudo apt-get install libopus-dev
libvpx
cd ~/ffmpeg_sources
wget http://storage.googleapis.com/downloads.webmproject.org/releases/webm/libvpx-1.5.0.tar.bz2
tar xjvf libvpx-1.5.0.tar.bz2
cd libvpx-1.5.0
PATH="$HOME/bin:$PATH" ./configure --prefix="$HOME/ffmpeg_build" --disable-examples --disable-unit-tests
PATH="$HOME/bin:$PATH" make
make install
make clean
avdevice
sudo apt-get install libavdevice-dev
ffmpeg
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-nonfreePATH="$HOME/bin:$PATH" makemake installmake distcleanhash -r
到這裡ffmpeg就編譯安裝結束了,編譯過的ffmpeg在~/bin 目錄下
Usage
兩種方法使用ffmpeg
進入~/bin資料夾,然後呼叫binary檔案: cd ~/bin && ./ffmpeg -i ~/input.mp4 ~/videos/output.mkv
使用絕對路徑:/home/yourusername/bin/ffmpeg -i ../input.mp4 ../videos/output.mkv
如果想要ffmpeg在所有地方都能直接呼叫,需要先登出,然後登陸。
或者執行source ~/.profile
Documentation
如果想要用man ffmpeg命令看文件,執行下面命令
echo "MANPATH_MAP $HOME/bin $HOME/ffmpeg_build/share/man" >> ~/.manpath
登出,然後登陸即可。
更新FFmpeg
rm -rf ~/ffmpeg_build ~/ffmpeg_sources ~/bin/{ffmpeg,ffprobe,ffplay,ffserver,vsyasm,x264,x265,yasm,ytasm}
然後從頭開始再來一次
Ubuntu 16.04下FFmpeg搭建簡易監控環境 http://www.linuxidc.com/Linux/2017-02/141091.htm
Linux 下編譯FFmpeg 支援x264, x265 http://www.linuxidc.com/Linux/2016-04/129858.htm
VS2013編譯FFmpeg http://www.linuxidc.com/Linux/2016-08/134102.htm
在 Mac OS X 環境中從原始碼編譯安裝 FFmpeg http://www.linuxidc.com/Linux/2015-12/126093.htm
FFmpeg安裝及encode庫的安裝說明 http://www.linuxidc.com/Linux/2016-10/136546.htm
Ubuntu 14.04下PPA安裝FFmpeg 2.2.2 http://www.linuxidc.com/Linux/2014-05/101322.htm
Linux 下編譯FFmpeg 支援x264, x265 http://www.linuxidc.com/Linux/2016-04/129858.htm
FFmpeg常用基本命令 http://www.linuxidc.com/Linux/2016-10/136545.htm
Ubuntu 16.04下交叉編譯FFmpeg http://www.linuxidc.com/Linux/2017-10/147370.htm
相關文章