Suggest workaround for error 0xfffffc0e
When the hardware encoder is not able to encode at the given definition, it fails with an error 0xfffffc0e. It is documented in the FAQ: <https://github.com/Genymobile/scrcpy/blob/master/FAQ.md#i-get-an-error-could-not-open-video-stream> But it is better to directly suggest the workaround in the console.
This commit is contained in:
parent
26529d377f
commit
8a694a9785
1 changed files with 16 additions and 0 deletions
|
@ -1,6 +1,8 @@
|
||||||
package com.genymobile.scrcpy;
|
package com.genymobile.scrcpy;
|
||||||
|
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
|
import android.media.MediaCodec;
|
||||||
|
import android.os.Build;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -133,11 +135,25 @@ public final class Server {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void suggestFix(Throwable e) {
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
|
if (e instanceof MediaCodec.CodecException) {
|
||||||
|
MediaCodec.CodecException mce = (MediaCodec.CodecException) e;
|
||||||
|
if (mce.getErrorCode() == 0xfffffc0e) {
|
||||||
|
Ln.e("The hardware encoder is not able to encode at the given definition.");
|
||||||
|
Ln.e("Try with a lower definition:");
|
||||||
|
Ln.e(" scrcpy -m 1024");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void main(String... args) throws Exception {
|
public static void main(String... args) throws Exception {
|
||||||
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
|
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void uncaughtException(Thread t, Throwable e) {
|
public void uncaughtException(Thread t, Throwable e) {
|
||||||
Ln.e("Exception on thread " + t, e);
|
Ln.e("Exception on thread " + t, e);
|
||||||
|
suggestFix(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue