今天試了一下用FFMPEG來調(diào)用google的webP剩拢,根據(jù)官方說明ffmpeg-libwebp谷浅;需要--enable-webp; 之前build ffmpeg 沒有用這個option舷胜,所以重新config上添加了這個選項妓肢,配置如下:
./configure --cc=/usr/bin/clang --prefix=/opt/ffmpeg --extra-version=tessus --enable-avisynth --enable-fontconfig --enable-gpl --enable-libass --enable-libbluray --enable-libfreetype --enable-libgsm --enable-libmodplug --enable-libmp3lame--enable-libopus --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libvidstab--enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libx264 --enable-libx265 --enable-libxvid --enable-libzmq --enable-version3 --disable-ffplay --disable-indev=qtkit --enable-libopenjpeg--enable-libkvazaar --enable-libilbc--enable-libfdk-aac --enable-nonfree --enable-encoder=aac --enable-libwebp
結(jié)果出錯节沦,如下:
? ? ? ? ? ERROR: libwebp not found using pkg-config
按常規(guī)史煎,缺失的庫使用 brew install? 一下就可以了,比如x265, 如果提示上面類似的error的話吧慢,只要運行如下的安裝操作即可:
? ? ? brew install x265
但是這次使用brew install webp 后涛漂,還是同樣的 ERROR, 不成功,折騰了好久检诗,最后去看看其他的解決方案匈仗。
最后查看pkg-config的機制,終于解決了逢慌。所以這里也給遇到同樣問題的人提供一個思路悠轩。問題雖然簡單,但是如果不了解的話涕癣,還是會浪費很多時間在這些細小問題上哗蜈。
關(guān)于pkg-config前标,可以查看官方文檔pkg-config或者百度一下,這里不詳述。
一般Mac系統(tǒng)默認的pkg-config目錄在
? ? ? ? ? ? /usr/local/lib/pkgconfig?
下距潘,而ffmpeg 的./configure 也是在這個目錄下搜索相應被enable的庫的pkg-config?配置文件 xxx.pc, 如 libwebp.pc, libx265.pc 等等
? ? 之所以 提示剛開始提到的ERROR炼列,是因為在/usr/local/lib/pkgconfig目錄下,沒有找到對應的libwebp.pc配置文件音比。
? 而我們使用brew install 命令安裝庫時俭尖,其安裝的目錄是
? ? ? ? ? ? ? ?/usr/local/Cellar/
? ?比如,brew install webp,則其安裝的目錄
? ? ? ? ? ? ? /usr/local/Cellar/webp
? ? ? ? ? ? ?-----相應的文件包括bin, include, lib等子目錄洞翩。
? ? ? ? ? ? ?-----同時lib子目錄就包含lib/pkgconfig/ libwebp.pc等文件稽犁。
說到這里,相信知道怎么做了骚亿,就是創(chuàng)建一個軟連接
? ?ln -s? /usr/local/lib/pkgconfig/libwebp.pc? ../../Cellar/webp/0.6.0_2/lib/pkgconfig/libwebp.pc
這樣就可以解決libwebp.pc 找不到的問題已亥,當然為了妥當起見,后面還需要創(chuàng)建相應的軟連接来屠,如對/usr/local/lib和/usr/local/include創(chuàng)建相應的軟連接對應webp相應的庫和頭文件虑椎,如下所示:
? ? ? /usr/local/lib/ibwebp.a -> ../Cellar/webp/0.6.0_2/lib/libwebp.a? ? ? ? ? ? ? ? ? ? ? ? ??
? ? ? /usr/local/include/decode.h -> ../Cellar/webp/0.6.0_2/include/webp/decode.h
一般brew install 命令會同時完成.pc libxxx, xxx.h相應的軟連接的創(chuàng)建,可能webp的安裝稍微特殊俱笛。
基于上面的方案捆姜,再build ffmpeg, 就沒問題了。
相信如果有同樣其他庫有相似的問題迎膜,可以用相似的方法解決泥技。
以上是我粗略的總結(jié),有其他更好的方案或者有錯誤的地方希望大家指出或者分享更好的方案磕仅。