FFmpeg Understanding(6.How to compile and install external libs of FFMPEG?)

本文详细介绍了如何在FFMPEG中安装各种外部库,包括NASM、MP3 LAME等,提供了具体步骤如下载、配置、编译及安装,并针对不同类型的库给出了相应的注意事项。

How to compile and install external libs of FFMPEG?

It is a boring task to compile and install the external libs of FFMPEG, but to enjoy many good videos/audios, I have to travel over mountains and waters. If you have same feeling, let’s go! Furthermore, the article discusses the latest version when writing it. If new version is available, please use them. However, the methods should be coherent.


[Install NASM compiler]

1. Download nasm-2.06rc1.tar.bz2

2. Extract it in your appropriate folder

$ tar xvjf ./nasm-2.06rc1.tar.bz2

3. Configure it

$ cd ./nasm-2.06rc1

$ ./configure --prefix=/mingw

4. Compile it

$ make

5. Install it

$ make install

 

[Install Mp3lame]

1. Download lame-398-2.tar.gz

2. Extract it in your appropriate folder

$ tar xvzf ./lame-398-2.tar.gz

3. Configure it for shared lib. There are some errors when trying my best to setup static lib, so I select the shared mode. I think that the new version will issue the patch to fix it. Of course, if users unset --enable-nasm by sacrifice the performance, the static lib can be generated.

a) shared lib

$ cd ./lame-398-2

$ ./configure --prefix=/mingw --enable-shared --disable-static --enable-nasm

b) static lib

$ ./configure --prefix=/mingw --disable-shared --enable-static

4. Compile the source codes

$ make

5. Install lib

$ make install

 

[Install YASM]

1. Download yasm-0.7.2.tar.gz

2. Extract it into appropriate folder

$ tar xvzf ./yasm-0.7.2.tar.gz

3. Configure it

$ cd ./yasm-0.7.2

$ ./configure --prefix=/mingw

4. Compile it

$ make

5. Install it

$ make install

 

[Install XVID]

1. Download it by CVS tool

$ cvs -d:pserver:anonymous@cvs.xvid.org:/xvid login
$ cvs -d:pserver:anonymous@cvs.xvid.org:/xvid co xvidcore

2. Configure it. The current XVID only can be compiled in light of shared mode!

$ cd ./xvidcore/build/generic

$ ./configure --prefix=/mingw

3. Compile it

$ make

4. Install it

$ make install

$ cp /mingw/lib/xvidcore.dll /mingw/bin

 

[Install X264]

1. Download it by git tool

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

2. Configure it

$ cd ./x264

$ ./configure –prefix=/mingw

3. Compile it

$ make

4. Install it

$ make install

 

[Install FAAC]

1. Download faac-1.26.tar.gz

2. Extract it into your appropriate folder

$ tar xvzf ./faac-1.26.tar.gz

3. Configure it

$ cd ./faac

$ ./bootstrap

$ ./configure –prefix=/mingw –disable-shared –enable-static

4. Compile it

$ make

5. Install it

$ make install

 

[Install FAAD2]

1. Download faad2-2.6.1.tar.gz

2. Download faad2-2.6.1.patch

3. Extract it into your appropriate folder

$ tar xvzf ./faad2-2.6.1.tar.gz

$ patch –p0 < ./faad2-2.6.1.patch

4. Configure it

$ cd ./faad2

$ ./bootstrap

$ ./configure --prefix=/mingw --enable-static --disable-shared

5. Compile it

$ make LDFLAGS="-no-undefined"

6. Install it

$ make install

 

[Install OGG]

OGG lib is essential element for VORBIS lib.

1. Download libogg-1.1.3.tar.gz

2. Extract it into your appropriate folder

$ tar xvzf ./libogg-1.1.3.tar.gz

3. Configure it

$ cd ./libogg-1.1.3

$ ./configure –prefix=/mingw –disable-shared –enable-static

4. Compile it

$ make

5. Install it

4 make install

 

[Install VORBIS]

