Load ffmpeg other info

master
徐灿辉 5 years ago
parent a08f24220f
commit 1812b5525e
  1. 25
      app/src/main/java/com/github/xch168/ffmpeg/invoker/demo/MainActivity.java
  2. 46
      app/src/main/res/layout/activity_main.xml
  3. 64
      library/src/main/cpp/ffmpeg-invoker.c
  4. 9
      library/src/main/cpp/ffmpeg-invoker.h
  5. 3
      library/src/main/java/com/github/xch168/ffmpeg/invoker/FFmpegInvoker.java

@ -3,6 +3,7 @@ package com.github.xch168.ffmpeg.invoker.demo;
import android.os.Build;
import android.os.Bundle;
import android.text.method.ScrollingMovementMethod;
import android.view.View;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
@ -11,6 +12,7 @@ import com.github.xch168.ffmpeg.invoker.FFmpegInvoker;
public class MainActivity extends AppCompatActivity {
private TextView mConfigView;
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -20,9 +22,9 @@ 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());
mConfigView = findViewById(R.id.tv_config_info);
mConfigView.setMovementMethod(ScrollingMovementMethod.getInstance());
}
private String getCpuAbi() {
@ -33,6 +35,22 @@ public class MainActivity extends AppCompatActivity {
}
}
public void getFFmpegConfigInfo(View view) {
mConfigView.setText(getConfigInfo());
}
public void getFFmpegCodecInfo(View view) {
mConfigView.setText(FFmpegInvoker.getAVCodecInfo());
}
public void getFFmpegFormatInfo(View view) {
mConfigView.setText(FFmpegInvoker.getAVFormatInfo());
}
public void getFFmpegFilterInfo(View view) {
mConfigView.setText(FFmpegInvoker.getAVFilterInfo());
}
private String getConfigInfo() {
String configInfo = FFmpegInvoker.getConfigInfo();
String[] configItems = configInfo.split(" ");
@ -42,5 +60,4 @@ public class MainActivity extends AppCompatActivity {
}
return configInfoBuilder.toString();
}
}

@ -15,12 +15,56 @@
app:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="20dp"/>
<Button
android:id="@+id/btn_config"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@+id/tv_cpu_abi"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginTop="20dp"
android:textAllCaps="false"
android:text="Config"
android:onClick="getFFmpegConfigInfo"/>
<Button
android:id="@+id/btn_codec"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="@+id/btn_config"
app:layout_constraintLeft_toRightOf="@+id/btn_config"
android:layout_marginLeft="10dp"
android:textAllCaps="false"
android:text="Codec"
android:onClick="getFFmpegCodecInfo"/>
<Button
android:id="@+id/btn_format"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="@+id/btn_config"
app:layout_constraintLeft_toRightOf="@+id/btn_codec"
android:layout_marginLeft="10dp"
android:textAllCaps="false"
android:text="Format"
android:onClick="getFFmpegFormatInfo"/>
<Button
android:id="@+id/btn_filter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="@+id/btn_config"
app:layout_constraintLeft_toRightOf="@+id/btn_format"
android:layout_marginLeft="10dp"
android:textAllCaps="false"
android:text="Filter"
android:onClick="getFFmpegFilterInfo"/>
<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_constraintTop_toBottomOf="@+id/btn_config"
app:layout_constraintBottom_toBottomOf="parent"
android:scrollbars="vertical"
android:layout_marginTop="20dp"/>

@ -107,3 +107,67 @@ Java_com_github_xch168_ffmpeg_invoker_FFmpegInvoker_getConfigInfo(JNIEnv *env, j
sprintf(info, "%s\n", avcodec_configuration());
return (*env)->NewStringUTF(env, info);
}
JNIEXPORT jstring JNICALL
Java_com_github_xch168_ffmpeg_invoker_FFmpegInvoker_getAVCodecInfo(JNIEnv *env, jclass clazz) {
char info[40000] = { 0 };
AVCodec *c_temp = av_codec_next(NULL);
while (c_temp != NULL) {
if (c_temp->decode != NULL) {
sprintf(info, "%s[Dec]", info);
}
else {
sprintf(info, "%s[Enc]", info);
}
switch (c_temp->type) {
case AVMEDIA_TYPE_VIDEO:
sprintf(info, "%s[Video]", info);
break;
case AVMEDIA_TYPE_AUDIO:
sprintf(info, "%s[Audio]", info);
break;
default:
sprintf(info, "%s[Other]", info);
break;
}
sprintf(info, "%s[%10s]\n", info, c_temp->name);
c_temp=c_temp->next;
}
return (*env)->NewStringUTF(env, info);
}
JNIEXPORT jstring JNICALL
Java_com_github_xch168_ffmpeg_invoker_FFmpegInvoker_getAVFormatInfo(JNIEnv *env, jclass clazz) {
char info[40000] = { 0 };
AVInputFormat *if_temp = av_iformat_next(NULL);
AVOutputFormat *of_temp = av_oformat_next(NULL);
//Input
while (if_temp != NULL) {
sprintf(info, "%s[In ][%10s]\n", info, if_temp->name);
if_temp = if_temp->next;
}
//Output
while (of_temp != NULL) {
sprintf(info, "%s[Out][%10s]\n", info, of_temp->name);
of_temp = of_temp->next;
}
return (*env)->NewStringUTF(env, info);
}
JNIEXPORT jstring JNICALL
Java_com_github_xch168_ffmpeg_invoker_FFmpegInvoker_getAVFilterInfo(JNIEnv *env, jclass clazz) {
char info[40000] = { 0 };
AVFilter *f_temp = (AVFilter *)avfilter_next(NULL);
while (f_temp != NULL) {
sprintf(info, "%s[%10s]\n", info, f_temp->name);
f_temp = f_temp->next;
}
return (*env)->NewStringUTF(env, info);
}

@ -15,6 +15,15 @@ Java_com_github_xch168_ffmpeg_invoker_FFmpegInvoker_exit(JNIEnv *, jclass);
JNIEXPORT jstring JNICALL
Java_com_github_xch168_ffmpeg_invoker_FFmpegInvoker_getConfigInfo(JNIEnv *, jclass);
JNIEXPORT jstring JNICALL
Java_com_github_xch168_ffmpeg_invoker_FFmpegInvoker_getAVCodecInfo(JNIEnv *env, jclass clazz);
JNIEXPORT jstring JNICALL
Java_com_github_xch168_ffmpeg_invoker_FFmpegInvoker_getAVFormatInfo(JNIEnv *, jclass);
JNIEXPORT jstring JNICALL
Java_com_github_xch168_ffmpeg_invoker_FFmpegInvoker_getAVFilterInfo(JNIEnv *, jclass);
#ifdef __cplusplus
}
#endif

@ -19,6 +19,9 @@ public class FFmpegInvoker {
public static native void exit();
public static native String getConfigInfo();
public static native String getAVCodecInfo();
public static native String getAVFormatInfo();
public static native String getAVFilterInfo();
public static void exec(String[] cmds, long duration, Callback listener) {
sCallback = listener;

Loading…
Cancel
Save