Android:如何在android studio中配置FFMPEG最新版本? [英] Android: How to configure FFMPEG latest version in android studio?

查看:278
本文介绍了Android:如何在android studio中配置FFMPEG最新版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在android studio中配置 FFMPEG ,但是我无法获得任何文档或链接。 Github在许多 FFMPEG lib可用于android,但所有都是旧版本。还有如何在android中运行命令?而且我想知道配置 FFMPEG 然后我们如何运行 FFMPEG 命令。帮助我感谢你的提前。



我已经使用以下链接,但没有成功获取最新版本。


http://writingminds.github.io/ffmpeg-android-java



https://github.com/WritingMinds/ffmpeg-android-java



https://github.com/havlenapetr/FFMpeg



https://github.com/appunite/AndroidFFmpeg



https://github.com/WritingMinds/ffmpeg-android



解决方案

最新版本的 FFMPEG 3.1.1,12天前刚刚发布。所以我认为没有任何可以使用这样一个旧版本的演示



我们需要自行构建 FFMPEG 库。我发现刚刚粘贴的一些问题可能会帮助您。 (未测试)



如何为Android构建FFmpeg


  1. 使用Android NDK r10编译FFmpeg 2.3

  2. 如何使用android-ndk-r10d在Windows上编译ffmpeg-2.5.3

  3. 如何使用cygwin和android ndk r9c在Windows上编译ffmpeg-2.2.2

  4. 如何在Windows中使用android-ndk-r10d来添加ffmpeg

您需要自己编译它通过下载 Android NDK &

$ b $ b

还有一个教程:如何为Android构建FFmpeg 。这是相当老,所以你只需要更改这里提到的版本。对于 FFMPEG ,它将是 3.1.1 & NDK将是 r12b






code> FFMPEG 与NDK r12b:


  1. 下载Android NDK :最新版本的Android NDK可以从 Android NDK网站下载。在撰写此答案时,最新版本是NDK r12。只需解压档案


  2. 下载ffmpeg源代码:FFMPEG源代码可以从 ffmpeg网站。最新的稳定版本是3.1.1(在写作时)。下载源代码并将其解压缩到$ NDK / sources文件夹。


  3. 更新配置文件:打开ffmpeg-3.1.1 /使用文本编辑器配置文件,并找到以下几行。

      SLIBNAME_WITH_MAJOR ='$(SLIBNAME)$(LIBMAJOR) 
    LIB_INSTALL_EXTRA_CMD ='$$(RANLIB)$(LIBDIR)/ $(LIBNAME)'
    SLIB_INSTALL_NAME ='$(SLIBNAME_WITH_VERSION)'
    SLIB_INSTALL_LINKS ='$(SLIBNAME_WITH_MAJOR)$(SLIBNAME )'

    这使得ffmpeg共享库被编译为
    libavcodec.so。 (例如libavcodec.so.55),这不是
    与Android构建系统兼容。因此,我们需要用以下行代替
    以上行。

      SLIBNAME_WITH_MAJOR ='$(SLIBPREF) $(FULLNAME) -  $(LIBMAJOR)$(SLIBSUF)'
    LIB_INSTALL_EXTRA_CMD ='$$(RANLIB)$(LIBDIR)/ $(LIBNAME)'
    SLIB_INSTALL_NAME ='$(SLIBNAME_WITH_MAJOR)
    SLIB_INSTALL_LINKS ='$(SLIBNAME)


  4. 构建ffmpeg: / strong>将以下文本复制到文本编辑器,并将其保存为ffmpeg_3.1.1文件夹中的build_android.sh。

     #! / bin / bash 
    NDK = $ HOME / Desktop / adt / android-ndk-r9
    SYSROOT = $ NDK / platforms / android-9 / arch-arm /
    TOOLCHAIN = $ NDK /工具链/ arm-linux-androideabi-4.8 / prebuilt / linux-x86_64
    函数build_one
    {
    ./configure
    --prefix = $ PREFIX
    --enable -shared
    --disable-static
    --disable-doc
    --disable-ffmpeg
    --disable-ffplay
    --disable-ffprobe
    --disable-ffserver
    --disable-avdevice
    --disable-doc
    --disable-symver
    - 前缀= $ TOOLCHAIN / bin / arm-linux-androideabi-
    --target-os = linux
    --arch = arm
    --enable-cross-compile
    --sysroot = $ SYSROOT
    --extra-cflags = - Os -fpic $ ADDI_CFLAGS
    --extra-ldflags =$ ADDI_LDFLAGS
    $ ADDITIONAL_CONFIGURE_FLAG
    make clean
    make
    make install
    }
    CPU = arm
    PREFIX = $(pwd)/ android / $ CPU
    ADDI_CFLAGS = - marm
    build_one

    保存文件后,转到此文件所在的目录执行以下命令,

      sudo chmod + x build_android.sh 

    然后通过命令执行脚本,

      ./ build_android .sh 


  5. 构建输出:构建可能需要一段时间根据您的计算机速度完成。一旦完成,您应该能够找到一个文件夹$ NDK / sources / ffmpeg-3.1.1 / android,其中包含arm / lib和arm / include文件夹。


  6. 使ffmpeg可用于您的项目的库



