mac安装ffmpeg经验总结

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mac安装ffmpeg经验总结相关的知识,希望对你有一定的参考价值。

参考技术A macos 10.15.5
mac自带终端即可。

解决方法则参考了 这个 ,和 这个作为指南貌似更称职 。
就是安装speex & pkg-config:

还有一个可能冗余的path配置:

以及:

安装x264 & x265就好了:

配置项就搞定了。

或者发现有各种权限问题啥的,加上sudo:

可以运行以下命令查看能不能正常返回version:

记得source你的配置文件。

ffmpeg安装之mac安装

转发自白狼栈:查看原文

关于ffmpeg的安装,有的人可能要折腾很久,甚至折腾一个礼拜,究其原因,基本都是编译安装惹的祸。

我们提供4种安装方式,最复杂的莫过于centos7上的编译安装。

  1. ffmpeg静态库下载安装
  2. 在mac上安装ffmpeg
  3. 在centos7上编译安装ffmpeg
  4. 使用 docker 安装 ffmpeg

大家可以根据自己的喜好选择安装。

今天我们来看一下如何在mac上安装ffmpeg。

在mac上我们有3种方法可以安装ffmpeg。

第一种我们在ffmpeg安装一文中已经提到过了,直接下载静态库;

第二种是编译安装,不仅要安装xcode,还要安装很多的依赖库,还是让我们的mac省省心吧,忽略;

第三种就是我们今天要说的,通过Homebrew安装。

如果在此之前你通过 Homebrew 已经安装过 ffmpeg,可以执行命令 brew uninstall ffmpeg 先进行卸载。

安装之前,我们先看下 Homebrew 的版本,这取决于我们采用哪种方式安装。终端执行 brew -v

» brew -v 
Homebrew 1.8.3
Homebrew/homebrew-core (git revision 38eb; last commit 2018-11-19)

如果你的电脑显示 command not found,请先执行下面的命令安装 Homebrew。

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

请注意,由于 Homebrew 的版本不同,我们接下来又有两种不同的操作方法。

1、Homebrew 版本小于2.0

此时可以先看下 Homebrew 支持哪些配置选项,然后选择安装我们需要的options即可。

» brew options ffmpeg 
--with-chromaprint
 Enable the Chromaprint audio fingerprinting library
--with-fdk-aac
 Enable the Fraunhofer FDK AAC library
--with-fontconfig
 Build with fontconfig support
  ..............................

安装的时候,类似下面这样,你可以自行选择要安装哪些配置选项,这里建议大家把上面所有的option都加上

brew install ffmpeg --with-chromaprint --with-fdk-aac --with-xxx ......
2、Homebrew 版本大于2.0

如果你的 Homebrew 版本大于2.0,通过 brew options ffmpeg,你会发现终端没有输出任何 options。这是怎么回事呢?

ffmpeg官方说了 “Since v2.0, Homebrew does not offer options for its core formulae anymore. Users who want to build ffmpeg with additional libraries (including non-free ones) need to use so-called taps from third party repositories. These repositories are not maintained by Homebrew.”,大概意思是说从Homebrew2.0 开始,Homebrew 不再为其核心公式提供配置选项。所以想要扩展其他库的小伙伴需要选择第三方的存储库 homebrew-ffmpeg。当然你也可以直接选择 brew install ffmpeg,不带任何扩展库,但是这样安装的结果缺少很多编解码库,稍微复杂的命令都执行不了。

首先执行 brew tap 命令

brew tap homebrew-ffmpeg/ffmpeg

然后再看下这个仓库支持的 options

brew options homebrew-ffmpeg/ffmpeg/ffmpeg

最后 install 的时候同样把这些 options 加上,类似下面这样

brew install homebrew-ffmpeg/ffmpeg/ffmpeg --with-chromaprint --with-fdk-aac --with-xxx ......

安装需要一定的时间,安装完之后直接在终端测试 ffmpeg 是否安装成功

» ffmpeg -version
ffmpeg version 4.1 Copyright (c) 2000-2018 the FFmpeg developers
  built with Apple LLVM version 10.0.0 (clang-1000.10.44.4)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/4.1 --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags=\'-I/Library/Java/JavaVirtualMachines/jdk1.8.0_251.jdk/Contents/Home/include -I/Library/Java/JavaVirtualMachines/jdk1.8.0_251.jdk/Contents/Home/include/darwin\' --host-ldflags= --enable-ffplay --enable-gpl --enable-libmp3lame --enable-libopus --enable-libsnappy --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-lzma --enable-chromaprint --enable-frei0r --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfdk-aac --enable-libfontconfig --enable-libfreetype --enable-libgme --enable-libgsm --enable-libmodplug --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-librsvg --enable-librtmp --enable-librubberband --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtesseract --enable-libtwolame --enable-libvidstab --enable-libwavpack --enable-libwebp --enable-libzmq --enable-opencl --enable-openssl --enable-videotoolbox --enable-libopenjpeg --disable-decoder=jpeg2000 --extra-cflags=-I/usr/local/Cellar/openjpeg/2.3.0/include/openjpeg-2.3 --enable-nonfree
  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

如果你用的仓库是 homebrew-ffmpeg/ffmpeg/ffmpeg,版本应该也是4.x的,唯一的不同可能多了几个options。

但是无论上面哪种情况,你都应该至少指定配置选项option,因为我们后面针对ffmpeg的操作会有些复杂。

以上是关于mac安装ffmpeg经验总结的主要内容,如果未能解决你的问题,请参考以下文章

2019年终总结&小半年流媒体服务器开发经验总结

经验总结Mac IDEA 调试技巧大大提高研发效率

Macbook 使用经验总结

近日经验总结

loadrunner安装经验总结

linux经验总结