Skip to content

Commit 6c46f6b

Browse files
committed
初次提交源码,别来无恙!!!
1 parent 6d0f0d4 commit 6c46f6b

37 files changed

+1001
-0
lines changed

.gitignore

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/*/build/
2+
build/
3+
buildCacheDir/
4+
5+
# Crashlytics configuations
6+
com_crashlytics_export_strings.xml
7+
8+
# Local configuration file (sdk path, etc)
9+
local.properties
10+
11+
# Gradle generated files
12+
.gradle/
13+
14+
# built application files
15+
# *.apk
16+
# *.ap_
17+
18+
# Signing files
19+
.signing/
20+
21+
# files for the dex VM
22+
*.dex
23+
24+
# Java class files
25+
*.class
26+
27+
# generated files
28+
bin/
29+
gen/
30+
obj/
31+
32+
# Local configuration file (sdk path, etc)
33+
local.properties
34+
com_crashlytics_export_strings.xml
35+
crashlytics.properties
36+
crashlytics-build.properties
37+
38+
# Eclipse project files
39+
.classpath
40+
.project
41+
.settings/
42+
43+
# Proguard folder generated by Eclipse
44+
proguard/
45+
46+
# Intellij project files
47+
*.iml
48+
*.ipr
49+
*.iws
50+
51+
.idea/
52+
Thumbs.db
53+
.DS_Store
54+
.checkstyle
55+
.DS_Store?
56+
._*
57+
.Spotlight-V100
58+
.Trashes
59+
ehthumbs.db
60+
61+
fabric.properties
62+
63+
.externalNativeBuild

app/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

app/build.gradle

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
apply plugin: 'com.android.application'
2+
3+
android {
4+
compileSdkVersion 26
5+
defaultConfig {
6+
applicationId "com.superman.fastffmpegandroid"
7+
minSdkVersion 15
8+
targetSdkVersion 26
9+
versionCode 1
10+
versionName "1.0"
11+
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
12+
}
13+
buildTypes {
14+
release {
15+
minifyEnabled false
16+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17+
}
18+
}
19+
20+
sourceSets {
21+
main {
22+
jniLibs.srcDirs = ['libs']
23+
}
24+
}
25+
26+
}
27+
28+
dependencies {
29+
implementation fileTree(dir: 'libs', include: ['*.jar'])
30+
implementation 'com.android.support:appcompat-v7:27.1.1'
31+
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
32+
testImplementation 'junit:junit:4.12'
33+
androidTestImplementation 'com.android.support.test:runner:1.0.2'
34+
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
35+
36+
implementation 'com.github.tbruyelle:rxpermissions:0.10.2'
37+
38+
}
11.6 MB
Binary file not shown.
631 KB
Binary file not shown.

app/proguard-rules.pro

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.superman.fastffmpegandroid;
2+
3+
import android.content.Context;
4+
import android.support.test.InstrumentationRegistry;
5+
import android.support.test.runner.AndroidJUnit4;
6+
7+
import org.junit.Test;
8+
import org.junit.runner.RunWith;
9+
10+
import static org.junit.Assert.*;
11+
12+
/**
13+
* Instrumented test, which will execute on an Android device.
14+
*
15+
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
16+
*/
17+
@RunWith(AndroidJUnit4.class)
18+
public class ExampleInstrumentedTest {
19+
@Test
20+
public void useAppContext() {
21+
// Context of the app under test.
22+
Context appContext = InstrumentationRegistry.getTargetContext();
23+
24+
assertEquals("com.superman.fastffmpegandroid", appContext.getPackageName());
25+
}
26+
}