< blockquote>

上面的步骤经过了全面测试,我在我的机器上执行,
构建成功。对于写这个答案我已经从这篇文章$ a
引用如何使用NDK
r9构建ffmpeg

但是对于旧版本我已经对我的
拥有了一些更正。 p>

打开询问任何疑问。


I want to configure FFMPEG in android studio but i cant get any document or link for that. Github on many FFMPEG lib available for android but that all are with old version. And how to run command in android? and i want to know after configure FFMPEG then how can we run FFMPEG commands. Help me for that. thanks advance.

I have used below links but not success in for latest version.

http://writingminds.github.io/ffmpeg-android-java

https://github.com/WritingMinds/ffmpeg-android-java

https://github.com/havlenapetr/FFMpeg

https://github.com/appunite/AndroidFFmpeg

https://github.com/WritingMinds/ffmpeg-android

解决方案

The latest version of FFMPEG is 3.1.1, Just released before 12 days. So i think there is no readily available demo like this old one.

We need to build the FFMPEG library on our own. Some questions i found just pasting here that might help you. (Not tested)

How to Build FFmpeg for Android

  1. Compiling FFmpeg 2.3 with Android NDK r10
  2. How to compile ffmpeg-2.5.3 on windows with android-ndk-r10d
  3. How to compile ffmpeg-2.2.2 on windows with cygwin and android ndk r9c
  4. How to buid ffmpeg with android-ndk-r10d in windows

You need to compile it on your own the by downloading Android NDK & Latest Version of FFMPEG.

One tutorial is also there : How to Build FFmpeg for Android. This is quite old so you just need to change the versions mentioned here. For FFMPEG it will be 3.1.1 & NDK it will be r12b.


Building FFMPEG with NDK r12b:

  1. Download Android NDK : The latest version of Android NDK can be downloaded at Android NDK website. At the time of writing this answer, the newest version is NDK r12. simply decompress the archive

  2. Download ffmpeg source code : FFMPEG source code can be downloaded from the ffmpeg website. The latest stable release is 3.1.1 (at the time of writing). Download the source code and decompress it to $NDK/sources folder.

  3. Update configure file : Open ffmpeg-3.1.1/configure file with a text editor, and locate the following lines.

    SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)'
    LIB_INSTALL_EXTRA_CMD='$$(RANLIB) "$(LIBDIR)/$(LIBNAME)"'
    SLIB_INSTALL_NAME='$(SLIBNAME_WITH_VERSION)'
    SLIB_INSTALL_LINKS='$(SLIBNAME_WITH_MAJOR) $(SLIBNAME)'
    

    This cause ffmpeg shared libraries to be compiled to libavcodec.so. (e.g. libavcodec.so.55), which is not compatible with Android build system. Therefore we’ll need to replace the above lines with the following lines.

    SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
    LIB_INSTALL_EXTRA_CMD='$$(RANLIB) "$(LIBDIR)/$(LIBNAME)"'
    SLIB_INSTALL_NAME='$(SLIBNAME_WITH_MAJOR)'
    SLIB_INSTALL_LINKS='$(SLIBNAME)
    

  4. Build ffmpeg : Copy the following text to a text editor and save it as build_android.sh in ffmpeg_3.1.1 folder.

        #!/bin/bash
        NDK=$HOME/Desktop/adt/android-ndk-r9
        SYSROOT=$NDK/platforms/android-9/arch-arm/
        TOOLCHAIN=$NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64
        function build_one
        {
            ./configure
                --prefix=$PREFIX
                --enable-shared
                --disable-static
            --disable-doc
                    --disable-ffmpeg
                --disable-ffplay
                --disable-ffprobe
                --disable-ffserver
                --disable-avdevice
                --disable-doc
                --disable-symver
                --cross-prefix=$TOOLCHAIN/bin/arm-linux-androideabi-
                --target-os=linux
                --arch=arm
                --enable-cross-compile
                --sysroot=$SYSROOT
                --extra-cflags="-Os -fpic $ADDI_CFLAGS"
                --extra-ldflags="$ADDI_LDFLAGS"
            $ADDITIONAL_CONFIGURE_FLAG
            make clean
            make
            make install
        }
        CPU=arm
        PREFIX=$(pwd)/android/$CPU
        ADDI_CFLAGS="-marm"
        build_one
    

    Once the file is saved, go to the directory where this file lies & execute the command below,

    sudo chmod +x build_android.sh
    

    Then execute the script by the command,

    ./build_android.sh
    

  5. Build Output : The build can take a while to finish depending on your computer speed. Once it’s done, you should be able to find a folder $NDK/sources/ffmpeg-3.1.1/android, which contains arm/lib and arm/include folders.

  6. Make ffmpeg Libraries available for Your Projects

Steps above are fully tested and i performed them on my machine and the build was successful. For writing this answer i have took the reference from this article How to Build ffmpeg with NDK r9 but as it was for older version i have made some corrections on my own.

Open for asking any doubts.

这篇关于Android:如何在android studio中配置FFMPEG最新版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