FFmpeg的:java.lang.UnsatisfiedLinkError中同时呼吁运行的类 [英] FFmpeg: java.lang.UnsatisfiedLinkError while calling Runnable class

查看:167
本文介绍了FFmpeg的:java.lang.UnsatisfiedLinkError中同时呼吁运行的类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个图片文件和音频文件,并创建一个视频。
我知道这是可能的。

I need to take a picture file and an audio file and create a video. I know that it's possible to do with the help of

Runtime.getRuntime().exec("ffmpeg -i image.jpeg -i audio.mp3 out.avi") 

但只为根设备,所以我试图从ffmpeg.c创建主JNI包装(),并从我的活动调用它喜欢这里:的 http://demo860.blogspot.com/2010/07/android-ffmpeg-dynamic-module-jni.html

1,本code为ffmpeg.c:

1.This code is in ffmpeg.c :

int m_argc = 0;
char *m_pargv [30];

int dynamic_ffpmeg_main (int argc, char **argv);
jint JNICALL Java_com_ccmedia_codec_ffmpeg_mod_1run ( JNIEnv *, jclass, jstring,     jstring );

jint JNICALL Java_com_ccmedia_codec_ffmpeg_mod_1run ( JNIEnv *env, jclass class, jstring pj1, jstring pj2)
{
    // as in http://demo860.blogspot.com/2010/07/android-ffmpeg-dynamic-module-jni.html
}

int dynamic_ffpmeg_main(int argc, char **argv)
{
// as in http://demo860.blogspot.com/2010/07/android-ffmpeg-dynamic-module-jni.html
}

int main(int argc, char **argv)
{
    dynamic_ffpmeg_main ( argc, argv );
    return 0;
}

2,本code是在我的.java:

2.This code is in my .java:

public class FFmpegCreator implements Runnable {

    static boolean m_bret = false;
static String m_szconfig = " -i /sdcard/file.mpg -vcodec mpeg4 aaa.mpg";

//public native String unimplementedStringFromJNI();

static {
    try {

        System.out.println("[AdDBCache] Module load try ffmpeg : "
                + System.getProperty("java.library.path"));

        // System.load("/sdcard/arm_and/bin/libffmpeg.so");

        System.loadLibrary("ffmpeg");

        System.out.println("[AdDBCache] Module load success");

    }

    catch (Exception e) {

        System.out.println("[AdDBCache] Module load err : "
                + System.getProperty("java.library.path"));

    }

}

private static synchronized final native int Java_com_ccmedia_codec_ffmpeg_mod_1run(String name, String sztoken);

public void set_config(String sz_config) {

    m_szconfig = sz_config;

}

public void run_core(String sz_file, String sz_token) {

    int n_stat;
    m_bret = false;
    n_stat = Java_com_ccmedia_codec_ffmpeg_mod_1run(m_szconfig, sz_token);
    m_bret = true;

}

public void run() {

    run_core("", "");

}
}

3.And这在我的活动:

3.And this in my Activity:

FFmpegCreator f = new FFmpegCreator ();
new Thread(f).start();

但我有

E/AndroidRuntime(25682): java.lang.UnsatisfiedLinkError: Java_com_ccmedia_codec_ffmpeg_mod_1run .

我不明白为什么... FFmpeg的构建成功...
谁能帮帮我,好吗?我真的会AP preciate如果你能帮助我。谢谢你。

And I can't understand why... FFmpeg build was successful... Could anyone help me, please? I'll really appreciate if you could help me. Thank you.

推荐答案

问题是 Java_com_ccmedia_ codec_ffmpeg_mod_1run 在Java端的本地方法的命名。你应该给它一个正常的方法名,没有所有的Java_package的...部分。然后,以配合这需要使用的包和类的方法属于C函数。最万无一失的方法,这样做是为了先更新Java方面:

The problem is the naming of the native method Java_com_ccmedia_codec_ffmpeg_mod_1run on the Java side. You should just give it a normal method name, without all of the Java_package... parts. Then to match this to a C function you need to use the package and class that the method belongs. The most fool-proof way to do this is to update the Java side first:

public class FFmpegCreator implements Runnable {
    // ...

    private static synchronized final native int mod_1run(String name, String sztoken);

    //...
}

然后运行 JAVAH上类:

$ javah -o FFmpegCreator.h -classpath bin/classes com.yourpackage.FFmpegCreator

(更换斌/班与您的.class文件进行编译,然后目录 com.yourpackage 与该 FFmpegCreator 的包内)。如果你看看 FFmpegCreator.h 它生成,将包括你的本地方法正确的签名。

(replace bin/classes with the directory where your .class files are compiled, and com.yourpackage with the package that FFmpegCreator is within). If you look at the FFmpegCreator.h it generates it will include the correct signature for your native method.

这篇关于FFmpeg的:java.lang.UnsatisfiedLinkError中同时呼吁运行的类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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