Load ffmpeg config info

master
徐灿辉 5 years ago
parent 60ec022e7f
commit a08f24220f
  1. 17
      app/src/main/java/com/github/xch168/ffmpeg/invoker/demo/MainActivity.java
  2. 14
      app/src/main/res/layout/activity_main.xml
  3. 7
      library/src/main/cpp/ffmpeg-invoker.c
  4. 3
      library/src/main/cpp/ffmpeg-invoker.h
  5. 13
      library/src/main/java/com/github/xch168/ffmpeg/invoker/FFmpegInvoker.java

@ -2,10 +2,13 @@ package com.github.xch168.ffmpeg.invoker.demo;
import android.os.Build;
import android.os.Bundle;
import android.text.method.ScrollingMovementMethod;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
import com.github.xch168.ffmpeg.invoker.FFmpegInvoker;
public class MainActivity extends AppCompatActivity {
@ -16,6 +19,10 @@ public class MainActivity extends AppCompatActivity {
TextView tv = findViewById(R.id.tv_cpu_abi);
tv.setText("CPU_ABI: " + getCpuAbi());
TextView configView = findViewById(R.id.tv_config_info);
configView.setMovementMethod(ScrollingMovementMethod.getInstance());
configView.setText(getConfigInfo());
}
private String getCpuAbi() {
@ -26,4 +33,14 @@ public class MainActivity extends AppCompatActivity {
}
}
private String getConfigInfo() {
String configInfo = FFmpegInvoker.getConfigInfo();
String[] configItems = configInfo.split(" ");
StringBuilder configInfoBuilder = new StringBuilder();
for (String config : configItems) {
configInfoBuilder.append(config).append('\n');
}
return configInfoBuilder.toString();
}
}

@ -10,9 +10,19 @@
android:id="@+id/tv_cpu_abi"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="20dp"/>
<TextView
android:id="@+id/tv_config_info"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tv_cpu_abi"
app:layout_constraintBottom_toBottomOf="parent"
android:scrollbars="vertical"
android:layout_marginTop="20dp"/>
</androidx.constraintlayout.widget.ConstraintLayout>

@ -100,3 +100,10 @@ Java_com_github_xch168_ffmpeg_invoker_FFmpegInvoker_exit(JNIEnv *env, jclass typ
m_clazz = (*env)->NewGlobalRef(env, type);
ffmpeg_thread_cancel();
}
JNIEXPORT jstring JNICALL
Java_com_github_xch168_ffmpeg_invoker_FFmpegInvoker_getConfigInfo(JNIEnv *env, jclass clazz) {
char info[10000] = {0};
sprintf(info, "%s\n", avcodec_configuration());
return (*env)->NewStringUTF(env, info);
}

@ -12,6 +12,9 @@ Java_com_github_xch168_ffmpeg_invoker_FFmpegInvoker_exec(JNIEnv *, jclass, jint,
JNIEXPORT void JNICALL
Java_com_github_xch168_ffmpeg_invoker_FFmpegInvoker_exit(JNIEnv *, jclass);
JNIEXPORT jstring JNICALL
Java_com_github_xch168_ffmpeg_invoker_FFmpegInvoker_getConfigInfo(JNIEnv *, jclass);
#ifdef __cplusplus
}
#endif

@ -1,9 +1,12 @@
package com.github.xch168.ffmpeg.invoker;
import android.util.Log;
/**
* Created by XuCanHui on 2020/3/14.
*/
public class FFmpegInvoker {
private static final String TAG = "FFmpegInvoker";
static {
System.loadLibrary("ffmpeg-invoker");
@ -15,10 +18,20 @@ public class FFmpegInvoker {
public static native int exec(int argc, String[] argv);
public static native void exit();
public static native String getConfigInfo();
public static void exec(String[] cmds, long duration, Callback listener) {
sCallback = listener;
sDuration = duration;
StringBuilder cmdBuilder = new StringBuilder();
for (String cmd : cmds)
{
cmdBuilder.append(" ").append(cmd);
}
Log.i(TAG, "ffmpeg cmd:" + cmdBuilder.toString());
exec(cmds.length, cmds);
}

Loading…
Cancel
Save