安装ffmpeg使用brew
首先安装brew:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
出现这个:==> Installation successful!安装成功
....
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
看看相关命令
$ 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安装:
$ 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:注意安装目录
==> 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命名报错了
出现下面的错误:
$ 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
报错:
dyld: Library not loaded:
/usr/local/opt/freetype/lib/libfreetype.6.dylib
就是freetype动态库指定的目录不存在,或许没有安装,使用brew命令安装,显示已经安装,重新卸载安装也不行
但是安装完成之后也不行,一直报错
执行命令报错:
$ 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安装目录,查看是否是因为路径问题
$ 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入手,看看相关的功能。
查看目录中是否有相关的目录
$ 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报错】