Linux下FFmpeg安裝教程
阿新 • • 發佈:2019-01-30
Linux下安裝FFmpeg
安裝yasm
cd yasm-1.3.0
./configure
make
sudo make install
安裝依賴
sudo apt-get install libfaac-dev libmp3lame-dev libtheora-dev libvorbis-dev libopencore-amrnb-dev libopencore-amrwb-dev libgsm1-dev zlib1g-dev libgpac1-dev
./configure
sudo make
sudo make install
安裝x264
下載原始碼:
git clone --depth 1 git://git.videolan.org/x264
進入原始碼目錄:
cd x264
./configure --enable-shared
如果提示:
./configure --enable-shared
Found no assembler
Minimum version is nasm-2.13
If you really want to compile without asm, configure with --disable-asm.
加上–disable-asm,即執行:
./configure --enable- shared --disable-asm
再執行:
sudo make install
安裝ffmpeg
cd ffmpeg-3.4.2
./configure --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --disable-jack --enable-gpl --enable-libmp3lame --enable-libx264 --enable -libxvid --enable-opencl --disable-lzma
sudo make
sudo make install
動態連結庫
vi /etc/ld.so.conf
加入:/usr/local/lib ##示自己的安裝目錄而定,/usr/local/lib是預設安裝位置
#執行
sudo ldconfig
新增ffmpeg到環境變數
vi /etc/profile
#加入以下內容:
FFMPEG=/usr/local ##示自己的安裝目錄而定
PATH加入:$FFMPEG/bin
#讓環境變數生效
sudo source /etc/profile
驗證安裝是否成功:
#執行
ffmpeg -version
#輸出:
ffmpeg version 3.4.2 Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 4.8.2 (GCC)
configuration: --enable-shared --enable-libx264 --enable-gpl --enable-avresample
libavutil 55. 78.100 / 55. 78.100
libavcodec 57.107.100 / 57.107.100
libavformat 57. 83.100 / 57. 83.100
libavdevice 57. 10.100 / 57. 10.100
libavfilter 6.107.100 / 6.107.100
libavresample 3. 7. 0 / 3. 7. 0
libswscale 4. 8.100 / 4. 8.100
libswresample 2. 9.100 / 2. 9.100
libpostproc 54. 7.100 / 54. 7.100
問題
問題1
/usr/bin/ld: libavcodec/mqc.o: relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
libavcodec/mqc.o: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
解決辦法:
在config.mak檔案Line88(不同版本位置可能不同)加上-fPIC,然後重新編譯。
問題2
ffmpeg: error while loading shared libraries: libavdevice.so.52: cannot open shared object file: No such file or directory
#執行,看看軟連結是否建立
ldd `which ffmpeg`
libavdevice.so.52 => not found
libavfilter.so.1 => not found
libavformat.so.52 => not found
libavcodec.so.52 => not found
libswscale.so.0 => not found
libavcore.so.0 => not found
libavutil.so.50 => not found
libm.so.6 => /lib/libm.so.6 (0x006c3000)
libpthread.so.0 => /lib/libpthread.so.0 (0x007e9000)
libc.so.6 => /lib/libc.so.6 (0x00575000)
/lib/ld-linux.so.2 (0x00557000)
解決辦法:
也有可能是該庫並未安裝之類的,只需在./configure時加上該庫即可