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

(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
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
提供的源码资源涵盖了小程序应用等多个领域,每个领域都包含了丰富的实例和项目。这些源码都是基于各自平台的最新技术和标准编写,确保了在对应环境下能够无缝运行。同时,源码中配备了详细的注释和文档,帮助用户快速理解代码结构和实现逻辑。 适用人群: 适合毕业设计、课程设计作业。这些源码资源特别适合大学生群体。无论你是计算机相关专业的学生,还是对其他领域编程感兴趣的学生,这些资源都能为你提供宝贵的学习和实践机会。通过学习和运行这些源码,你可以掌握各平台开发的基础知识,提升编程能力和项目实战经验。 使用场景及目标: 在学习阶段,你可以利用这些源码资源进行课程实践、课外项目或毕业设计。通过分析和运行源码,你将深入了解各平台开发的技术细节和最佳实践,逐步培养起自己的项目开发和问题解决能力。此外,在求职或创业过程中,具备跨平台开发能力的大学生将更具竞争力。 其他说明: 为了确保源码资源的可运行性和易用性,特别注意了以下几点:首先,每份源码都提供了详细的运行环境和依赖说明,确保用户能够轻松搭建起开发环境;其次,源码中的注释和文档都非常完善,方便用户快速上手和理解代码;最后,我会定期更新这些源码资源,以适应各平台技术的最新发展和市场需求。 所有源码均经过严格测试,可以直接运行,可以放心下载使用。有任何使用问题欢迎随时与博主沟通,第一时间进行解答!

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值