# From Eclipse create a new Android project.
1. Create new "Android Application Project"
2. Fill Application Name with "Test WebM JNI". Project Name will be "TestWebMJNI". Package Name will be "com.example.testwebmjni".
3. [optional] You can change the Minimum required SDK to what your application needs.
4. Click Next button on the Configure Project screen.
5. Click Next on the Icon screen.
6. Click Next on the Create Activity screen.
7. Click Finish on the Blank Activity screen.
# Add the JNI code.
8. Create <project>/jni folder.
# Get JNI bindings
9. git clone http://git.chromium.org/webm/bindings.git
# Get libvpx
10. git clone http://git.chromium.org/webm/libvpx.git
11. cd bindings/JNI
# Get libwebm
12. git clone http://git.chromium.org/webm/libwebm.git
# Get libogg
13. Download ogg code from http://downloads.xiph.org/releases/ogg/libogg-1.3.0.tar.gz
14. extract to bindings/JNI
# We need to run configure to generate config_types.h.
15. cd libogg-1.3.0 && ./configure && cd ..
# Get libvorbis
16. Download vorbis code from http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.3.tar.gz
17. extract to bindings/JNI
# Get libyuv
18. svn checkout http://libyuv.googlecode.com/svn/trunk/ libyuv-read-only
19. cd ../..
20. Create <project>/jni/Application.mk with the data below:
APP_ABI := armeabi-v7a
APP_OPTIM := release
NDK_TOOLCHAIN_VERSION := 4.8
APP_STL := gnustl_static
APP_CPPFLAGS := -frtti
21. Create <project>/jni/Android.mk with the data below:
WORKING_DIR := $(call my-dir)
BINDINGS_DIR := $(WORKING_DIR)/bindings/JNI
include $(BINDINGS_DIR)/Android.mk
# Configure libvpx for Android
22. ./libvpx/configure --target=armv7-android-gcc --disable-examples --sdk-path=<full path to>/<NDK>/android-ndk-r9c/
# Build the JNI code.
23. ndk-build
# Copy the java code.
24. cp -R bindings/JNI/com/google ../src/com/
# Adding code to test the bindings.
25. Change MainActivity.java onCreate to:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
int[] major = new int[2];
int[] minor = new int[2];
int[] build = new int[2];
int[] revision = new int[2];
MkvMuxer.getVersion(major, minor, build, revision);
String outStr = "libwebm:" + Integer.toString(major[0]) + "." +
Integer.toString(minor[0]) + "." + Integer.toString(build[0]) + "." +
Integer.toString(revision[0]);
TextView tv = new TextView(this);
tv.setText(outStr);
setContentView(tv);
}
26. Run the app. You should see libwebm version output.
# Test encoding audio and video
27. Copy raw I420 y4m file and a Raw PCM Wav file to ExternalStorage on the device.
28. Add "<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />" to AndroidManifest.xml.
# Copy example code.
29. cp bindings/JNI/examples/EncodeY4mWavExample.java ../src/com/example/testwebmjni/
30. Add "package com.example.testwebmjni;" to the top of EncodeY4mWavExample.java.
31. Change MainActivity.java onCreate to:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String storageDir = Environment.getExternalStorageDirectory().getAbsolutePath();
String inputVideo = storageDir + "/<Y4M file>";
String inputAudio = storageDir + "/<WAV file>";
String outputWebM = storageDir + "/testjni.webm";
StringBuilder error = new StringBuilder();
String outStr = "\nencodeY4mWavExample(): ";
if (EncodeY4mWavExample.encodeY4mWavExample(inputVideo, inputAudio, outputWebM, 200, error)) {
outStr += " Success!";
} else {
outStr += " Error: " + error.toString();
}
TextView tv = new TextView(this);
tv.setText(outStr);
setContentView(tv);
}
32. Run the app. You should see output of "Success!".
33. Playback "testjni.webm" on the device.
原文链接:
http://git.chromium.org/gitweb/?p=webm/bindings.git;a=blob_plain;f=JNI/README.Android
build vp8 on android
最新推荐文章于 2022-10-03 09:36:57 发布
本文详细介绍如何在Android项目中集成JNI代码以实现多媒体处理功能,包括搭建开发环境、配置NDK、添加并编译JNI代码、测试音视频编解码等步骤。
817

被折叠的 条评论
为什么被折叠?



