forked from xufuji456/FFmpegAndroid
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathffmpeg_cmd.c
More file actions
25 lines (24 loc) · 747 Bytes
/
ffmpeg_cmd.c
File metadata and controls
25 lines (24 loc) · 747 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
#include <jni.h>
#include "ffmpeg/ffmpeg.h"
#include "ffmpeg_jni_define.h"
FFMPEG_FUNC(jint, handle, jobjectArray commands) {
int argc = (*env)->GetArrayLength(env, commands);
char **argv = (char**)malloc(argc * sizeof(char*));
int i;
int result;
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);
}
//执行ffmpeg命令
result = run(argc, argv);
//释放内存
for (i = 0; i < argc; i++) {
free(argv[i]);
}
free(argv);
return result;
}