1. Download vorbis-tools-1.2.0.tar.gz

2. Extract it into your appropriate folder

$ tar xvzf ./vorbis-tools-1.2.0.tar.gz

3. Configure it

$ cd libvorbis-1.2.0

$ ./configure –prefix=/mingw –disable-shared –enable-static

4. Compile it

$ make

5. Install it

$ make install

 

[Install SDL]

1. Download it by SVN tool

$ svn checkout http://svn.libsdl.org/trunk/SDL

2. Configure it

$ cd ./SDL

$ ./autogen.sh

$ ./configure –prefix=/mingw –disable-shared –enable-static –enable-sse2 –enable-ssemath

3. Compile it

$ make

4. Install it

$ make install

 

[Install THEORA]

1. Download libtheora-1.0beta3.tar.gz

2. Extract it into your appropriate folder

$ tar xvzf ./libtheora-1.0beta3

3. Configure it

$ cd ./libtheora-1.0beta3

$ ./configure –prefix=/mingw –disable-shared –enable-static

4. Compile it

$ make

5. Install it

$ make install

 

[Install SPEEX]

1. Download speex-1.2rc1.tar.gz

2. Extract it into your appropriate folder

$ tar xvzf ./speex-1.2rc1.tar.gz

3. Configure it

$ cd ./speex-1.2rc1

$ ./configure –prefix=/mingw –disable-shared –enable-static –enable-sse

4. Compile it

$ make

5. Install it

$ make install

 

[Install GSM]

Please refer FFmpeg Understanding(5. How to install GSM lib for FFMPEG?)

Install OIL

1. Download liboil-0.3.16.tar.gz

2. Extract it into your appropriate folder

$ tar xvzf ./liboil-0.3.16.tar.gz

3. Configure it

$ cd ./liboil-0.3.16

$ ./configure --prefix=/mingw --disable-shared --enable-static

4. Compile it

$ make

5. Install it

$ make install

 

Install schroedinger

1. Download glib_2.18.3-1_win32.zip and pkg-config-0.23-2.zip

2. Extract pkg-config.exe into /mingw/bin in the pkg-config-0.23-2.zip

3. Extract libglib-2.0-0.dll into /mingw/bin in the glib_2.18.3-1_win32.zip

4. Download schroedinger-1.0.7.tar.gz

5. Extract it into your appropriate folder

$ tar xvzf ./schroedinger-1.0.7.tar.gz

6. Configure it

$ cd ./schroedinger-1.0.7

$ ./configure --prefix=/mingw --disable-shared --enable-static --enable-encoder --with-thread=win32 && make

7. Compile it

$ make

8. Install it

$ make install

 

Install openjpeg

1. Download openjpeg_v1_3.tar.gz

2. Extract it into your appropriate folder

$ tar xvzf ./openjpeg_v1_3.tar.gz

3. Configure it

$ vim ./Makefile

  14 PREFIX = /mingw

 

  48 #OpenJPEG: $(STATICLIB) $(SHAREDLIB)

  49 OpenJPEG: $(STATICLIB)

 

  57 #$(SHAREDLIB): $(MODULES)

  58 #   $(CC) -s -shared -Wl,-soname,$(LIBNAME) -o $@ $(MODULES) $(LIBRARIES)

 

  62 #   install -m 644 -o root -g root $(STATICLIB) '$(DESTDIR)$(INSTALL_LIBDIR)'

  63     install -m 644 $(STATICLIB) '$(DESTDIR)$(INSTALL_LIBDIR)'

  64     ranlib '$(DESTDIR)$(INSTALL_LIBDIR)/$(STATICLIB)'

  65 #   install -m 755 -o root -g root $(SHAREDLIB) '$(DESTDIR)$(INSTALL_LIBDIR)'

  66 #   ln -sf $(SHAREDLIB) '$(DESTDIR)$(INSTALL_LIBDIR)/$(LIBNAME)'

  67 #   install -m 644 -o root -g root libopenjpeg/openjpeg.h '$(DESTDIR)$(INSTALL_INCLUDE)'

  68     install -m 644 libopenjpeg/openjpeg.h '$(DESTDIR)$(INSTALL_INCLUDE)'

  69 #   -ldconfig

 

  72 #   rm -rf core dist/ u2dtmp* $(MODULES) $(STATICLIB) $(SHAREDLIB) $(LIBNAME)

  73     rm -rf core dist/ u2dtmp* $(MODULES) $(STATICLIB)

