Compiling 64-bit FFmpeg on Mac OS X Lion or Snow Leopard

本文提供了一个详细的步骤教程,指导如何在Mac OS X Lion或Snow Leopard上成功编译64位FFmpeg。包括安装所需软件,配置和编译FFmpeg库、命令行工具、服务器和播放器。

(updated September 26, 2011)

FFmpeg (http://www.ffmpeg.org) is open source software to record, convert and stream audio and video in numerous formats.

The FFmpeg package requires the following external libraries, which are to be downloaded separately:

  • LAME (Lame Aint an MP3 Encoder), a high quality MPEG Audio Layer III (MP3) encoder
  • FAAC/FAAD2 (Freeware Advanced Audio Coder and Decoder 2), an implementation of the AAC audio compression format.
  • SDL (Simple DirectMedia Layer), is a multimedia library that provides access to graphics, sound, and input devices via OpenGL, and the 2D-video framebuffer.

A successful FFmpeg build yields the following components:

  • FFmpeg libraries, the most important being libavcodec that contains all the FFmpeg audio/video encoders and decoders.
  • ffmpeg, the main command line tool to convert one video file type to another.
  • ffserver, an HTTP a RSTP (Real Time Streaming Protocol) multimedia streaming server.
  • ffplay, a simple media player based on SDL and on the FFmpeg libraries.

Installation steps

1) First, download and install Xcode 3.2.1 (Snow Leopard) or  Xcode 4.1 (Lion) development environment from Apple (https://developer.apple.com/xcode/). Because all sources for FFmpeg are written in C, the gcc compiler that comes with Xcode must be available in your Terminal shell, the command:

$ gcc --version

should print something like:

i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5646)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

2) Download the latest LAME sources from http://sourceforge.net/projects/lame/files/
Unpack, configure, build, and install:

$ tar zxvf lame-398-2.tar.gz
$ cd lame-398-2
$ ./configure
$ make
$ sudo make install

3) Download the latest sources of both FAAC and FAAD2 from http://sourceforge.net/projects/faac/files/
Unpack, configure, build, and install them both:

$ tar zxvf faac-1.28.tar.gz
$ cd faac-1.28
$ ./configure
$ make
$ sudo make install
$
$ tar zxvf faad2-2.7.tar.gz
$ cd faad2-2.7
$ ./configure
$ make
$ sudo make install

4) Download the stable source code of SDL at http://www.libsdl.org/download-1.2.php
Then, generate configuration script, configure, build, and install:

$ cd SDL-1.2.14
$ ./autogen.sh
$ ./configure --disable-assembly
$ make
$ sudo make install

5). Finally, get the latest sources from the FFmpeg project, configure, build, and install:

$ svn checkout svn://svn.ffmpeg.org/ffmpeg/trunk ffmpeg
$ cd ffmpeg
$ ./configure --enable-libmp3lame --enable-libfaac --enable-libfaad --enable-gpl --enable-nonfree --enable-shared --disable-mmx --arch=x86_64 --cpu=core2
$ make
$ sudo make install

If all goes well, the libraries will be installed in /usr/local/lib, and the executables ffmpeg, ffserver and ffplay in /usr/local/bin

Enjoy FFmpeg!

Optional installs

This article would not be complete without optional tools and codecs you may install. They are suited for people who are willing to experiment with compiling and installing stuff. I will keep adding items to this section after I have successfully implemented them myself.

First, we’ll install some extra tools that are required for some of the compiles, or will make your installations easier.

FLVtool

You may have noticed that Flash Video (.flv) files produced by FFmpeg may not show their running time correctly in a media player. FLVtool can insert meta data (e.g. running length) into .flv files. For more information, see http://rubyforge.org/projects/flvtool2/

Because Snow Leopard and Lion both have RubyGems (a Ruby package manager) pre-installed, flvtool2 can be easily obtained:

$ sudo gem install flvtool2

NASM and Yasm

Snow Leopard comes with an old version of NASM (The Netwide Assembler). Both Snow Leopard and Lion have no Yasm (Yet Another Assembler) installed. Therefore, get the latest stable release of NASM at http://www.nasm.us/pub/nasm/releasebuilds/ and of Yasm at http://www.tortall.net/projects/yasm/releases/, install both assemblers:

$ tar zxvf nasm-2.0.7.tar.bz2
$ ./configure
$ make
$ sudo make install
$
$ tar zxvf yasm-0.8.0.tar.gz
$ ./configure
$ make
$ sudo make install

Git

Both Subversion (svn) and CVS are pre-installed on Snow Leopard, but you may also want the other popular version control system, Git. To install Git on Snow Leopard (under Lion it is already present in your developer environment) follow the instructions at http://www.crainbandy.com/how-to/how-to-install-git-on-mac-os-x-leopard-snow-leopard

H.264

x264 is a free software library for encoding video streams into the H.264/MPEG-4 AVC format.
Yasm (installed earlier) is required to compile several assembly language routines present in the x264 code.

To obtain the x264 sources, either download the daily snapshot from http://download.videolan.org/pub/videolan/x264/snapshots/, or use Git:

