屏幕录像机应用程序在自定义 Rom 上抛出错误

问题描述 投票:0回答:1

我对 Android Custom Rom 开发还很陌生。我想知道检查编解码器本身的问题是什么。我有调试日志和应用程序本身的副本,但是我无法在安装应用程序后手动更改应用程序源代码。

我目前使用的是 Android 12 GSI,我正在尝试修改一些文件并使其在另一台设备上运行。

这是调试日志:

10-24 03:57:39.788 24987 24987 D RecordingService: onStartCommand com.android.systemui.screenrecord.START
10-24 03:57:39.788 24987 24987 D RecordingService: recording with audio sourceNONE
10-24 03:57:39.790 24987 24987 D ScreenMediaRecorder: start recording
10-24 03:57:39.792 1479 1508 I InputManager-JNI: Setting show touches feature to disabled.
10-24 03:57:39.795 1479 1601 I InputReader: Reconfiguring input devices, changes=SHOW_TOUCHES |
10-24 03:57:39.798 1035 1203 W StagefrightRecorder: stop while neither recording nor paused
10-24 03:57:39.811 24987 24987 W System.err: java.lang.IllegalArgumentException: unsupported size
10-24 03:57:39.811 24987 24987 W System.err: at android.media.MediaCodecInfo$VideoCapabilities.getSupportedFrameRatesFor(MediaCodecInfo.java:1676)
10-24 03:57:39.811 24987 24987 W System.err: at com.android.systemui.screenrecord.ScreenMediaRecorder.getSupportedSize(ScreenMediaRecorder.java:254)
10-24 03:57:39.811 24987 24987 W System.err: at com.android.systemui.screenrecord.ScreenMediaRecorder.prepare(ScreenMediaRecorder.java:130)
10-24 03:57:39.811 24987 24987 W System.err: at com.android.systemui.screenrecord.ScreenMediaRecorder.start(ScreenMediaRecorder.java:270)
10-24 03:57:39.811 24987 24987 W System.err: at com.android.systemui.screenrecord.RecordingService.startRecording(RecordingService.java:235)
10-24 03:57:39.811 24987 24987 W System.err: at com.android.systemui.screenrecord.RecordingService.onStartCommand(RecordingService.java:146)
10-24 03:57:39.812 24987 24987 W System.err: at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:4643)
10-24 03:57:39.812 24987 24987 W System.err: at android.app.ActivityThread.access$2000(ActivityThread.java:247)
10-24 03:57:39.812 24987 24987 W System.err: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2095)
10-24 03:57:39.812 24987 24987 W System.err: at android.os.Handler.dispatchMessage(Handler.java:106)
10-24 03:57:39.812 24987 24987 W System.err: at android.os.Looper.loopOnce(Looper.java:201)
10-24 03:57:39.812 24987 24987 W System.err: at android.os.Looper.loop(Looper.java:288)
10-24 03:57:39.812 24987 24987 W System.err: at android.app.ActivityThread.main(ActivityThread.java:7842)
10-24 03:57:39.812 24987 24987 W System.err: at java.lang.reflect.Method.invoke(Native Method)
10-24 03:57:39.812 24987 24987 W System.err: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)

完全不相关,但我正在研究 scrcpy 的相同问题,scrcpy 是 PC 多平台上的屏幕镜像工具。遇到相同的录制问题,直到我手动更改编码器,默认使用“c2.android.avc.encoder”。

我只有一个调试日志,但我没有办法跟踪所述“不支持的大小”。我去谷歌源代码并在这里准确地查看了它:

android.media.MediaCodecInfo$VideoCapabilities.getSupportedFrameRatesFor(MediaCodecInfo.java:1676)

并找到了这个功能:

private int[] getSupportedSize(final int screenWidth, final int screenHeight, int refreshRate) {
        double maxScale = 0;
        MediaCodecList codecList = new MediaCodecList(MediaCodecList.REGULAR_CODECS);
        MediaCodecInfo.VideoCapabilities maxInfo = null;
        for (MediaCodecInfo codec : codecList.getCodecInfos()) {
            String videoType = MediaFormat.MIMETYPE_VIDEO_AVC;
            String[] types = codec.getSupportedTypes();
            for (String t : types) {
                if (!t.equalsIgnoreCase(videoType)) {
                    continue;
                }
                MediaCodecInfo.CodecCapabilities capabilities =
                        codec.getCapabilitiesForType(videoType);
                if (capabilities != null && capabilities.getVideoCapabilities() != null) {
                    MediaCodecInfo.VideoCapabilities vc = capabilities.getVideoCapabilities();
                    int width = vc.getSupportedWidths().getUpper();
                    int height = vc.getSupportedHeights().getUpper();
                    int screenWidthAligned = screenWidth;
                    if (screenWidthAligned % vc.getWidthAlignment() != 0) {
                        screenWidthAligned -= (screenWidthAligned % vc.getWidthAlignment());
                    }
                    int screenHeightAligned = screenHeight;
                    if (screenHeightAligned % vc.getHeightAlignment() != 0) {
                        screenHeightAligned -= (screenHeightAligned % vc.getHeightAlignment());
                    }
                    if (width >= screenWidthAligned && height >= screenHeightAligned
                            && vc.isSizeSupported(screenWidthAligned, screenHeightAligned)) {
                        // Desired size is supported, now get the rate
                        int maxRate = vc.getSupportedFrameRatesFor(screenWidthAligned,
                                screenHeightAligned).getUpper().intValue();
                        if (maxRate < refreshRate) {
                            refreshRate = maxRate;
                        }
                        Log.d(TAG, "Screen size supported at rate " + refreshRate);
                        return new int[]{screenWidthAligned, screenHeightAligned, refreshRate};
                    }
                    // Otherwise, continue searching
                    double scale = Math.min(((double) width / screenWidth),
                            ((double) height / screenHeight));
                    if (scale > maxScale) {
                        maxScale = Math.min(1, scale);
                        maxInfo = vc;
                    }
                }
            }
        }
        // Resize for max supported size
        int scaledWidth = (int) (screenWidth * maxScale);
        int scaledHeight = (int) (screenHeight * maxScale);
        if (scaledWidth % maxInfo.getWidthAlignment() != 0) {
            scaledWidth -= (scaledWidth % maxInfo.getWidthAlignment());
        }
        if (scaledHeight % maxInfo.getHeightAlignment() != 0) {
            scaledHeight -= (scaledHeight % maxInfo.getHeightAlignment());
        }
        // Find max supported rate for size
        int maxRate = maxInfo.getSupportedFrameRatesFor(scaledWidth, scaledHeight)
                .getUpper().intValue();
        if (maxRate < refreshRate) {
            refreshRate = maxRate;
        }
        Log.d(TAG, "Resized by " + maxScale + ": " + scaledWidth + ", " + scaledHeight
                + ", " + refreshRate);
        return new int[]{scaledWidth, scaledHeight, refreshRate};
    }

那么我可以从哪里开始探测导致不支持的大小错误的错误?

java android codec
1个回答
0
投票

我遇到了类似的情况,我无法使用我的屏幕录像机录像和投射。我不知道如何修复它我目前使用的是 Android 14 GSI 我不知道你是否可以帮助我修复它

© www.soinside.com 2019 - 2024. All rights reserved.