您的位置:首页 > 其它

NDK编译ffmpeg程序

2015-04-21 20:49 218 查看
参考: /article/10519818.html

1. 用Android NDK自带的脚本做一个独立的工具链:

[root@localhost work]# pwd

/root/work

[root@localhost work]# ls

android-ndk-r10d ffmpeg-2.6.2.tar.bz2

[root@localhost work]# tar xjf ffmpeg-2.6.2.tar.bz2

[root@localhost work]# ls android-ndk-r10d/

build ndk-depends ndk-which samples

docs ndk-gdb platforms sources

find-win-host.cmd ndk-gdb-py prebuilt tests

GNUmakefile ndk-gdb.py README.TXT toolchains

ndk-build ndk-gdb-py.cmd RELEASE.TXT

ndk-build.cmd ndk-stack remove-windows-symlink.sh

[root@localhost work]# android-ndk-r10d/build/tools/make-standalone-toolchain.sh --platform=android-8 --toolchain=arm-linux-androideabi-4.9

Copying prebuilt binaries...

Copying sysroot headers and libraries...

Copying c++ runtime headers and libraries...

Creating package file: /tmp/ndk-root/arm-linux-androideabi-4.9.tar.bz2

Cleaning up...

Done.

注: --toolchain=arm-linux-androideabi-4.9 取决于NDK子目录/toolchains下提供了哪些文件夹(工具链)

2. 将工具链bin目录加到PATH环境变量

[root@localhost work]# tar xjf /tmp/ndk-root/arm-linux-androideabi-4.9.tar.bz2

[root@localhost work]# export PATH=$PATH:/root/work/arm-linux-androideabi-4.9/bin/

3. 配置ffmpeg代码

[root@localhost work]# cd ffmpeg-2.6.2

[root@localhost ffmpeg-2.6.2]# mkdir ../temp

[root@localhost ffmpeg-2.6.2]# ./configure --enable-cross-compile --target-os=linux --arch=arm --cross-prefix=arm-linux-androideabi- --disable-doc --disable-debug --prefix=/root/work/temp

这里输出一条警告,貌似不影响:WARNING: arm-linux-androideabi-pkg-config not found, library detection may fail.

4. 编译安装(安装到刚才 --perfix= 指定的目录中去)

[root@localhost ffmpeg-2.6.2]# make; make install;

[root@localhost ffmpeg-2.6.2]# cd ..; ls temp

bin include lib share

[root@localhost ffmpeg-2.6.2]# ls temp/bin

ffmpeg ffprobe ffserver

以上是生成的arm二进制程序

5. 复制到Android上运行,添加可执行权限需要手机 root 过

将生成的ffmpeg,ffprobe复制到手机存储空间;

然后adb shell进Android系统:

$ su

# mount

......

/dev/block/mmcblk1p21 /system ext3 ro,noatime,nodiratime,barrier=1,data=ordered

0 0

......

#mount -o remount /dev/block/mmcblk1p21 /system/

将/system目录重新挂载为可读可写

# cp /sdcard/ffmpeg /system/bin/

# cp /sdcard/ffprobe /system/bin/


然后试下运行效果

# ffmpeg -version

ffmpeg -version

ffmpeg version 2.6.2 Copyright (c) 2000-2015 the FFmpeg developers

built with gcc 4.9 (GCC) 20140827 (prerelease)

configuration: --enable-cross-compile --target-os=linux --arch=arm --cross-prefi

x=arm-linux-androideabi- --disable-doc --disable-debug --prefix=/root/work/temp

libavutil 54. 20.100 / 54. 20.100

libavcodec 56. 26.100 / 56. 26.100

libavformat 56. 25.101 / 56. 25.101

libavdevice 56. 4.100 / 56. 4.100

libavfilter 5. 11.102 / 5. 11.102

libswscale 3. 1.101 / 3. 1.101

libswresample 1. 1.100 / 1. 1.100

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: