在Android下使用FFMpeg

时间:2014-06-12 14:24:00

标签: android android-ndk ffmpeg

我试图在我的Android NDK项目中播放视频。我使用libffmpeg.so来做到这一点。这是我的代码:

JNIEXPORT jint JNICALL Java_com_example_ndksetup_VideoTrimmer_trim(JNIEnv *env,
        jclass someclass, jstring inputFile, jstring outFile, jint startTime,
        jint length) {
    __android_log_print(ANDROID_LOG_DEBUG, DEBUG_TAG, "NDK: %s", "Starting to cut");

    int numberOfArgs = 6;
    char** arguments = calloc(numberOfArgs, sizeof(char*));
    char start[5], duration[5];
    const char *in, *out;
    itoa(startTime, start);
    itoa(length, duration);

    in = (*env)->GetStringUTFChars(env, inputFile, 0);
    out = (*env)->GetStringUTFChars(env, outFile, 0);

    arguments[0] = "ffmpeg";
    arguments[1] = "-i";
    arguments[2] = in;
    arguments[3] = "-vf";
    arguments[4] = "\"crop=100:100:100:100\"";
    arguments[5] = out;

    int i;
    for (i = 0; i < numberOfArgs; i++) {
        log_message(arguments[i]);
    }
    __android_log_print(ANDROID_LOG_DEBUG, DEBUG_TAG, "NDK: %s", "Printed all");

    ffmpeg_main(numberOfArgs, arguments);
    __android_log_print(ANDROID_LOG_DEBUG, DEBUG_TAG, "NDK: %s", "Finished cutting");
    free(arguments);
    (*env)->ReleaseStringUTFChars(env, inputFile, in);
    (*env)->ReleaseStringUTFChars(env, outFile, out);
    return 0;
}

但我还是得到了

06-12 15:45:37.202: E/TakePics(3149): Unrecognized option 'vf'

你能告诉我我做错了什么吗?

0 个答案:

没有答案