app/src/main/AndroidManifest.xml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.superman.fastffmpegandroid">
4+
5+
<!--网络连接-->
6+
<uses-permission android:name="android.permission.INTERNET" />
7+
<!--sd卡读写 6.0以上系统可能还需要动态申请sd卡读写权限-->
8+
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
9+
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
10+
11+
<application
12+
android:allowBackup="true"
13+
android:icon="@mipmap/ic_launcher"
14+
android:label="@string/app_name"
15+
android:roundIcon="@mipmap/ic_launcher_round"
16+
android:supportsRtl="true"
17+
android:theme="@style/AppTheme">
18+
<activity android:name=".MainActivity">
19+
<intent-filter>
20+
<action android:name="android.intent.action.MAIN" />
21+
22+
<category android:name="android.intent.category.LAUNCHER" />
23+
</intent-filter>
24+
</activity>
25+
</application>
26+
27+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
package com.superman.fastffmpegandroid;
2+
3+
import android.Manifest;
4+
import android.app.ProgressDialog;
5+
import android.content.DialogInterface;
6+
import android.os.Environment;
7+
import android.support.v7.app.AppCompatActivity;
8+
import android.os.Bundle;
9+
import android.view.View;
10+
import android.widget.EditText;
11+
import android.widget.TextView;
12+
import android.widget.Toast;
13+
14+
import com.superman.ffmpeg.FFmpegInvoke;
15+
import com.tbruyelle.rxpermissions2.RxPermissions;
16+
17+
import java.util.concurrent.ExecutorService;
18+
import java.util.concurrent.Executors;
19+
20+
import io.reactivex.functions.Consumer;
21+
22+
public class MainActivity extends AppCompatActivity {
23+
24+
private static final String TAG = MainActivity.class.getSimpleName();
25+
26+
private ExecutorService es = Executors.newSingleThreadExecutor();
27+
String path = Environment.getExternalStorageDirectory().getPath();
28+
29+
//需要申请的权限,必须先在AndroidManifest.xml有声明,才可以动态获取权限
30+
private static String[] PERMISSIONS_STORAGE = {
31+
Manifest.permission.READ_EXTERNAL_STORAGE,
32+
Manifest.permission.WRITE_EXTERNAL_STORAGE};
33+
34+
private TextView tv;
35+
36+
private EditText editText;
37+
38+
private ProgressDialog mProgressDialog;
39+
40+
//权限
41+
private RxPermissions rxPermissions = null;
42+
43+
@Override
44+
protected void onCreate(Bundle savedInstanceState) {
45+
super.onCreate(savedInstanceState);
46+
setContentView(R.layout.activity_main);
47+
48+
rxPermissions = new RxPermissions(this);
49+
50+
tv = (TextView)findViewById(R.id.sample_text);
51+
// tv.setText(path);
52+
53+
editText = (EditText)findViewById(R.id.editText);
54+
editText.setText("ffmpeg -y -i /storage/emulated/0/1/qq.mp4 -vf boxblur=5:1 -preset superfast /storage/emulated/0/1/result.mp4");
55+
56+
FFmpegInvoke.getInstance().setDebug(true);
57+
58+
tv.setOnClickListener(new View.OnClickListener() {
59+
@Override
60+
public void onClick(View v) {
61+
62+
rxPermissions.request(PERMISSIONS_STORAGE).subscribe(new Consumer<Boolean>() {
63+
@Override
64+
public void accept(Boolean aBoolean) throws Exception {
65+
if (aBoolean) {// 用户同意了权限
66+
runFFmpeg ();
67+
68+
} else {//用户拒绝了权限
69+
Toast.makeText(MainActivity.this,"您拒绝了权限,请往设置里开启权限",Toast.LENGTH_LONG).show();
70+
}
71+
}
72+
});
73+
74+
}
75+
});
76+
77+
}
78+
79+
private void runFFmpeg () {
80+
openProgressDialog();
81+
final String text = editText.getText().toString();
82+
String[] commands = text.split(" ");
83+
84+
FFmpegInvoke.getInstance().runCommand(commands, new FFmpegInvoke.IFFmpegListener() {
85+
@Override
86+
public void onFinish() {
87+
runOnUiThread(new Runnable() {
88+
@Override
89+
public void run() {
90+
if (mProgressDialog != null)
91+
mProgressDialog.cancel();
92+
tv.setText("处理成功");
93+
Toast.makeText(MainActivity.this, "处理成功", Toast.LENGTH_LONG).show();
94+
}
95+
});
96+
}
97+
98+
@Override
99+
public void onProgress(final int progress) {
100+
runOnUiThread(new Runnable() {
101+
@Override
102+
public void run() {
103+
if (mProgressDialog != null)
104+
mProgressDialog.setProgress(progress);
105+
}
106+
});
107+
}
108+
109+
@Override
110+
public void onCancel() {
111+
runOnUiThread(new Runnable() {
112+
@Override
113+
public void run() {
114+
if (mProgressDialog != null)
115+
mProgressDialog.cancel();
116+
tv.setText("onCancel");
117+
Toast.makeText(MainActivity.this, "已取消", Toast.LENGTH_LONG).show();
118+
}
119+
});
120+
}
121+
122+
@Override
123+
public void onError(final String message) {
124+
runOnUiThread(new Runnable() {
125+
@Override
126+
public void run() {
127+
if (mProgressDialog != null)
128+
mProgressDialog.cancel();
129+
tv.setText("onError=" + message);
130+
Toast.makeText(MainActivity.this, "onError=" + message, Toast.LENGTH_LONG).show();
131+
}
132+
});
133+
}
134+
});
135+
}
136+
137+
@SuppressWarnings("deprecation")
138+
public void openProgressDialog() {
139+
mProgressDialog = new ProgressDialog(this);
140+
final int totalProgressTime = 100;
141+
mProgressDialog.setMessage("正在转换视频,请勿取消");
142+
mProgressDialog.setButton("取消", new DialogInterface.OnClickListener() {
143+
144+
@Override
145+
public void onClick(DialogInterface dialog, int which) {
146+
// TODO Auto-generated method stub
147+
FFmpegInvoke.getInstance().exit();
148+
149+
}
150+
});
151+
mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
152+
mProgressDialog.setCancelable(false);
153+
mProgressDialog.setMax(totalProgressTime);
154+
mProgressDialog.show();
155+
156+
}
157+
158+
}

0 commit comments

Comments
 (0)