Rorcraft Blog

How to compile ffmpeg on Mac and Linux

Default compile command
—- htmltar zxvf xxx.tar.gz
./configure —prefix=/usr —enable-shared
make && sudo make install

1
2
3
4
1, lame
--- html
http://sourceforge.net/project/showfiles.php?group_id=290 (lame-3.97.tar.gz)
compile

2, Ogg, Vorbis, Theora

1
2
http://xiph.org/downloads/ (libvorbis,libtheora,libogg)
compile

3, NASM

1
2
http://sourceforge.net/project/showfiles.php?group_id=6208 (nasm sources)
compile

4, xvid
http://downloads.xvid.org/downloads/
—- htmltar xvidcore-1.1.3.tar.gz
cd xvidcore-1.1.3/build/generic/
compile

1
2
3
4
5
6
Problem: nasm: fatal: unrecognised output format ../../src/bitstream/x86_asm/cbp_3dne.asm - use -hf for a list (http://rob.opendot.cl/index.php/useful-stuff/xvid-with-asm-on-os-x/)
Solution:
--- html./configure --prefix=/usr --enable-shared --enable-macosx_module
vi platform.inc:
< SPECIFIC_CFLAGS=-fPIC -fno-common -no-cpp-precomp 
< CFLAGS=-Wall -O2 -fstrength-reduce -finline-functions -ffast-math -fomit-frame-pointer

> SPECIFIC_CFLAGS=-fPIC -fno-common -no-cpp-precomp -DHAVE_PTHREAD -undefined suppress
> CFLAGS=-Wall -O3 -fstrength-reduce -finline-functions -ffast-math -fomit-frame-pointer -march=prescott
41c41
< AFLAGS=-I$(<D)/ -f

1
2
3
> add '-f macho -DPREFIX' at the end of the line
48c48
< SPECIFIC_LDFLAGS=-r -keep_private_externs -nostdlib && $(CC) $(LDFLAGS) $(PRE_SHARED_LIB) -o libxvidcore.$(SHARED_EXTENSION).$(API_MAJOR) -bundle -flat_namespace -undefined suppress 

> SPECIFIC_LDFLAGS=-r -keep_private_externs -nostdlib && $(CC) $(LDFLAGS) $(PRE_SHARED_LIB) -o libxvidcore.$(SHARED_EXTENSION).$(API_MAJOR) -bundle -flat_namespace -undefined
make
sudo make install

1
2
3
4
5
6
7
8
9
10
11
12
5, x264
svn co svn://svn.videolan.org/x264/trunk x264
compile

Problem: common/i386/dct-a.asm:124: panic: invalid section name (for Macosx)
Solution:
--- htmlinstall latest nasm and xcode(maybe re-install it, need some package installed)
download patch http://www.via.ecp.fr/via/ml/x264-devel/2006-12/msg00030.html
patch < ./x264-darwin-build.patch  ./configure --prefix=/usr --enable--dynamic 
make clean 
make  
sudo make install

6, a52codec
http://liba52.sourceforge.net/ (a52codec-0.7.4)
compile

Problem: on ubuntu
—- html./configure —prefix=/usr
make && sudo make install

1
2
3
4
5
6
7
8
7, mpg4 aac
http://sourceforge.net/project/showfiles.php?group_id=704 (faad2-src, faac-src)
--- htmlA). cd faac
chmod +x bootstrap
./bootstrap
./configure --prefix=/usr --with-mp4v2 --enable-shared
make
sudo make install

Problem : cannot run ./bootstrap on ubuntu
—- htmlsudo apt-get install autoconf
sudo apt-get install automake
sudo apt-get install libtool

1
2
3
4
5
6
Problem: bad interpreter: No such file or directory. (for Macosx)
Solution:
--- htmlchange bootstrap to unix format (or use dos2unix)
tr -d '\015' < bootstrap > bootstrapa
mv bootstrapa bootstrap
chmod +x bootstrap

Problem: cannot find libtoolsize with Mac
Solution: - htmlsudo ln -s /usr/bin/glibtoolize /usr/bin/libtoolize

1
2
3
Problem: .infig.status: error: cannot find input file:
Solution: --- htmlfind . -type f | xargs dos2unix
chmod +x configure

B). cd faad2
—- html./bootstrap
./configure —prefix=/usr —with-mp4v2 —enable-shared
make
make install

