专栏首页python3macos安装ffmpeg以及出现问题

macos安装ffmpeg以及出现问题

安装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报错

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

我来说两句

0 条评论
登录 后参与评论

相关文章

  • 编译VIM

    注意:语言本身的位置好说,但是dev开发库就不一样了。 比如,一般我们本机只安装python,而不会安装python-dev。这是两个完全不一样的概念。第一个我...

    py3study
  • CENTOS 安装python双版本(2

    CentOS6使用Python2.6.6作为系统默认的python,几个关键的系统实用程序都是以它作为开发语言的,例如yum,如果对默认的Python解释器进行...

    py3study
  • django 时区和系统(ubuntu)

    py3study
  • 编译VIM

    注意:语言本身的位置好说,但是dev开发库就不一样了。 比如,一般我们本机只安装python,而不会安装python-dev。这是两个完全不一样的概念。第一个我...

    py3study
  • 二叉树的前、中、后遍历(递归/非递归)

    二叉树的遍历 ? 二叉树的前序遍历 访问根结点,先序遍历左子树,先序遍历右子树 遍历基本步骤为先根结点,然后左子树,然后右子树, 需要注意的是这个遍历需要类似于...

    李家酒馆酒保
  • 剑指offer - 反转链表 - JavaScript

    借助栈的后入先出的顺序,可以将顺序列表逆序。不过这不是原地反转,当然题目也没有要求。

    心谭博客
  • 逆序数(二叉查找树)

    已知数组nums,求新数组count,count[i]代表了在nums[i]右侧且比nums[i]小的元素个数。 例如: nums = [5,2,6,1],...

    小飞侠xp
  • 《代码的未来》读书笔记:也谈闭包

      原文中使用了C语言的函数对象,这里我们主要从.NET平台来说。在.NET中,委托这个概念对C++程序员来说并不陌生,因为它和C++中的函数指针非常类似,很多...

    Edison Zhou
  • Spring Boot快速搭建Web工程

    先想一下,正常我们想要创建一个web服务,首先需要下载tomcat,创建web工程,配置各种web.xml,引入spring的配置,各种配置文件一顿倒腾......

    用户1154259
  • openshift/origin工作记录(5)——node节点系统资源预留

    解决思路为设置node节点系统资源预留值。

    胡了了

扫码关注云+社区

领取腾讯云代金券