ffprobe jni interface

ffprobe jni interface
pull/107/head
xufulong 5 years ago
parent 3836b5c194
commit 58a8c5c8af
  1. 1
      app/CMakeLists.txt
  2. 33
      app/src/main/cpp/ffprobe_cmd.c

@ -33,6 +33,7 @@ add_library( # Sets the name of the library.
src/main/cpp/video_filter.c src/main/cpp/video_filter.c
src/main/cpp/audio_lame.c src/main/cpp/audio_lame.c
src/main/cpp/fast_start.c src/main/cpp/fast_start.c
src/main/cpp/ffprobe_cmd.c
) )
add_library( ffmpeg add_library( ffmpeg

@ -0,0 +1,33 @@
//
// Created by frank on 2020-01-06.
//
#include <jni.h>
#include <string.h>
#include <malloc.h>
#include <ffmpeg_jni_define.h>
#include <ffmpeg/ffprobe.h>
FFMPEG_FUNC(jstring , handleProbe, jobjectArray commands) {
int argc = (*env)->GetArrayLength(env, commands);
char **argv = (char**)malloc(argc * sizeof(char*));
int i;
for (i = 0; i < argc; i++) {
jstring jstr = (jstring) (*env)->GetObjectArrayElement(env, commands, i);
char* temp = (char*) (*env)->GetStringUTFChars(env, jstr, 0);
argv[i] = malloc(1024);
strcpy(argv[i], temp);
(*env)->ReleaseStringUTFChars(env, jstr, temp);
}
//execute ffprobe command
char* result = ffprobe_run(argc, argv);
//release memory
for (i = 0; i < argc; i++) {
free(argv[i]);
}
free(argv);
return (*env)->NewStringUTF(env, result);
}
Loading…
Cancel
Save