1
2
Use the following command with Mac i386Ôºö
--- htmlmake "CC=gcc -arch i386 -DHAS_LRINTF -Z -L'/Developer/SDKs/MacOSX10.4u.sdk/usr/lib'"

Problem: on ubuntu
—- htmldownload http://packages.ubuntu.com/feisty/libs/libfaad2-0
http://packages.ubuntu.com/dapper/libdevel/libfaad2-dev
sudo dpkg -i xxx.deb

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
Problem: plugins/Makefile.am:3: required directory plugins/bmp does not exist
Solution:
--- htmlvi plugins/Makefile.am
Delete
if HAVE_BMP
SUBDIRS = bmp
else
SUBDIRS =
endif #HAVE_BMP

vi configure.in
Delete
if test x$WITHBMP = xyes; then
 AC_DEFINE([HAVE_BMP], 1, [User wants beep media player plugin built])
 AM_CONDITIONAL([HAVE_XMMS], true)
 AM_CONDITIONAL([HAVE_BMP], true)
fi

vi plugins/xmms/src/Makefile.am
Change the following line(delete everything about HAVE_BMP)
if HAVE_BMP
libdir=$(shell pkg-config --variable=input-plugin-dir bmp)
local_CFLAGS=$(shell pkg-config --cflags bmp)
local_LDFLAGS=$(shell pkg-config --libs bmp)
else
local_CFLAGS=`$(XMMS_CONFIG) --cflags` -Wall
local_LDFLAGS=`$(XMMS_CONFIG) --libs`
libdir = `$(XMMS_CONFIG) --input-plugin-dir`
endif #HAVE_BMP
To
local_CFLAGS=`$(XMMS_CONFIG) --cflags` -Wall
local_LDFLAGS=`$(XMMS_CONFIG) --libs`
libdir = $(XMMS_CONFIG) --input-plugin-dir

Problem: /usr/include/architecture/i386/math.h:378: error: conflicting types for ‘lrintf’
common.h:329: error: previous definition of ‘lrintf’ was here
Solution:
—- htmlvi libfaad/common.h
311 line add: #ifndef HAS_LRINTF
339 line add: #endif

1
2
3
4
5
6
7
8
9
10
11
12
13
14
8, 3gp

http://www.penguin.cz/~utx/amr (amrnb and amrwb)
compile

9, ffmpeg
--- htmlcd ffmpeg
./configure --prefix=/usr --enable-gpl --enable-pthreads --disable-ffserver --disable-ffplay --enable-pp --enable-shared --enable-libmp3lame --enable-libamr-nb  --enable-libamr-wb --enable-libogg --enable-libtheora --enable-libvorbis --enable-libxvid --enable-liba52 --enable-liba52bin  --enable-libfaad  --enable-libfaadbin --enable-libfaac --enable-libx264
make
sudo make install

ffmpeg --version
FFmpeg version SVN-rUNKNOWN, Copyright (c) 2000-2007 Fabrice Bellard, et al.
  configuration: --prefix=/usr --enable-gpl --enable-pthreads --disable-ffserver --disable-ffplay --enable-pp --enable-shared --enable-libmp3lame --enable-libamr-nb --enable-libamr-wb --enable-libogg --enable-libtheora --enable-libvorbis --enable-libxvid --enable-liba52 --enable-liba52bin --enable-libfaad --enable-libfaadbin --enable-libfaac --enable-libx264

If the ffmpeg command isn’t the new one after re-compile with mac, please:
—- htmlsudo rm /usr/bin/ffmpeg
sudo rm /usr/local/bin/ffmpeg
sudo make install
sudo ln -s /usr/bin/ffmpeg /usr/local/bin/ffmpeg

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
./configure -h
./configure -h > ffmpeg_config.txt

dos2unix, mac2unix for Mac
--- htmlwget http://fresh.t-systems-sfr.com/linux/src/dos2unix-3.1.tar.gz
tar zxvf dos2unix-3.1.tar.gz
cd dos2unix-3.1
rm -f dos2unix
rm -f dos2unix.1
rm -f mac2unix
rm -f mac2unix.1
make all
sudo install -m 755 dos2unix /usr/local/bin
sudo install -m 644 dos2unix.1 /usr/local/man/man1
sudo install -m 755 mac2unix /usr/local/bin
sudo install -m 644 mac2unix.1 /usr/local/man/man1
blog comments powered by Disqus

Contact

We love to hear about your web projects.
Email:
Sydney: +61 421 591 943
Hong Kong:+852 6901 2682

Categories