Android:如何在Android studio中配置FFMPEG最新版本?

时间:2022-01-13 20:54:02

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.

我想在android studio中配置FFMPEG,但是我无法获得任何文档或链接。Github上有很多针对android的FFMPEG库,但都是旧版本。如何在android中运行命令?我想知道配置完FFMPEG后我们如何运行FFMPEG命令。帮助我。谢谢你提前。

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

我已经使用了以下链接,但不成功的最新版本。

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

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

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

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

https://github.com/havlenapetr/FFMpeg

https://github.com/havlenapetr/FFMpeg

https://github.com/appunite/AndroidFFmpeg

https://github.com/appunite/AndroidFFmpeg

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

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

4 个解决方案

#1


33  

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.

最新版本的FFMPEG是3.1.1,刚刚在12天前发布。所以我认为没有现成的演示像这个旧的。

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

我们需要自己构建FFMPEG库。我发现一些问题贴在这里可能对你有帮助。(未测试)

How to Build FFmpeg for Android

如何为Android构建FFmpeg

  1. Compiling FFmpeg 2.3 with Android NDK r10
  2. 使用Android NDK r10编译FFmpeg 2.3
  3. How to compile ffmpeg-2.5.3 on windows with android-ndk-r10d
  4. 如何在windows上使用android-ndk-r10d编译ffmpeg-2.5.3
  5. How to compile ffmpeg-2.2.2 on windows with cygwin and android ndk r9c
  6. 如何在使用cygwin和android ndk r9c的windows上编译ffmpeg-2.2.2
  7. How to buid ffmpeg with android-ndk-r10d in windows
  8. 如何在windows中使用android-ndk-r10d

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

您需要通过下载Android NDK和最新版本的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.

还有一个教程:如何为Android构建FFmpeg。这已经很老了,所以您只需要更改这里提到的版本。FFMPEG将是3.1.1和NDK, r12b。


Building FFMPEG with NDK r12b:

