广告
返回顶部
首页 > 资讯 > 后端开发 > Python >macos安装ffmpeg以及出现问题
  • 692
分享到

macos安装ffmpeg以及出现问题

macosffmpeg 2023-01-31 07:01:00 692人浏览 薄情痞子

Python 官方文档:入门教程 => 点击学习

摘要

安装FFmpeg使用brew首先安装brew: /usr/bin/ruby -e "$(curl -fsSL https://raw.GitHubusercontent.com/Homebrew/install/master/instal

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

--结束END--

本文标题: macos安装ffmpeg以及出现问题

本文链接: https://www.lsjlt.com/news/192194.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作