Skip to content

Commit

Permalink
帧率修复
Browse files Browse the repository at this point in the history
  • Loading branch information
w2016561536 committed Sep 2, 2021
1 parent ae8a142 commit 5e6d9d5
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 9 deletions.
Binary file modified app/release/app-release.apk
Binary file not shown.
25 changes: 19 additions & 6 deletions app/src/main/java/com/example/vcam/HookMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ protected void beforeHookedMethod(MethodHookParam paramd) throws Throwable {
if (toast_content != null) {
Toast.makeText(toast_content, "发现拍照\n宽:" + onemwidth + "\n高:" + onemhight + "\n格式:JPEG", Toast.LENGTH_LONG).show();
}
Bitmap pict = getBMP("/sdcard/DCIM/Camera/bmp/1000.bmp");
Bitmap pict = getBMP("/sdcard/DCIM/Camera/1000.bmp");
ByteArrayOutputStream temp_array = new ByteArrayOutputStream();
pict.compress(Bitmap.CompressFormat.JPEG, 100, temp_array);
byte[] jpeg_data = temp_array.toByteArray();
Expand Down Expand Up @@ -514,7 +514,7 @@ protected void beforeHookedMethod(MethodHookParam paramd) throws Throwable {
if (toast_content != null) {
Toast.makeText(toast_content, "发现拍照\n宽:" + onemwidth + "\n高:" + onemhight + "\n格式:YUV_420_888", Toast.LENGTH_LONG).show();
}
input = getYUVByBitmap(getBMP("/sdcard/DCIM/Camera/bmp/1000.bmp"));
input = getYUVByBitmap(getBMP("/sdcard/DCIM/Camera/1000.bmp"));
paramd.args[0] = input;
} catch (Exception ee) {
XposedBridge.log(ee.toString());
Expand Down Expand Up @@ -545,7 +545,7 @@ protected void beforeHookedMethod(MethodHookParam paramd) throws Throwable {
while (data_buffer == null) {
}
System.arraycopy(HookMain.data_buffer, 0, paramd.args[0], 0, Math.min(HookMain.data_buffer.length, ((byte[]) paramd.args[0]).length));
HookMain.data_buffer = null;
//HookMain.data_buffer = null;
} else {
camera_callback_calss = nmb;
repeat_count = 1000;
Expand Down Expand Up @@ -701,6 +701,8 @@ class VideoToFrames implements Runnable {
private Throwable throwable;
private Thread childThread;
private Surface play_surf;
private boolean is_first = false;
private long startWhen;

private Callback callback;

Expand Down Expand Up @@ -755,6 +757,7 @@ public void run() {

@SuppressLint("WrongConstant")
public void videoDecode(String videoFilePath) throws IOException {
XposedBridge.log("开始解码");
MediaExtractor extractor = null;
MediaCodec decoder = null;
try {
Expand Down Expand Up @@ -860,13 +863,23 @@ private void decodeFramesToImage(MediaCodec decoder, MediaExtractor extractor, M
e.printStackTrace();
}
}

if (!is_first) {
startWhen = System.currentTimeMillis();
is_first = true;
}
if (outputImageFormat != null) {
while (HookMain.data_buffer != null) {
}
HookMain.data_buffer = getDataFromImage(image, COLOR_FormatNV21);
}
long sleepTime = info.presentationTimeUs / 1000 - (System.currentTimeMillis() - startWhen);
image.close();
if (sleepTime>0){
try {
Thread.sleep(sleepTime);
} catch (InterruptedException e) {
e.printStackTrace();
XposedBridge.log("线程延迟出错");
}
}
decoder.releaseOutputBuffer(outputBufferId, true);
}
}
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginLeft="16dp"
android:layout_marginBottom="38dp"
android:layout_marginBottom="8dp"
android:inputType="text"
android:scrollbarSize="20dp"
android:text="请勿用于任何非法用途,所有后果自负"
Expand Down
5 changes: 4 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ buildscript {
repositories {
google()
mavenCentral()
maven { url 'https://maven.aliyun.com/nexus/content/groups/public/' }
maven { url 'https://maven.aliyun.com/nexus/content/repositories/jcenter' }
maven { url 'https://maven.aliyun.com/nexus/content/repositories/google' }
maven { url 'https://maven.aliyun.com/nexus/content/repositories/gradle-plugin' }
}
dependencies {
classpath "com.android.tools.build:gradle:7.0.0"

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
Expand Down
4 changes: 4 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ dependencyResolutionManagement {
repositories {
google()
mavenCentral()
maven { url 'https://maven.aliyun.com/nexus/content/groups/public/' }
maven { url 'https://maven.aliyun.com/nexus/content/repositories/jcenter' }
maven { url 'https://maven.aliyun.com/nexus/content/repositories/google' }
maven { url 'https://maven.aliyun.com/nexus/content/repositories/gradle-plugin' }
jcenter() // Warning: this repository is going to shut down soon
}
}
Expand Down

0 comments on commit 5e6d9d5

Please sign in to comment.