4. Compile it

$ make CFLAGS="-DWIN32 -DOPJ_STATIC $CFLAGS"

5. Install it

$ make install

 

Install libnut

1. Download source code.

svn co svn://svn.mplayerhq.hu/nut/src/trunk libnut



2. Modify demuxer.c, and red color marks the changes.

Original source code

Source code modified

static off_t stream_seek(void * priv, long long pos, int whence) {

       fseek(priv, pos, whence);

       return ftello(priv);

}

static off_t stream_seek(void * priv, long long pos, int whence) {

       fseek(priv, pos, whence);

       return ftell(priv);

}

3. Modify config.mk, and red color marks the changes.

Original Configuration

Configuration modified

PREFIX = /usr/local

prefix = $(DESTDIR)$(PREFIX)

 

#CFLAGS += -DDEBUG

 

CFLAGS += -Os -fomit-frame-pointer -g -Wall

 

CFLAGS += -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64

 

CC = cc

RANLIB  = ranlib

AR = ar

PREFIX = /mingw

prefix = $(DESTDIR)$(PREFIX)

 

#CFLAGS += -DDEBUG

 

CFLAGS += -O3 -fomit-frame-pointer -Wall

 

CFLAGS += -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64

 

CC = gcc

RANLIB  = ranlib

AR = ar

4. Compile it

 

$ make

5. Install it

$ make install

 

Install opencore-amr

Please refer to How to compile opencore-amr in the MINGW .

 

 

[How to use above external lib by FFMPEG?]

$ cd ./ffmpeg

$ make uninstall

$ make distclean

$ ./configure --prefix=/mingw --enable-memalign-hack --enable-shared --disable-static --enable-w32threads --enable-libx264 --enable-libmp3lame --enable-libxvid --enable-gpl --enable-avfilter --enable-postproc --enable-avfilter-lavf --enable-swscale --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libfaac --enable-libfaad --enable-libgsm --enable-libopenjpeg --enable-libschroedinger --enable-libnut --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-version3

$ make

$ make install

 

[Summarization]

1. The general way to acquire external libs are:

   a) Use tool to check them out, for example, cvs, svn, wget, git, and so on.

   b) Download source-codes released, and extract them into appropriate folder.

2. The fixed mode to configure, compile and install. They have been shown in the above contents, such as:

$ ./xxxx.sh #if it exists

$ ./configure –prefix=/mingw …

$ make

$ make install

3. Try you best to make static lib if there are too many shared files in your project. The basic method is add ‘--disable-shared’ and ‘--enable-static’ option in the command of configure .

4. Prepare the dependent libs before installing it. You can use ‘./configure –h’ to probe the relationships among them.

5. http://downloads.xiph.org/releases/ is a good place to find libs.

 

[Appendix: the other useful libs]

1. A52 decoder:

cvs -d:pserver:anonymous@liba52.cvs.sourceforge.net:/cvsroot/liba52 login

cvs -z3 -d:pserver:anonymous@liba52.cvs.sourceforge.net:/cvsroot/liba52 co -P .

2. DTS decoder:

   cvs -d:pserver:anonymous@dts.cvs.sourceforge.net:/cvsroot/dts login

   cvs -z3 -d:pserver:anonymous@dts.cvs.sourceforge.net:/cvsroot/dts co -P .

3. flvtools

   wget http://rubyforge.org/frs/download.php/9225/flvtool2_1.0.5_rc6.tgz

4. armnb

   wget http://ftp.penguin.cz/pub/users/utx/amr/amrnb-6.1.0.4.tar.bz2

