Appium使用minicap后 截图视频流大小不对解决方法

minicap日志

INFO: Using projection 1x1@1x1/0
INFO: (external/minicap/src/minicap_33.cpp:245) Creating SurfaceComposerClient
INFO: (external/minicap/src/minicap_33.cpp:248) Performing SurfaceComposerClient init check
INFO: (external/minicap/src/minicap_33.cpp:259) Creating virtual display
INFO: (external/minicap/src/minicap_33.cpp:265) Creating buffer queue
INFO: (external/minicap/src/minicap_33.cpp:268) Setting buffer options
INFO: (external/minicap/src/minicap_33.cpp:272) Creating CPU consumer
INFO: (external/minicap/src/minicap_33.cpp:276) Creating frame waiter
INFO: (external/minicap/src/minicap_33.cpp:280) Publishing virtual display
INFO: (jni/minicap/JpgEncoder.cpp:64) Allocating 2820 bytes for JPG encode

注意 :INFO: Using projection 1x1@1x1/0, 意味着 minicap 虽然运行了,但它只创建了一个 1x1 像素的虚拟屏幕, * Appium 或 MJPEG 接收到的图像无法作为有效画面显示

分析启动脚本run.sh

是使用 adb shell dumpsys window | grep -Eo 'init=[0-9]+x[0-9]+' | head -1 | cut -d= -f 2 获取的屏幕大小,单独执行这行命令,发现返回内容是1x1

解决方法 修复shell

adb shell dumpsys window | grep -Eo 'init=[0-9]{2,5}x[0-9]{2,5}' | head -1 | cut -d= -f 2 限制必须是2-5位的,过滤掉 个位数

appium 自动化时mjpeg 报错,怎么解决ERROR hogwarts::138 启动appium服务失败: Message: An unknown server-side error occurred while processing the command. Original error: Waited 10000ms but the MJPEG server never sent any images
Stacktrace:
UnknownError: An unknown server-side error occurred while processing the command. Original error: Waited 10000ms but the MJPEG server never sent any images
at getResponseForW3CError (/usr/local/lib/node_modules/appium/node_modules/.store/@appium+base-driver@9.5.2/node_modules/@appium/base-driver/lib/protocol/errors.js:1118:9)
at asyncHandler (/usr/local/lib/node_modules/appium/node_modules/.store/@appium+base-driver@9.5.2/node_modules/@appium/base-driver/lib/protocol/protocol.js:491:57)
Traceback (most recent call last):
File “”, line 136, in start
File “/Users/ceshiguanlichu/myenv/venv/lib/python3.11/site-packages/appium/webdriver/webdriver.py”, line 251, in init
super().init(
File “/Users/ceshiguanlichu/myenv/venv/lib/python3.11/site-packages/selenium/webdriver/remote/webdriver.py”, line 276, in init
self.start_session(capabilities)
File “/Users/ceshiguanlichu/myenv/venv/lib/python3.11/site-packages/appium/webdriver/webdriver.py”, line 345, in start_session
response = self.execute(RemoteCommand.NEW_SESSION, w3c_caps)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/Users/ceshiguanlichu/myenv/venv/lib/python3.11/site-packages/selenium/webdriver/remote/webdriver.py”, line 468, in execute
self.error_handler.check_response(response)
File “/Users/ceshiguanlichu/myenv/venv/lib/python3.11/site-packages/selenium/webdriver/remote/errorhandler.py”, line 232, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: Waited 10000ms but the MJPEG server never sent any images
Stacktrace:
UnknownError: An unknown server-side error occurred while processing the command. Original error: Waited 10000ms but the MJPEG server never sent any images
at getResponseForW3CError (/usr/local/lib/node_modules/appium/node_modules/.store/@appium+base-driver@9.5.2/node_modules/@appium/base-driver/lib/protocol/errors.js:1118:9)
at asyncHandler (/usr/local/lib/node_modules/appium/node_modules/.store/@appium+base-driver@9.5.2/node_modules/@appium/base-driver/lib/protocol/protocol.js:491:57)
ERROR hogwarts::309 任务执行失败 (AttributeError): ‘NoneType’ object has no attribute ‘quit’