We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
我用react照抄的时候测试只有一台手机可以正常投屏,其他手机都会报错启动 scrcpy 客户端时出错: AdbScrcpyExitedError: scrcpy server exited prematurely,想问问知道这是什么情况吗?
const connect = async () => { const Manager = AdbDaemonWebUsbDeviceManager.BROWSER console.log('Manager', Manager) const device = await Manager?.requestDevice() console.log('device', device) if (device) { try { const connection = await device.connect() console.log('connection', connection) const CredentialStore = new AdbWebCredentialStore() const transport = await AdbDaemonTransport.authenticate({ serial: device.serial, connection, credentialStore: CredentialStore }) console.log('transport', transport) const adb = new Adb(transport) console.log('adb', adb) adbInstance.current = adb } catch (e) { console.log(e) console.error('连接失败,当前设备已被其他应用程序占用!请关闭其他程序再尝试连接') } } else { console.error('请选择一台设备进行绑定连接') return } } const startScrcpy = () => { if (adbInstance.current) { scrcpyStart(renderRef, adbInstance.current) } } /** * 初始化 scrcpy 测试,推送服务端并启动 scrcpy 客户端 */ const scrcpyStart = async (renderRef: any, adb: Adb) => { try { console.log('Scrcpy 版本:', VERSION) renderContainer.current = renderRef.current if (!renderRef.current) { throw new Error('渲染容器未找到') } adbInstance.current = adb if (!adbInstance.current) { throw new Error('ADB 实例未初始化') } console.log('正在推送服务器...') await pushServerAndStartScrcpyClient(adbInstance.current, '/server.bin') console.log('服务端已推送') await startScrcpyClient(adb) } catch (error) { console.error('初始化 scrcpy 时出错:', error) if (error instanceof Error) { console.error('错误详情:', error.message) console.error('错误堆栈:', error.stack) } throw error } } /** * 启动 scrcpy 客户端并初始化视频流 * @param adb ADB 实例 */ const startScrcpyClient = async (adb: Adb) => { try { options = new AdbScrcpyOptionsLatest( new ScrcpyOptionsLatest({ videoCodec: 'h264' }) // new ScrcpyOptionsLatest({ // videoBitRate: 1000000, // 降低比特率到 1Mbps // videoCodec: 'h264', // 明确使用 H264 // lockVideoOrientation: ScrcpyVideoOrientation.Unlocked, // displayId: 0, // maxFps: 30, // 限制帧率 // maxSize: 1024, // 限制最大尺寸 // sendDeviceMeta: true, // sendDummyByte: true, // videoCodecOptions, // tunnelForward: true, // logLevel: ScrcpyLogLevel.Debug // }) ) // 就是这一步引起的报错 client.current = await AdbScrcpyClient.start(adb, DEFAULT_SERVER_PATH, VERSION, options) client.current.stdout .pipeTo( new WritableStream({ write: line => { console.log('stdout:', line) } }) as any ) .then((r: any) => console.log('pipeTo', r)) videoStream = await client.current.videoStream if (videoStream) { initializeVideoStream(videoStream) console.log('视频流已启动') } else { throw new Error('视频流初始化失败') } } catch (error) { console.error('启动 scrcpy 客户端时出错:', error) // 添加更详细的错误信息 if (error instanceof Error) { console.error('错误详情:', error.message) console.error('错误堆栈:', error.stack) } // 尝试清理资源 await destroyClient() throw error } }
The text was updated successfully, but these errors were encountered:
具体还是需要看手机是什么型号,由于在写的时候并没有很多手机测试,可以试试用scrcpy官方的能不能正常投屏https://github.com/Genymobile/scrcpy
Sorry, something went wrong.
在你的项目测试是可以的,但是在我的项目怎么都是报这个错...
我想起在我最初测试的时候,好像也遇到了类似的问题,你检查下这里:
console.log('正在推送服务器...') await pushServerAndStartScrcpyClient(adbInstance.current, '/server.bin')
这里的推送的server.bin到手机里面的/data/local/tmp文件夹下,推送后这个文件大小应该不会变的,你也可以输出下这个文件的二进制流,看大小正不正常
No branches or pull requests
Uh oh!
There was an error while loading. Please reload this page.
我用react照抄的时候测试只有一台手机可以正常投屏,其他手机都会报错启动 scrcpy 客户端时出错: AdbScrcpyExitedError: scrcpy server exited prematurely,想问问知道这是什么情况吗?
The text was updated successfully, but these errors were encountered: