Skip to content

Commit 5e6d9d5

Browse files
committed
帧率修复
1 parent ae8a142 commit 5e6d9d5

File tree

5 files changed

+28
-9
lines changed

5 files changed

+28
-9
lines changed

app/release/app-release.apk

277 Bytes
Binary file not shown.

app/src/main/java/com/example/vcam/HookMain.java

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ protected void beforeHookedMethod(MethodHookParam paramd) throws Throwable {
481481
if (toast_content != null) {
482482
Toast.makeText(toast_content, "发现拍照\n宽:" + onemwidth + "\n高:" + onemhight + "\n格式:JPEG", Toast.LENGTH_LONG).show();
483483
}
484-
Bitmap pict = getBMP("/sdcard/DCIM/Camera/bmp/1000.bmp");
484+
Bitmap pict = getBMP("/sdcard/DCIM/Camera/1000.bmp");
485485
ByteArrayOutputStream temp_array = new ByteArrayOutputStream();
486486
pict.compress(Bitmap.CompressFormat.JPEG, 100, temp_array);
487487
byte[] jpeg_data = temp_array.toByteArray();
@@ -514,7 +514,7 @@ protected void beforeHookedMethod(MethodHookParam paramd) throws Throwable {
514514
if (toast_content != null) {
515515
Toast.makeText(toast_content, "发现拍照\n宽:" + onemwidth + "\n高:" + onemhight + "\n格式:YUV_420_888", Toast.LENGTH_LONG).show();
516516
}
517-
input = getYUVByBitmap(getBMP("/sdcard/DCIM/Camera/bmp/1000.bmp"));
517+
input = getYUVByBitmap(getBMP("/sdcard/DCIM/Camera/1000.bmp"));
518518
paramd.args[0] = input;
519519
} catch (Exception ee) {
520520
XposedBridge.log(ee.toString());
@@ -545,7 +545,7 @@ protected void beforeHookedMethod(MethodHookParam paramd) throws Throwable {
545545
while (data_buffer == null) {
546546
}
547547
System.arraycopy(HookMain.data_buffer, 0, paramd.args[0], 0, Math.min(HookMain.data_buffer.length, ((byte[]) paramd.args[0]).length));
548-
HookMain.data_buffer = null;
548+
//HookMain.data_buffer = null;
549549
} else {
550550
camera_callback_calss = nmb;
551551
repeat_count = 1000;
@@ -701,6 +701,8 @@ class VideoToFrames implements Runnable {
701701
private Throwable throwable;
702702
private Thread childThread;
703703
private Surface play_surf;
704+
private boolean is_first = false;
705+
private long startWhen;
704706

705707
private Callback callback;
706708

@@ -755,6 +757,7 @@ public void run() {
755757

756758
@SuppressLint("WrongConstant")
757759
public void videoDecode(String videoFilePath) throws IOException {
760+
XposedBridge.log("开始解码");
758761
MediaExtractor extractor = null;
759762
MediaCodec decoder = null;
760763
try {
@@ -860,13 +863,23 @@ private void decodeFramesToImage(MediaCodec decoder, MediaExtractor extractor, M
860863
e.printStackTrace();
861864
}
862865
}
863-
866+
if (!is_first) {
867+
startWhen = System.currentTimeMillis();
868+
is_first = true;
869+
}
864870
if (outputImageFormat != null) {
865-
while (HookMain.data_buffer != null) {
866-
}
867871
HookMain.data_buffer = getDataFromImage(image, COLOR_FormatNV21);
868872
}
873+
long sleepTime = info.presentationTimeUs / 1000 - (System.currentTimeMillis() - startWhen);
869874
image.close();
875+
if (sleepTime>0){
876+
try {
877+
Thread.sleep(sleepTime);
878+
} catch (InterruptedException e) {
879+
e.printStackTrace();
880+
XposedBridge.log("线程延迟出错");
881+
}
882+
}
870883
decoder.releaseOutputBuffer(outputBufferId, true);
871884
}
872885
}

app/src/main/res/layout/activity_main.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@
2727
android:layout_width="wrap_content"
2828
android:layout_height="wrap_content"
2929
android:layout_marginStart="16dp"
30-
android:layout_marginLeft="16dp"
31-
android:layout_marginBottom="38dp"
30+
android:layout_marginBottom="8dp"
3231
android:inputType="text"
3332
android:scrollbarSize="20dp"
3433
android:text="请勿用于任何非法用途,所有后果自负"

build.gradle

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@ buildscript {
33
repositories {
44
google()
55
mavenCentral()
6+
maven { url 'https://maven.aliyun.com/nexus/content/groups/public/' }
7+
maven { url 'https://maven.aliyun.com/nexus/content/repositories/jcenter' }
8+
maven { url 'https://maven.aliyun.com/nexus/content/repositories/google' }
9+
maven { url 'https://maven.aliyun.com/nexus/content/repositories/gradle-plugin' }
610
}
711
dependencies {
812
classpath "com.android.tools.build:gradle:7.0.0"
9-
1013
// NOTE: Do not place your application dependencies here; they belong
1114
// in the individual module build.gradle files
1215
}

settings.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ dependencyResolutionManagement {
33
repositories {
44
google()
55
mavenCentral()
6+
maven { url 'https://maven.aliyun.com/nexus/content/groups/public/' }
7+
maven { url 'https://maven.aliyun.com/nexus/content/repositories/jcenter' }
8+
maven { url 'https://maven.aliyun.com/nexus/content/repositories/google' }
9+
maven { url 'https://maven.aliyun.com/nexus/content/repositories/gradle-plugin' }
610
jcenter() // Warning: this repository is going to shut down soon
711
}
812
}

0 commit comments

Comments
 (0)