$ git clone git://git.videolan.org/x264.git
$ cd x264

Take care that the version of x264 >= 0.78. Then, configure, build and install the x264 library with:

$ ./configure
$ make
$ sudo make install

To rebuild FFmpeg to include H.264 support, add these two directives to the configure command:

--enable-libx264 --enable-static

Optional other formats

  • XviD format: libxvid, http://downloads.xvid.org/downloads/xvid_latest.tar.gz
  • Ogg format: libogg, http://downloads.xiph.org/releases/ogg/
  • Ogg Vorbis audio: libvorbis, http://downloads.xiph.org/releases/vorbis/ (requires Ogg)
  • AMR-NarrowBand audio: libamr-nb, http://www.penguin.cz/~utx/amr
  • AMR-WideBand audio: libamr-wb, http://www.penguin.cz/~utx/amr
  • Theora video: libtheora, svn co http://svn.xiph.org/trunk/theora theora (requires Ogg and Vorbis)
  • Speex audio: libspeex, git clone git://git.xiph.org/speex.git (requires Ogg)
  • FLAC audio: libflac, http://sourceforge.net/projects/flac/files/flac-src/
  • GSM audio: libgsm, http://user.cs.tu-berlin.de/~jutta/gsm/gsm-1.0.13.tar.gz
  • NUT format: libnut, svn co svn://svn.mplayerhq.hu/nut/src/trunk/ nut
  • Schroedinger video: libschroedinger, http://diracvideo.org/download/schroedinger/ (requires liboil, http://liboil.freedesktop.org/download/)

Usage examples

  • Extract specific images at a set time, e.g. grabbing 10 frames, 1 per second, starting at 5 minutes:
    ffmpeg -i video.avi -ss 300 -r 1 -t 10 image%02d.png
  • Create a movie out of numbered image files:
    ffmpeg -f image2 -i image%d.jpg video.mpg
  • Converting any video to DVD-compatible MPEG2:
    ffmpeg -y -i video.xyz -vcodec mpeg2video -target ntsc-dvd -r ntsc -deinterlace -aspect 4:3 outputfile.m2v
  • Convert an AVI to a standard PAL DVD
    ffmpeg -i video.avi -target pal-dvd -ps 4000000000 -aspect 16:9 video.mpeg
  • Convert MOV to AVI:
    ffmpeg -i video.mov -sameq -vcodec msmpeg4v2 -acodec pcm_u8 -s 640×360 video.avi
  • Convert FLV to SWF:
    ffmpeg -i video.flv -acodec copy -vcodec copy video.swf
  • Extract audio from an AVI:
    ffmpeg -i video.avi -vn -ar 44100 -ac 2 -ab 192 -f mp3 audio.mp3
  • Convert MTS/M2TS (AVCHD) to AVI:
    ffmpeg -i video.mts -vcodec libxvid -b 18000k -acodec ac3 -deinterlace -s 1440×1080 video.avi
  • Convert MP4 to 3GP (mobile) format
    ffmpeg -i input_video.mp4 -s 176×144 -vcodec h263 -r 25 -b 12200 -ab 12200 -ac 1 -ar 8000 video.3gp
  • Concatenate two AVI’s:
    ffmpeg -i video1.avi -sameq intermediate1.mpg
    ffmpeg -i video2.avi -sameq intermediate2.mpg
    cat intermediate1.mpg intermediate2.mpg > intermediate.mpg
    ffmpeg -i intermediate.mpg -sameq video.avi
于2024年4月-2025年9月期间,研究团队在贵州习水国家级自然保护区制定39条样线,涵盖灌木林、常绿阔叶林、针叶林、常绿落叶阔叶混交林、针阔混交林等不同植被类型,每条样线分春夏秋冬4个季节采集样品,用真菌采集软件记录经纬度、海拔、采集地点、时间、生境等信息,使用佳能相机(R6 mark Ⅱ)对大型真菌进行拍照,并采集标本,标本存放于贵州省生物研究所大型真菌标本馆(HGAMF)。 通过形态学初步鉴定,结合分子生物学最终鉴定,参考已]报道的中国毒蘑菇名录开展毒蘑菇的认定。 调查到保护区内有毒真菌7目25科64种,导致中毒的主要类型有急性肾衰竭型、神经精神型和胃肠炎型。最终形成贵州习水国家级自然保护区大型有毒真菌图片数据集,它由以下2个部分组成。 (1)附件1包含78张原始照片(.JPG),照片名字包括了大型有毒真菌的拉丁名和中文名,若无中文名的直接用拉丁名。 (2)附件2是一个压缩文件,包含了2张工作表,其中一张表是大型有毒真菌39条样线的信息,另一张表是大型有毒真菌的中毒类型。 照片采用佳能相机R6 mark Ⅱ拍摄,物种鉴定通过多种文献核实,并经两位以上专家鉴定确认。该数据集可为研究地及周边的普通人识别有毒大型真菌提供参考,通过及时的图片对比,能有效避免误采误食大型有毒真菌,同时为因误食大型真菌可能引发的身体损伤进行了总结,能为患者及时治疗提供参考。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值