Video streaming is not sending video after connection is established
Environment
- OS: macOS
- scrcpy version: 2.0
- installation method: server only, downloaded from https://github.com/Genymobile/scrcpy/blob/master/doc/build.md#option-2-use-prebuilt-server
- device model: SM-973F.
- Android version: 10
Describe the bug I am using the scrcpy server to stream video to my local program. After the video socket is established, the local program receives the check byte successfully. But then the video socket didn't receive anything. It should continuously receive video bytes. It works for 1.24. This is the new behavior when I tried 2.0.
There is no errors seen from my terminal logs or logcat. But i will paste the logcat content during the time.
04-26 17:27:08.609 6250 6250 D KeyguardSecIndicationPolicy: update top pos = DEFAULT, item = [id=7645|ty=UNLOCK_GUIDE|pr=25|txt=Swipe to unlock|ti=duration=PERSISTENT|an=false] -> [id=7770|ty=BATTERY|pr=40|txt=Charging: 95% 04-26 17:27:08.609 6250 6250 D KeyguardSecIndicationPolicy: 24 m until full|ti=duration=3000|an=false] 04-26 17:27:08.609 6250 6250 D KeyguardSecIndicationController: onIndicationChanged() return - keyguard is not visible, pos = DEFAULT, item = [id=7770|ty=BATTERY|pr=40|txt=Charging: 95% 04-26 17:27:08.609 6250 6250 D KeyguardSecIndicationController: 24 m until full|ti=duration=3000|an=false] 04-26 17:27:08.609 6250 6250 D KeyguardSecIndicationPolicy: update Event pos = DEFAULT, type = BATTERY_RESTING, id = 7771, text = Charging: 95% 04-26 17:27:08.609 6250 6250 D KeyguardSecIndicationPolicy: 24 m until full 04-26 17:27:08.609 6250 6250 D KeyguardSecIndicationController: onRefreshBatteryInfo() status = BatteryStatus{status=2,level=95,plugged=2,health=2,maxChargingWattage=-1,remaining=1411000ultraFastCharger=0} 04-26 17:27:08.612 6250 6250 D PowerUI : priorPlugType = 2 mPlugType = 2 priorBatteryStatus = 2 mBatteryStatus = 2 04-26 17:27:08.613 6250 6250 D PowerUI.Notification: showChargingNotice oldChargingType : 7 currentChargingType : 7 oldChargingTime : 1440000 mChargingTime : 1411000 04-26 17:27:08.614 6250 6250 D PowerUI.Notification: showChargingNotification() 04-26 17:27:08.618 5328 5328 I display : HWC setVsyncEnabled = 1 04-26 17:27:08.624 5861 7493 D ApplicationPolicy: isStatusBarNotificationAllowedAsUser: packageName = com.android.systemui,userId = 0 04-26 17:27:08.624 5861 7493 D API test: getContainerInfo: value is 04-26 17:27:08.625 5861 7493 D ApplicationPolicy: isStatusBarNotificationAllowedAsUser: packageName = com.android.systemui,userId = -1 04-26 17:27:08.625 5861 7493 D API test: getContainerInfo: value is 04-26 17:27:08.625 5861 7493 D ApplicationPolicy: isStatusBarNotificationAllowedAsUser: converting userId from USER_ALLto 0 04-26 17:27:08.625 5861 7493 D API test: getContainerInfo: value is 04-26 17:27:08.627 6250 6250 D PowerUI : Battery swelling mode - priorBatterySwellingMode = 0 mBatterySwellingMode = 0 mBatteryStatus = 2 04-26 17:27:08.639 6250 6250 D QSContainerImpl: getDisplayHeight portrait? true displayHeight= 2280 04-26 17:27:08.734 5861 5861 D EdgeLightingManager: isCallingUserSupported : callingUserId=-1, mUserId=0, isDualAppId=false 04-26 17:27:08.739 6699 6699 D Launcher.NotificationListener: onNotificationPosted : StatusBarNotification(pkg=com.android.systemui user=UserHandle{-1} id=2131362942 tag=charging_state key=-1|com.android.systemui|2131362942|charging_state|10052: Notification(channel=GEN pri=-2 contentView=null vibrate=null sound=null defaults=0x0 flags=0xa color=0xff607d8b category=sys vis=PUBLIC semFlags=0x0 semPriority=0 semMissedCount=0)) number : 0 listener : null 04-26 17:27:08.824 5328 5397 I display : HWC setVsyncEnabled = 0 04-26 17:27:09.227 5314 5680 D EnterpriseController: netId is 0 04-26 17:27:09.227 5314 5680 E Netd : getNetworkForDns: getNetId from enterpriseCtrl is netid 0 04-26 17:27:09.227 5314 5680 D DnsProxyListener: DNSDBG::dns addrinfo af 0 - 10282 04-26 17:27:09.229 5314 21706 E ResolverController: No valid NAT64 prefix (0, <unspecified>/0) 04-26 17:27:09.230 5861 6176 E NetdEventListenerService: handleMessage: { when=0 what=10001 obj=com.android.server.connectivity.NetdEventListenerService$DnsResultParams@64ac44d target=com.android.server.connectivity.NetdEventListenerService$DnsEventHandler } 04-26 17:27:09.423 7255 7255 D io_stats: !@ 8,0 r 189876 10039152 w 646383 26294104 d 68962 130110656 f 206717 293254 iot 584508 447900 th 102400 0 0 pt 0 inp 0 0 152984.001 04-26 17:27:09.492 5364 5364 I SurfaceFlinger: SFWD update time=152984072917883 04-26 17:27:11.253 5314 5680 D EnterpriseController: netId is 0 04-26 17:27:11.253 5314 5680 E Netd : getNetworkForDns: getNetId from enterpriseCtrl is netid 0 04-26 17:27:11.253 5314 5680 D DnsProxyListener: DNSDBG::dns addrinfo af 0 - 10282 04-26 17:27:11.256 5314 21712 E ResolverController: No valid NAT64 prefix (0, <unspecified>/0) 04-26 17:27:11.257 5861 6176 E NetdEventListenerService: handleMessage: { when=0 what=10001 obj=com.android.server.connectivity.NetdEventListenerService$DnsResultParams@6333b02 target=com.android.server.connectivity.NetdEventListenerService$DnsEventHandler } 04-26 17:27:11.612 6250 6250 D KeyguardSecIndicationPolicy: remove Item pos = DEFAULT , id = 7770, 04-26 17:27:11.613 6250 6250 D KeyguardSecIndicationPolicy: update top pos = DEFAULT, item = [id=7770|ty=BATTERY|pr=40|txt=Charging: 95% 04-26 17:27:11.613 6250 6250 D KeyguardSecIndicationPolicy: 24 m until full|ti=duration=3000|an=false] -> [id=7645|ty=UNLOCK_GUIDE|pr=25|txt=Swipe to unlock|ti=duration=PERSISTENT|an=false] 04-26 17:27:11.613 6250 6250 D KeyguardSecIndicationController: onIndicationChanged() return - keyguard is not visible, pos = DEFAULT, item = [id=7645|ty=UNLOCK_GUIDE|pr=25|txt=Swipe to unlock|ti=duration=PERSISTENT|an=false] 04-26 17:27:12.013 5861 7493 I LocationManagerService: getGPSUsingApps() called 04-26 17:27:12.013 5861 7493 I NSLocationMonitor: getGPSUsingApps() called 04-26 17:27:12.034 6360 8525 V NSLocationManager_FLP: getGPSUsingApps, NO_FREEZE={5013}/ FREEZE={} 04-26 17:27:13.278 5314 5680 D EnterpriseController: netId is 0 04-26 17:27:13.278 5314 5680 E Netd : getNetworkForDns: getNetId from enterpriseCtrl is netid 0 04-26 17:27:13.278 5314 5680 D DnsProxyListener: DNSDBG::dns addrinfo af 0 - 10282 04-26 17:27:13.280 5314 21715 E ResolverController: No valid NAT64 prefix (0, <unspecified>/0) 04-26 17:27:13.282 5861 6176 E NetdEventListenerService: handleMessage: { when=0 what=10001 obj=com.android.server.connectivity.NetdEventListenerService$DnsResultParams@88c5849 target=com.android.server.connectivity.NetdEventListenerService$DnsEventHandler } 04-26 17:27:14.428 7255 7255 D io_stats: !@ 8,0 r 189876 10039152 w 646385 26294124 d 68962 130110656 f 206718 293256 iot 584512 447902 th 102400 0 0 pt 0 inp 0 0 152989.007 04-26 17:27:15.305 5314 5680 D EnterpriseController: netId is 0 04-26 17:27:15.305 5314 5680 E Netd : getNetworkForDns: getNetId from enterpriseCtrl is netid 0 04-26 17:27:15.305 5314 5680 D DnsProxyListener: DNSDBG::dns addrinfo af 0 - 10282 04-26 17:27:15.307 5314 21719 E ResolverController: No valid NAT64 prefix (0, <unspecified>/0) 04-26 17:27:15.310 5861 6176 E NetdEventListenerService: handleMessage: { when=0 what=10001 obj=com.android.server.connectivity.NetdEventListenerService$DnsResultParams@81e054e target=com.android.server.connectivity.NetdEventListenerService$DnsEventHandler } 04-26 17:27:15.820 7516 8067 D SDHMS:com.sec.android.sdhms.thermal.siop.y: SIOP:: AP:145(255,110) BAT:261(261,0) CHG:263(263,0) USB:271(271,0) WIFI:197(248,50) PA:236(287,50) LRP:254(254,0) LRF:253(253) LRB:254(254) 04-26 17:27:17.330 5314 5680 D EnterpriseController: netId is 0 04-26 17:27:17.330 5314 5680 E Netd : getNetworkForDns: getNetId from enterpriseCtrl is netid 0
What command do you execute?
It works for 1.24. This is the new behavior when I tried 2.0.
You must add audio=false for 2.0.
Hi @rom1v, did we change anything when the server sends back in the socket? I received an invalid h264 frame.
Here is my command to trigger the scrcpy server:
adb", "shell", "CLASSPATH=/data/local/tmp/scrcpy-server.jar", "app_process", "/", "com.genymobile.scrcpy.Server", v2.0, max_size=960, "tunnel_forward=true", bit_rate=6000000, send_frame_meta=false, control=true, display_id=0, audio=false, encoder_name=OMX.google.h264.encoder
From the raw h264 frames sent back from the server, I detected an invalid bytes, where there is a 003x bytes and x is not 0-3. Which is invalid in the h264 format protocol. This is working on 1.24.
There is a new send_codec_meta in 2.0. So also pass send_codec_meta=false if you don't use the more general option raw_video_stream=true:
https://github.com/Genymobile/scrcpy/blob/cb20bcb16f4ca191e237c8744a7c2e6d29701d60/server/src/main/java/com/genymobile/scrcpy/Server.java#L321-L328
Update on this. I compared the code changes between v1 and v2. The place where it got modofied was the device meta length. It changed from 64+4 bytes to 64 bytes.
But the control messages now stops working. All the control events I sent to scrcpy's server seem to have no effect right now. Any pointers for me to debug? Or any quick hints on you mind what's changed? @rom1v
The protocol is documented here: https://github.com/Genymobile/scrcpy/blob/master/doc/develop.md#protocol
Thanks @rom1v. The control is working now. It was a bug on my side.