适用于 Android 的 Lame MP3 编码器编译

发布于 2024-12-22 15:35:03 字数 69 浏览 3 评论 0 原文

我想为Android编译蹩脚的编码器。如何找到 Lame 及其针对 Android 平台的编译教程。

谢谢,

I want to compile the lame encoder for Android. How can I find the tutorials for Lame and its compiling for Android platform.

Thanks,

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

少跟Wǒ拽 2024-12-29 15:35:03

曾经有一篇很好的博客文章 关于如何为Android编译lame,但由于某种原因它已经离线了一段时间并且只能在一些狡猾的中文网站上使用。

我直接复制下面的内容:

使用 Android NDK 将编译 lame 编码器移植到 Android ARM arch

我正在Android Market寻找mp3编码应用程序,
发现很少,我认为Android不支持mp3的原因
编码是因为mp3是专利技术。另一个原因是我
我猜人们更喜欢 Java 编程和 Android SDK,而不是
Android 原生开发套件。

尽管如此,还是使用 Android 为 Android 编译 libmp3lame 库
NDK 其实很简单。

  1. 下载Android NDK(还需要Android SDK和带ADT插件的Eclipse)并创建简单的项目。
  2. 在项目目录中创建名为“jni”的目录。
  3. 下载lame源码,解压,将所有源码从libmp3lame目录复制到jni目录。同时复制位于 lame 源的 include 目录中的 lame.h。
  4. 创建 jni/Android.mk 文件。它应该看起来像这样:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)`
LOCAL_MODULE    := mp3lame
LOCAL_SRC_FILES := bitstream.c fft.c id3tag.c mpglib_interface.c presets.c  quantize.c   reservoir.c tables.c  util.c  VbrTag.c
   encoder.c  gain_analysis.c lame.c  newmdct.c   psymodel.c
   quantize_pvt.c set_get.c  takehiro.c vbrquantize.c version.c
include $(BUILD_SHARED_LIBRARY)
  • 清理蹩脚的源代码,删除 GNU 自动工具中剩余的内容,Makefile.amMakefile.inlibmp3lame_vc8.vcproj logoe.icodepcomp、文件夹i386vector
  • 编辑文件jni/utils.h,并替换定义extern ieee754_float32_t fast_log2(ieee754_float32_t x);
    有了这个extern float fast_log2(float x);
  • 转到 Android 项目的根目录并运行 $pathtoandroidndk/ndk-build 就完成了,您将编译 limp3lame.so。< /里>
  • 另外,您可能会对以下关于SO的问题感兴趣,因为它处理为Android编译lame后的一些问题:

    There used to be a good blog post on how to compile lame for Android, but for some reason it's been offline for a while and only available on some dodgy Chinese sites.

    I'll just copy the content below:

    porting compiling lame encoder to Android ARM arch using Android NDK

    I was looking for a mp3 encoding application in Android Market,
    and found very few, the reason I think Android doesn't support mp3
    encoding is because mp3 is patented technology. Another reason is I
    guess people prefer Java programming and Android SDK rather than
    Android native development kit.

    Nevertheless compiling libmp3lame library for Android using Android
    NDK is very easy actually.

    1. download Android NDK(also you need Android SDK and Eclipse with ADT plugin) and create simple project.
    2. create directory called "jni" in your project's directory.
    3. download lame sources, extract, copy all sources from directory libmp3lame to jni directory. Also copy lame.h which is located in include directory of lame sources.
    4. create jni/Android.mk file. it should look like this:
    LOCAL_PATH := $(call my-dir)
    include $(CLEAR_VARS)`
    LOCAL_MODULE    := mp3lame
    LOCAL_SRC_FILES := bitstream.c fft.c id3tag.c mpglib_interface.c presets.c  quantize.c   reservoir.c tables.c  util.c  VbrTag.c
       encoder.c  gain_analysis.c lame.c  newmdct.c   psymodel.c
       quantize_pvt.c set_get.c  takehiro.c vbrquantize.c version.c
    include $(BUILD_SHARED_LIBRARY)
    
    1. clean lame sources, remove what's left from GNU autotools, Makefile.am, Makefile.in, libmp3lame_vc8.vcproj, logoe.ico, depcomp, folders i386, vector.
    2. edit file jni/utils.h, and replace definition extern ieee754_float32_t fast_log2(ieee754_float32_t x);
      with this extern float fast_log2(float x);
    3. go to the root directory of your Android project and run $pathtoandroidndk/ndk-build and you're done, you'll have limp3lame.so compiled.

    Also, the following question on SO might be of interest for you, as it deals with some issues after compiling lame for Android:

    [旋木] 2024-12-29 15:35:03

    上述解决方案对我有用,除了:

    • 不要从源目录中删除 vector 目录,
    • 您可以通过添加编译器标志来消除编译警告:LOCAL_CFLAGS = -DSTDC_HEADERS

    The above solution worked for me except:

    • don't delete the vector directory from the source directory
    • you can get rid of the compile warnings by adding a compiler flag: LOCAL_CFLAGS = -DSTDC_HEADERS
    ~没有更多了~
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文