在Android的FFmpeg的JNI? [英] FFMpeg jni in Android?

查看:171
本文介绍了在Android的FFmpeg的JNI?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经建立FFMPEG可执行文件和库由Bambuser规定(http://bambuser.com/opensource)。所以,我成功地建立起了Android可执行文件和libraties。我怎么能在我的Eclipse项目链接这些库和从Java调用FFmpeg的功能呢?开源$ C ​​$ C包括C头文件的地方。

I have built FFMPEG executables and libraries as provided by Bambuser (http://bambuser.com/opensource). So I managed to build the Android executables and libraties. How can I link these libs in my Eclipse project and invoke the FFmpeg functions from Java? The open source code includes the C header-files.

我是新来的原生代码为Android,而我无法找到一个简单的答案了这一点。在基本的:有一群兼容的Andr​​oid库和一些C头文件做什么我必须做的重用那些libaries从Java功能(+ Android SDK中)

I am new to native coding for Android, and I could not find an easy answer for this. In basic : having a bunch of Android compatible libraries and some C header files what do I have to do to reuse those libaries' functionality from java (+Android SDK)?

任何帮助将是AP preciated。

Any help would be appreciated.

亲切的问候,

WhyHow

推荐答案

您必须编写使用JNI约定揭露FFmpeg的功能到Java code一些C胶水code。在这里,在C从Android NDK样本实施的JNI方法的一个例子:

You have to write some C glue code using the JNI conventions to expose the FFmpeg functionalities to Java code. Here's an example of a JNI method implemented in C from the Android NDK samples:

jstring
Java_com_example_hellojni_HelloJni_stringFromJNI( JNIEnv* env,
                                                  jobject thiz )
{
    return (*env)->NewStringUTF(env, "Hello from JNI !");
}

您还需要一些Java code加载库,并声明本机方法。

You also need some Java code to load the library and declare the native method.

public class HelloJni
{
    public native String  stringFromJNI();

     static {
        System.loadLibrary("hello-jni");
    }
}

我发现这个项目在SourceForge上其业已实施了一些JNI接口ffmpeg的将其与Java媒体框架的集成。您可能会发现它有用。

I found this project on sourceforge which already has implemented some JNI interface to ffmpeg to integrate it with the Java Media Framework. You may find it useful.

有叫南国防军(Java本地接入)另一个Java FFI技术,它允许你声明的本地函数原型在Java和直接调用它们。使用它,可能需要较少的样板code。请参见这个项目一个Android的实施。 (我从来没有用它自己)

There's another Java FFI technology called JNA (Java Native Access) that allows you to declare native function prototypes in Java and call them directly. Using it may require less boilerplate code. See this project for an Android implementation. (I have never used it myself)

这篇关于在Android的FFmpeg的JNI?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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