5. libiconv

http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.12.tar.gz

6. zlib:

   http://www.zlib.net/

7. freetype2

   http://sourceforge.net/project/showfiles.php?group_id=3157

8. libregif

   http://armory.nicewarrior.org/projects/libregif/

9. libpng

   http://www.libpng.org/pub/png/

   http://sourceforge.net/project/showfiles.php?group_id=5624

10. live555

   http://www.live555.com/liveMedia/

 

 

[History]

1. 01/23/2009 --- draft

2. 04/19/2009 --- fix some errors

3. 04/25/2009 --- Add libnuts, schreodinger, openjpeg

4. 08/01/2009 --- Add opencore-amr


在解决 `Could not find com.google.android.exoplayer:extension-ffmpeg:2.14.2` 这类 Gradle 依赖找不到的问题时,通常需要从多个角度排查,包括版本号的准确性、Gradle 插件版本兼容性、Maven 仓库配置以及网络问题等。 ### 1. 确认版本号是否正确 首先需要确认 `com.google.android.exoplayer:extension-ffmpeg:2.14.2` 是否确实存在。ExoPlayer 的某些扩展模块(如 FFmpeg 扩展)可能不会在所有版本中都提供,或者版本号命名方式可能有所不同。建议访问 [ExoPlayer 官方 GitHub 页面](https://github.com/google/ExoPlayer) 或 [Maven Central](https://search.maven.org/) 查询该模块是否存在。 如果版本号不存在或拼写错误,则需要更正为正确的版本号。 ### 2. Gradle 插件版本兼容性 Gradle 插件版本与 ExoPlayer 版本之间可能存在兼容性问题。例如,旧版 Gradle 插件(如 3.x)可能无法正确解析新版 ExoPlayer 的依赖。建议升级 Android Studio 和 Gradle 插件到最新稳定版本,以确保兼容性和修复潜在 bug [^2]。 在 `build.gradle` 项目级文件中更新 Gradle 插件版本: ```gradle buildscript { repositories { google() mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:7.2.1' // 确保为最新稳定版本 } } ``` ### 3. 配置 Maven 仓库 确保在 `build.gradle` 文件中正确配置了 Google 的 Maven 仓库和 Maven Central: ```gradle repositories { google() mavenCentral() } ``` ExoPlayer 及其扩展模块通常托管在 Google 的 Maven 仓库中。如果缺少该仓库配置,Gradle 将无法找到依赖项 [^1]。 ### 4. 检查网络与代理设置 Gradle 下载依赖时可能受网络限制或代理设置影响。可以尝试在命令行中使用 `ping maven.google.com` 或 `curl` 检查是否可以访问 Google 的 Maven 仓库。 如果使用代理,可以在 `gradle.properties` 中配置代理设置: ```properties systemProp.http.proxyHost=proxy.example.com systemProp.http.proxyPort=8080 systemProp.https.proxyHost=proxy.example.com systemProp.https.proxyPort=8080 ``` ### 5. 使用本地依赖作为临时方案 如果无法通过远程仓库获取依赖,可以尝试手动下载 AAR 文件并作为本地依赖引入。例如,将 `extension-ffmpeg.aar` 放入 `app/libs/` 目录,并在 `build.gradle` 中添加: ```gradle flatDir { dirs 'libs' } ``` 然后在依赖中引用: ```gradle implementation files('libs/extension-ffmpeg-release.aar') ``` ### 示例代码 以下是一个完整的 `build.gradle` 示例片段: ```gradle // 项目级 build.gradle buildscript { repositories { google() mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:7.2.1' } } // 模块级 build.gradle android { namespace 'com.example.myapp' compileSdk 33 defaultConfig { minSdk 21 targetSdk 33 versionCode 1 versionName "1.0" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } } dependencies { implementation 'com.google.android.exoplayer:exoplayer:2.14.2' implementation 'com.google.android.exoplayer:extension-ffmpeg:2.14.2' } ``` ---
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值