linux上安裝和使用ffmpeg 挖坑記

2021-09-27 11:28:32 字數 2411 閱讀 4532

小結此處照著網上教程坑略多,務必看完再動手。

sudo ./configure --enable-shared --prefix=/usr/local/ffmpeg
如果提示yasm版本太舊則安裝一下

sudo apt-get install yasm
然後再次執行上面的命令即可

ps:這裡僅簡單安裝,./configure 可以檢視即將安裝專案,需要什麼自己配吧

進入安裝目錄下 /usr/local/ffmpeg,由於沒有配置ffmpeg環境變數,此時執行./ffmpeg會提示各種so鏈結庫找不到。

sudo gedit /etc/ld.so.conf

新增到檔案尾行

/usr/local/ffmpeg/lib

執行 sudo ldconfig

然後就能正常使用了

./ffmpeg -f image2 -i /***x/frames/%05d.jpg   -vcodec libx264  -r 10 /***xx/test.mp4 -y
我用opencv在frames目錄下生成了一堆,00000-10000,這裡注意%05d.jpg,根據我的編號決定的。如果不匹配可能會報錯,比如一開始我寫的%d.jpg:

繼續執行:

error1: unknown encoder 『libx264』

這是編譯時沒有把這個編碼庫編碼進來。

參考

sudo ./configure --enable-shared --prefix=./install --e

nable-gpl --enable-libx264

./configure --enable-static --enable-shared
error2提示 :found no assembler minimum version is nasm-2.13

安裝一下 sudo apt-get install nasm

然後重新configure, make, make install

sudo ./configure --enable-shared --prefix=./install --enable-gpl --enable-libx264
重新configure後應當在enabled encoders中發現libx264

enabled encoders:

a64multi jpegls png

a64multi5 libx264 ppm

aac libx264rgb prores

ac3 ljpeg prores_aw

ac3_fixed magicyuv prores_ks

adpcm_adx mjpeg qtrle

...

make -j8 ,在編譯x264時發生錯誤,提示新增 -fpic

error3/usr/local/lib/libx264.a(base.o): relocation r_x86_64_pc32 against symbol `stderr@@glibc_2.2.5』 can not be used when ****** a shared object; recompile with -fpic

也就是需要在編譯x264的時候 with -fpic

囧,重新編譯x264, ./configure --help可以看到有個選項可以直接開啟pic

./configure --enable-static --enable-shared --enable-pic
依然三件套,configure, make,install

error4error while loading shared libraries: libx264.so.157: cannot open shared object file: no such file or directory

這個我倒是知道,因為安裝x264的時候so被裝到了/usr/local/lib下,囧。這個位置是沒有被搜尋的

sudo gedit /etc/ld.so.conf

新增到檔案尾行

/usr/local/lib

執行 sudo ldconfig

整個過程結束

不同功能可能遇到的問題不一樣,僅供參考

Linux上安裝和使用Nginx教程

nginx版本 nginx1.15.5 linux版本 centos7.5 安裝相關依賴元件 gcc c語言環境 pcre pcre perl compatible regular expressions 是乙個perl庫,包括 perl 相容的正規表示式庫。nginx的http模組使用pcre來解...

linux 上安裝使用git

一.安裝 專案主頁 最先安裝 ssh root下執行 ssh keygen t dsa 生成 pub key root ssh id dsa.pub 二 git使用說明 1 新增git配置資訊 git config global user.name test git config global us...

Linux上安裝使用SSH

參考部落格 ubuntu預設並沒有安裝ssh服務,如果通過ssh鏈結ubuntu,需要自己手動安裝ssh server。判斷是否安裝ssh服務,可以通過如下命令進行 xjj xjj desktop ssh localhost ssh connect to host localhost port 22...