安裝ffmpeg使用brew
首先安裝brew:php
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
出現這個:==> Installation successful!安裝成功html
.... No changes to formulae. ==> Installation successful! ==> Homebrew has enabled anonymous aggregate formulae and cask analytics. Read the analytics documentation (and how to opt-out) here: https://docs.brew.sh/Analytics ==> Homebrew is run entirely by unpaid volunteers. Please consider donating: https://github.com/Homebrew/brew#donations ==> Next steps: - Run `brew help` to get started - Further documentation: https://docs.brew.sh
看看相關命令html5
$ brew Example usage: brew search [TEXT|/REGEX/] brew info [FORMULA...] brew install FORMULA... brew update brew upgrade [FORMULA...] brew uninstall FORMULA... brew list [FORMULA...] Troubleshooting: brew config brew doctor brew install --verbose --debug FORMULA Contributing: brew create [URL [--no-fetch]] brew edit [FORMULA...] Further help: brew commands brew help [COMMAND] man brew https://docs.brew.sh
安裝ffmpeg,使用brew安裝:node
$ brew install ffmpeg ==> Installing dependencies for ffmpeg: frei0r, libtasn1, nettle, p11-kit, openssl, libevent, unbound, gnutls, lame, fribidi, gettext, python, glib, lzo, pixman, cairo, graphite2, icu4c, harfbuzz, libass, libbluray, libsoxr, libogg, libvorbis, libvpx, opencore-amr, opus, flac, libsndfile, libsamplerate, rubberband, sdl2, snappy, speex, webp, theora, x264, x265 and xvid ==> Installing ffmpeg dependency: frei0r ==> Downloading https://homebrew.bintray.com/bottles/frei0r-1.6.1.mojave.bottle.1.tar.gz ==> Downloading from https://akamai.bintray.com/a5/a509ee11dc4a3cd431a888c708d32c53d81e5ca67250520f91284d4370d946d4?__gda__=exp=1563528408~hmac=dd80d6bc9693a885841309c5bc094e71743 ######################################################################## 100.0% ==> Pouring frei0r-1.6.1.mojave.bottle.1.tar.gz 🍺 /usr/local/Cellar/frei0r/1.6.1: 137 files, 2.0MB ==> Installing ffmpeg dependency: libtasn1 ==> Downloading https://homebrew.bintray.com/bottles/libtasn1-4.13.mojave.bottle.tar.gz ######################################################################## 100.0% ==> Pouring libtasn1-4.13.mojave.bottle.tar.gz 🍺 /usr/local/Cellar/libtasn1/4.13: 59 files, 436KB ==> Installing ffmpeg dependency: nettle
出現下面的表名正在下載安裝ffmpeg:注意安裝目錄python
==> Installing ffmpeg ==> Downloading https://homebrew.bintray.com/bottles/ffmpeg-4.1.4_1.mojave.bottle.tar.gz ==> Downloading from https://akamai.bintray.com/1f/1fff696effdf5cdea3feb1b2d022018c6dfe47b71de640a46adc4631cdeccf1e?__gda__=exp=1563528747~hmac=8eb115e7fc1a65ade91bdda74c9fd572e38 ######################################################################## 100.0% ==> Pouring ffmpeg-4.1.4_1.mojave.bottle.tar.gz 🍺 /usr/local/Cellar/ffmpeg/4.1.4_1: 282 files, 55.0MB
一切安裝順利,然鵝。。。。然鵝,執行ffmpeg命名報錯了
出現下面的錯誤:git
$ ffmpeg dyld: Library not loaded: /usr/local/opt/freetype/lib/libfreetype.6.dylib Referenced from: /usr/local/bin/ffmpeg Reason: image not found [1] 22518 abort ffmpeg
報錯:github
dyld: Library not loaded: /usr/local/opt/freetype/lib/libfreetype.6.dylib
就是freetype動態庫指定的目錄不存在,或許沒有安裝,使用brew命令安裝,顯示已經安裝,從新卸載安裝也不行
可是安裝完成以後也不行,一直報錯
執行命令報錯:web
$ ffmpeg dyld: Library not loaded: /usr/local/opt/freetype/lib/libfreetype.6.dylib Referenced from: /usr/local/bin/ffmpeg Reason: image not found [1] 22518 abort ffmpeg
進入ffmpeg安裝目錄,查看是不是由於路徑問題sql
$ cd /usr/local/Cellar/ffmpeg/4.1.4_1/bin $ ./ffmpeg dyld: Library not loaded: /usr/local/opt/freetype/lib/libfreetype.6.dylib Referenced from: /usr/local/bin/ffmpeg Reason: image not found [1] 22518 abort ffmpeg
發現仍是報錯。因而仍是從查看ffmepg的動態庫freetype入手,看看相關的功能。mongodb
查看目錄中是否有相關的目錄
$ cd /usr/local/opt/freetype/lib/ cd: no such file or directory: /usr/local/opt/freetype/lib/ $ cd /usr/local/opt/ $ ls aom fontconfig jansson libnettle libvpx node.js python tidy-html5 apr freetds jemalloc libogg libvterm node@11 python3 tree apr-util frei0r jpeg libomp libzip nodejs python@2 unbound argon2 fribidi lame libpng little-cms2 npm readline unibilium aspell gdbm lcms2 libpq luajit nvim rtmpdump unixodbc autoconf gettext leptonica libsamplerate lzo opencore-amr rubberband webp autoconf@2.69 giflib libass libsndfile mongo openexr sdl2 wget boost glib libbluray libsodium mongodb openjpeg shared-mime-info x264 boost@1.69 gmp libde265 libsoxr mongodb-community openldap snappy x265 bower gnutls libev libssh2 mongodb-community@4.0 openssl speex xvid brotli graphite2 libevent libtasn mongodb@4.0 opus sqlite xz c-ares harfbuzz libffi libtasn1 msgpack p11-kit sqlite3 yarn cairo htop libheif libtermkey ncurses pcre tcpdump curl htop-osx libidn libtiff neovim pcre1 telnet curl-openssl icu4c libidn2 libtool netcat pcre2 tesseract ffmpeg ilmbase libjpeg libunistring nettle php@7.2 theora ffmpeg@4 imagemagick libjpg libuv nghttp2 pixman thrift flac imagemagick@7 libmetalink libvorbis node proxychains-ng thrift@0.12
能夠看到並不存在,同時發現新安裝的freetype目錄在其餘位置,經過創建軟鏈接解決問題。
經過先卸載後安裝freetype肯定安裝目錄
$ brew upgrade freetype Error: freetype 2.10.1 already installed # yanglei @ yangleideMacBook-Pro in /usr/local/opt [17:33:50] C:1 $ brew uninstall freetype Uninstalling /usr/local/Cellar/freetype/2.10.1... (61 files, 2.2MB) # yanglei @ yangleideMacBook-Pro in /usr/local/opt [17:34:11] $ brew install freetype ==> Downloading https://homebrew.bintray.com/bottles/freetype-2.10.1.mojave.bottle.tar.gz Already downloaded: /Users/yanglei/Library/Caches/Homebrew/downloads/4e8dc5929a6cd94508b9908d8d04d326817a99cd66c009056b2fe3a60d182bd1--freetype-2.10.1.mojave.bottle.tar.gz ==> Pouring freetype-2.10.1.mojave.bottle.tar.gz 🍺 /usr/local/Cellar/freetype/2.10.1: 61 files, 2.2MB # yanglei @ yangleideMacBook-Pro in /usr/local/opt [17:34:39] $ cd /usr/local/opt/freetype/lib/libfreetype.6.dylib cd: not a directory: /usr/local/opt/freetype/lib/libfreetype.6.dylib cd /usr/local/Cellar/freetype/2.10.1/ $ ln -s /usr/local/Cellar/freetype/2.10.1/bin/freetype-config /usr/local/opt/freetype/lib/libfreetype.6.dylib ln: /usr/local/opt/freetype/lib/libfreetype.6.dylib: File exists # yanglei @ yangleideMacBook-Pro in /usr/local/Cellar/freetype/2.10.1/bin [17:36:55] C:1 $ cd /usr/local/opt/freetype/lib/ # yanglei @ yangleideMacBook-Pro in /usr/local/opt/freetype/lib [17:37:11] $ ls libfreetype.6.dylib libfreetype.a libfreetype.dylib pkgconfig # yanglei @ yangleideMacBook-Pro in /usr/local/opt/freetype/lib [17:37:12] $ l total 2744 drwxr-xr-x 6 yanglei staff 192B Jul 1 23:55 . drwxr-xr-x 10 yanglei staff 320B Jul 19 17:34 .. -r--r--r-- 1 yanglei staff 591K Jul 19 17:34 libfreetype.6.dylib -r--r--r-- 1 yanglei staff 780K Jul 1 23:55 libfreetype.a lrwxr-xr-x 1 yanglei staff 19B Jul 1 23:55 libfreetype.dylib -> libfreetype.6.dylib drwxr-xr-x 3 yanglei staff 96B Jul 19 17:34 pkgconfig
執行以後,查看文件已存在,同時執行ffmpeg,發現已經能夠正常使用。
$ ffmpeg ffmpeg version 4.1.4 Copyright (c) 2000-2019 the FFmpeg developers built with Apple LLVM version 10.0.1 (clang-1001.0.46.4) configuration: --prefix=/usr/local/Cellar/ffmpeg/4.1.4_1 --enable-shared --enable-pthreads --enable-version3 --enable-avresample --cc=clang --host-cflags='-I/Library/Java/JavaVirtualMachines/adoptopenjdk-12.0.1.jdk/Contents/Home/include -I/Library/Java/JavaVirtualMachines/adoptopenjdk-12.0.1.jdk/Contents/Home/include/darwin' --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libmp3lame --enable-libopus --enable-librubberband --enable-libsnappy --enable-libtesseract --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enable-libspeex --enable-videotoolbox --disable-libjack --disable-indev=jack --enable-libaom --enable-libsoxr libavutil 56. 22.100 / 56. 22.100 libavcodec 58. 35.100 / 58. 35.100 libavformat 58. 20.100 / 58. 20.100 libavdevice 58. 5.100 / 58. 5.100 libavfilter 7. 40.101 / 7. 40.101 libavresample 4. 0. 0 / 4. 0. 0 libswscale 5. 3.100 / 5. 3.100 libswresample 3. 3.100 / 3. 3.100 libpostproc 55. 3.100 / 55. 3.100 Hyper fast Audio and Video encoder usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}... Use -h to get full help or, even bet
來個視頻試試
$ ffmpeg -i bb.mp4 ffmpeg version 4.1.4 Copyright (c) 2000-2019 the FFmpeg developers built with Apple LLVM version 10.0.1 (clang-1001.0.46.4) configuration: --prefix=/usr/local/Cellar/ffmpeg/4.1.4_1 --enable-shared --enable-pthreads --enable-version3 --enable-avresample --cc=clang --host-cflags='-I/Library/Java/JavaVirtualMachines/adoptopenjdk-12.0.1.jdk/Contents/Home/include -I/Library/Java/JavaVirtualMachines/adoptopenjdk-12.0.1.jdk/Contents/Home/include/darwin' --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libmp3lame --enable-libopus --enable-librubberband --enable-libsnappy --enable-libtesseract --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enable-libspeex --enable-videotoolbox --disable-libjack --disable-indev=jack --enable-libaom --enable-libsoxr libavutil 56. 22.100 / 56. 22.100 libavcodec 58. 35.100 / 58. 35.100 libavformat 58. 20.100 / 58. 20.100 libavdevice 58. 5.100 / 58. 5.100 libavfilter 7. 40.101 / 7. 40.101 libavresample 4. 0. 0 / 4. 0. 0 libswscale 5. 3.100 / 5. 3.100 libswresample 3. 3.100 / 3. 3.100 libpostproc 55. 3.100 / 55. 3.100 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'bb.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf56.25.101 Duration: 00:00:11.24, start: 0.000000, bitrate: 1182 kb/s Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 1180 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default) Metadata: handler_name : VideoHandler
目前ffmpeg使用一切順利,然鵝其餘軟件又出現了問題php報錯。。。欲解決問題,請看個人下篇文章【php執行失敗動態庫libicui18n報錯】