forked from xufuji456/FFmpegAndroid
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathffprobe_cmd.cpp
More file actions
42 lines (34 loc) · 930 Bytes
/
ffprobe_cmd.cpp
File metadata and controls
42 lines (34 loc) · 930 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
//
// Created by frank on 2020-01-06.
//
#include <jni.h>
#include <string.h>
#include <malloc.h>
#ifdef __cplusplus
extern "C" {
#endif
#include "ffmpeg_jni_define.h"
#include "ffmpeg/ffprobe.h"
#ifdef __cplusplus
}
#endif
FFPROBE_FUNC(jstring, handleProbe, jobjectArray commands) {
int argc = env->GetArrayLength(commands);
char **argv = (char **) malloc(argc * sizeof(char *));
int i;
for (i = 0; i < argc; i++) {
jstring jstr = (jstring) env->GetObjectArrayElement( commands, i);
char *temp = (char *) env->GetStringUTFChars(jstr, 0);
argv[i] = static_cast<char *>(malloc(1024));
strcpy(argv[i], temp);
env->ReleaseStringUTFChars(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(result);
}