使用NDK r12b构建FFMPEG:

  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

    下载Android NDK:最新版本的Android NDK可以在Android NDK网站上下载。在写这个答案的时候,最新的版本是NDK r12。只是解压存档

  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.

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

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

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

    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.

    这导致ffmpeg共享库被编译到libavcodecso。(如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. Build ffmpeg : Copy the following text to a text editor and save it as build_android.sh in ffmpeg_3.1.1 folder.

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

        #!/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.

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

  6. Make ffmpeg Libraries available for Your Projects
  7. 使ffmpeg库可用于您的项目

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.

上面的步骤经过了充分的测试,我在我的机器上执行了它们,构建成功了。为了编写这个答案,我引用了本文中关于如何使用NDK r9构建ffmpeg的内容,但是由于它是旧版本的,所以我自己做了一些修改。

Open for asking any doubts.

敞开心扉,提出任何疑问。

#2


13  

I suggest you these following URLs that was helpful for me :

我建议你以下的网址,对我有帮助:

http://androidwarzone.blogspot.in/2011/12/ffmpeg4android.html

http://androidwarzone.blogspot.in/2011/12/ffmpeg4android.html

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

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

https://androiddeveloperhelp.wordpress.com/2015/12/19/video-editing-android-example/

https://androiddeveloperhelp.wordpress.com/2015/12/19/video-editing-android-example/

For knowledge:

对知识:

http://www.lai18.com/content/5175900.html

http://www.lai18.com/content/5175900.html

Android studio Source Code:

Android工作室源代码:

https://drive.google.com/file/d/0B9qAjo6wKhk9MEpNNjMxaG5oWXM/view?usp=sharing

https://drive.google.com/file/d/0B9qAjo6wKhk9MEpNNjMxaG5oWXM/view?usp=sharing

It may be help you.

这可能对你有帮助。

#3


4  

Have you seen this link Writingminds's FFmpeg library provided all explanation about it in this link

你见过这个链接Writingminds的FFmpeg库在这个链接中提供了关于它的所有解释吗

Latest Version of that library writingmind is here https://github.com/WritingMinds/ffmpeg-android-java/releasesAndroid:如何在Android studio中配置FFMPEG最新版本?

If you want to use latest version of any library you can do it right from in build.gradle because if any library is not updated it can be seen and can be updated from build.gradle, I always do this for many library for latest available version.

如果您想使用任何库的最新版本,可以在build中直接使用。渐变,因为如果任何库没有更新,就可以看到它,并可以从build中更新它。葛莱蒂,我总是为许多图书馆为最新的可用版本这样做。

For gradle in FFMpeg use this

对于FFMpeg中的gradle使用这个。

compile 'com.writingminds:FFmpegAndroid:0.3.2'

More libraries similar to it is given on this link https://android-arsenal.com/details/1/925

更多类似于它的库在这个链接https://android-arsenal.com/details/1/925上给出

Also i suggest you to read this que, and this que

我建议你们读一下这个和这个

If you want to use Latest version of Original Library go here : FFmpeg [ latest version will be here ]

to add with native code then these blogs may help you

要添加本地代码,这些博客可能会帮助您。

http://ffmpeg-android.blogspot.in/ and

http://ffmpeg-android.blogspot。在/和

http://www.roman10.net/2011/07/17/how-to-build-android-applications-based-on-ffmpeg-by-an-example/

http://www.roman10.net/2011/07/17/how-to-build-android-applications-based-on-ffmpeg-by-an-example/

#4


1  

I've experienced with ffmpeg for android for few weeks.

我在android上体验了几个星期的ffmpeg。

The library called FFmpeg4Android and can be found here at WarZone.

这个名为FFmpeg4Android的图书馆可以在WarZone找到。

I know the title says it from December 6, 2011 but i've tested and worked with it and it all runs smoothly. You haven't mentioned what's your exact need with this library but you could read about the ffmpeg abilities at the official site.

我知道标题上写着从2011年12月6日开始,但是我已经对它进行了测试和工作,它运行得很顺利。您还没有提到您对这个库的确切需求,但是您可以在官方站点上了解ffmpeg的功能。

The FFmpeg4Android has an example project that can be a great reference, and also their support is immediate and clear.

FFmpeg4Android有一个示例项目,可以作为很好的参考,而且它们的支持是直接和明确的。

The commands are running according to your string input, e.g:

命令是根据您的字符串输入运行的,例如:

ffmpeg -y -i /sdcard/videokit/in.mp4 -strict experimental -s 160x120 -r 25 -vcodec mpeg4 -b 150k -ab 48000 -ac 2 -ar 22050 /sdcard/videokit/out.mp4

ffmpeg - y - i / sdcard / videokit /。mp4 -严格的实验-s 160x120 -r 25 -vcodec mpeg4 -b 150k -ab 48000 -ac 2 -ar 22050 /sdcard/videokit/out.mp4

let me know if you need further help, i'll be glad to help.

如果你需要进一步的帮助,请告诉我,我很乐意帮忙。

#1


33  

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.

最新版本的FFMPEG是3.1.1,刚刚在12天前发布。所以我认为没有现成的演示像这个旧的。

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

我们需要自己构建FFMPEG库。我发现一些问题贴在这里可能对你有帮助。(未测试)

How to Build FFmpeg for Android

如何为Android构建FFmpeg

  1. Compiling FFmpeg 2.3 with Android NDK r10
  2. 使用Android NDK r10编译FFmpeg 2.3
  3. How to compile ffmpeg-2.5.3 on windows with android-ndk-r10d
  4. 如何在windows上使用android-ndk-r10d编译ffmpeg-2.5.3
  5. How to compile ffmpeg-2.2.2 on windows with cygwin and android ndk r9c
  6. 如何在使用cygwin和android ndk r9c的windows上编译ffmpeg-2.2.2
  7. How to buid ffmpeg with android-ndk-r10d in windows
  8. 如何在windows中使用android-ndk-r10d

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

您需要通过下载Android NDK和最新版本的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.

还有一个教程:如何为Android构建FFmpeg。这已经很老了,所以您只需要更改这里提到的版本。FFMPEG将是3.1.1和NDK, r12b。


Building FFMPEG with NDK r12b:

使用NDK r12b构建FFMPEG:

  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

    下载Android NDK:最新版本的Android NDK可以在Android NDK网站上下载。在写这个答案的时候,最新的版本是NDK r12。只是解压存档

  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.

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

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

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

    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.

    这导致ffmpeg共享库被编译到libavcodecso。(如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. Build ffmpeg : Copy the following text to a text editor and save it as build_android.sh in ffmpeg_3.1.1 folder.

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

        #!/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.

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

  6. Make ffmpeg Libraries available for Your Projects
  7. 使ffmpeg库可用于您的项目

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.

上面的步骤经过了充分的测试,我在我的机器上执行了它们,构建成功了。为了编写这个答案,我引用了本文中关于如何使用NDK r9构建ffmpeg的内容,但是由于它是旧版本的,所以我自己做了一些修改。

Open for asking any doubts.

敞开心扉,提出任何疑问。

#2


13  

I suggest you these following URLs that was helpful for me :

我建议你以下的网址,对我有帮助:

http://androidwarzone.blogspot.in/2011/12/ffmpeg4android.html

http://androidwarzone.blogspot.in/2011/12/ffmpeg4android.html

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

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

https://androiddeveloperhelp.wordpress.com/2015/12/19/video-editing-android-example/

https://androiddeveloperhelp.wordpress.com/2015/12/19/video-editing-android-example/

For knowledge:

对知识:

http://www.lai18.com/content/5175900.html

http://www.lai18.com/content/5175900.html

Android studio Source Code:

Android工作室源代码:

https://drive.google.com/file/d/0B9qAjo6wKhk9MEpNNjMxaG5oWXM/view?usp=sharing

https://drive.google.com/file/d/0B9qAjo6wKhk9MEpNNjMxaG5oWXM/view?usp=sharing

It may be help you.

这可能对你有帮助。

#3


4  

Have you seen this link Writingminds's FFmpeg library provided all explanation about it in this link

你见过这个链接Writingminds的FFmpeg库在这个链接中提供了关于它的所有解释吗

Latest Version of that library writingmind is here https://github.com/WritingMinds/ffmpeg-android-java/releasesAndroid:如何在Android studio中配置FFMPEG最新版本?

If you want to use latest version of any library you can do it right from in build.gradle because if any library is not updated it can be seen and can be updated from build.gradle, I always do this for many library for latest available version.

如果您想使用任何库的最新版本,可以在build中直接使用。渐变,因为如果任何库没有更新,就可以看到它,并可以从build中更新它。葛莱蒂,我总是为许多图书馆为最新的可用版本这样做。

For gradle in FFMpeg use this

对于FFMpeg中的gradle使用这个。

compile 'com.writingminds:FFmpegAndroid:0.3.2'

More libraries similar to it is given on this link https://android-arsenal.com/details/1/925

更多类似于它的库在这个链接https://android-arsenal.com/details/1/925上给出

Also i suggest you to read this que, and this que

我建议你们读一下这个和这个

If you want to use Latest version of Original Library go here : FFmpeg [ latest version will be here ]

to add with native code then these blogs may help you

要添加本地代码,这些博客可能会帮助您。

http://ffmpeg-android.blogspot.in/ and

http://ffmpeg-android.blogspot。在/和

http://www.roman10.net/2011/07/17/how-to-build-android-applications-based-on-ffmpeg-by-an-example/

http://www.roman10.net/2011/07/17/how-to-build-android-applications-based-on-ffmpeg-by-an-example/

#4


1  

I've experienced with ffmpeg for android for few weeks.

我在android上体验了几个星期的ffmpeg。

The library called FFmpeg4Android and can be found here at WarZone.

这个名为FFmpeg4Android的图书馆可以在WarZone找到。

I know the title says it from December 6, 2011 but i've tested and worked with it and it all runs smoothly. You haven't mentioned what's your exact need with this library but you could read about the ffmpeg abilities at the official site.

我知道标题上写着从2011年12月6日开始,但是我已经对它进行了测试和工作,它运行得很顺利。您还没有提到您对这个库的确切需求,但是您可以在官方站点上了解ffmpeg的功能。

The FFmpeg4Android has an example project that can be a great reference, and also their support is immediate and clear.

FFmpeg4Android有一个示例项目,可以作为很好的参考,而且它们的支持是直接和明确的。

The commands are running according to your string input, e.g:

命令是根据您的字符串输入运行的,例如:

ffmpeg -y -i /sdcard/videokit/in.mp4 -strict experimental -s 160x120 -r 25 -vcodec mpeg4 -b 150k -ab 48000 -ac 2 -ar 22050 /sdcard/videokit/out.mp4

ffmpeg - y - i / sdcard / videokit /。mp4 -严格的实验-s 160x120 -r 25 -vcodec mpeg4 -b 150k -ab 48000 -ac 2 -ar 22050 /sdcard/videokit/out.mp4

let me know if you need further help, i'll be glad to help.

如果你需要进一步的帮助,请告诉我,我很乐意帮忙。