Genymobile / scrcpy

Display and control your Android device
Apache License 2.0
110.42k stars 10.58k forks source link

Ugly frame rate with scrcpy and onn 4k 2003 box #5354

Open nc88keyz opened 1 week ago

nc88keyz commented 1 week ago

Here is the issue: frame rate is terribly slow over adb, Ive tried all the flags and the best can be seen is around 9-10 frames refresh rate. as default with no flags, its around 12-13 fps I have tried direct, over wireguard, over tail scale. does not matter. Here is what is really happening though. After much trial and error. Anydesk produces a near real time remote layer with very acceptable frame rate. The only work around I can do for maintenance on these installation is the following. Split screen with scrcpy on the right, and anydesk pinned on the left. With the mouse hovering over the scrcpy window. The visual speed is real time with all mouse movements and keyboard input on the anydesk window with screen recording active on the anydesk app via android google tv apk. My hope ?

Can this be fixed in scrcpy? or is something broken on adb protocol for the Onn 2023 4k box. I realize its a $20 value box in the USA, but the wifi streams fine , its relatively snappy so i don't see what is broken with scrcpy. Maybe something can be tweaked for it. On the same network a tivo stream 4k and multiple shields (2015 and 2019 pro models) do not have this issue.

Specs on the Onn 2023 4k stick, https://www.aftvnews.com/comparison-of-walmarts-onn-hd-stick-onn-4k-box-and-onn-4k-pro-streaming-devices-with-google-tv/

Also at the advice of some facebook group users, i used adb usb connection as well with little to no change. I was surprised by this as I was thinking it was a wifi issue, but was proven wrong by the results. It was not the answer.

rom1v commented 1 week ago

What command do you execute? Is it over USB? Over wifi?

Which resolution? Which bitrate?

What is the result with --print-fps?

If you record and play the file (scrcpy --record=file.mp4 …), is it laggy?

nc88keyz commented 1 week ago

ill get those for you, but i didnt see different in bitrates that I tried, not sure what I am looking for on --print-fps, and no did not try record=file.mp4, but can on a LAN. as it did the same as via remote basically with my personal onn 2023 4k for testing. I tried both usb and wifi.

fps 0 and 1 at 1920x1080 over wifi adb

recording is slightly laggy with animations maybe, but its nothing like real time output from scrpy window. can you post some resolutions to attempt, or bitrate flags. I do believe i tried those flags when troubleshooting initially.

nc88keyz commented 1 week ago

ok the following works well, at about 1 to 1.5 fps -b2M --max-size 720 not sure about fps now? will update

7-8fps, which is not great but definately better than it was before. -b4M --print-fps --max-size 720

7 8 7 etc

Why is 1080 and 1440 breaking it badly?

480 = 16fps lol.

ok, what can we do to make it better without sacrificing resolution to that extreme?

thank you so much for your help btw. I dont buy that the onn chipset, which is several years newer than the tivo stream would be that much difference! with 3 years of technology advancement.

rom1v commented 1 week ago

Also try another encoder: https://github.com/Genymobile/scrcpy/blob/master/doc/video.md#encoder

7-8fps

What is on the device screen? (scrcpy never captures a frame if nothing has changed, so for example on a static screen you get 0fps). Is it smooth on the device itself?

or is something broken on adb protocol

All of this has nothing to do with adb, it's the capture+encoding on the device by MediaCodec (and the encoder implementation).

nc88keyz commented 1 week ago

It was just projectivity launcher, and moving arrows back and forth up down, ocassioanlly clicking enter on the cog. , 0,1,0,0 etc. with 1080, at 720 and 2M it gets around 7,8 for same activity on launcher.

i tried the encoders thing before this is what is returned with list

[server] INFO: List of video encoders: --video-codec=h264 --video-encoder='c2.android.avc.encoder' --video-codec=h264 --video-encoder='OMX.google.h264.encoder' [server] INFO: List of audio encoders: --audio-codec=opus --audio-encoder='c2.android.opus.encoder' --audio-codec=aac --audio-encoder='c2.android.aac.encoder' --audio-codec=aac --audio-encoder='OMX.google.aac.encoder'

recommended path?

rom1v commented 1 week ago

Did you try both video encoders?

nc88keyz commented 1 week ago

INFO: 1 fps INFO: 1 fps INFO: 1 fps INFO: 1 fps INFO: 1 fps INFO: 1 fps INFO: 1 fps INFO: 1 fps INFO: 1 fps INFO: 1 fps INFO: 1 fps INFO: 1 fps INFO: 1 fps INFO: 1 fps INFO: 1 fps INFO: 1 fps INFO: 1 fps INFO: 2 fps INFO: 1 fps INFO: 1 fps INFO: 1 fps INFO: 2 fps INFO: 1 fps INFO: 2 fps INFO: 1 fps INFO: 1 fps INFO: 2 fps INFO: 1 fps INFO: 1 fps

at 2M 1080 this is the output the audio does appear to be almost real time, with acceptable lag

rom1v commented 1 week ago

With --video-encoder=c2.android.avc.encoder or --video-encoder=OMX.google.h264.encoder?

rom1v commented 1 week ago

Also, out of curiosity, does --turn-screen-off change anything?

nc88keyz commented 1 week ago

encoders do not make a difference at 720p , 7-8 fps output. will update with turn screen off, i think it didnt work before but could be wrong

screen off does not make differece, still 7,8 fps output. BTW, i did try to disable 4k on display settings and set to 1080p60, no difference also.

the Onn 2023 4k runs android 12, they are not bloated, and do not have large amounts of storage used up. no kodi installations or anything. just basically channels dvr, and tivimate and a few streaming apps. it took hours to set these up at 0,1 fps for my famiy members 5 states away over scrcpy. not the experience with a shield or tivostream 4k. the 720p and 2M bitrate does help, i mean 7 to 8 v 1fps is night and day. Don't understand why it would hang up ,on the encoder , when anydesk output is near admirable.

Also considering the Onn 2023 4k is a very obtainable and popular box for the pricing int he USA at $20 USD, why haven't more people brought this ugly performance issue up? I cannot imagine scrcpy is not used widely on these devices. Its the best tool ever for android for remote administration!!! I have a lot of tech-special needs people in my family ! haha

rom1v commented 1 week ago

7-8 fps is clearly not normal. It should be 60fps.

Here, this is a capture/encoding issue (if you record, you'll get low frame rate too in the recorded file), but I don't know why.

when anydesk output is near admirable.

Anydesk running on the very same device? Every app capturing the screen should also use MediaCodec, so if it behaves differently it probably gives different options.

You can play with options here: https://github.com/Genymobile/scrcpy/blob/665ccb32f5306ebd866dc0d99f4d08ed2aeb91c3/server/src/main/java/com/genymobile/scrcpy/video/SurfaceEncoder.java#L230-L246 (you can change values with --video-codec-options)

Does it work better with --no-audio?

nc88keyz commented 1 week ago

I agree its not normal, and every other android tv devices in my house does not exibit these issues. have not seen anything about 7,8 fps unless you drop to 480, 1M which is unbearable. I will say this the connection is around 48-56Mbps over wifi on an asus Xt8 mesh point. They go up to 6E if the device supports it. I think i have two devices , that do, not that that should matter, but it was the same over usb as well, with no noticable. Someone has to have an Onn 2023 4k walmart special that can test out as well. Ive gotten the same results on two different LANS and over WAN as well. via native RDP, rustdesk, anydesk, via remote, and even remote desktop to usb adb , ( had my dad order a usb2go adapter and we ended up just powering it off the laptop itself and doing without the usb2go adapter as the usb a to a cable we ordered would not recognize on the laptop. Also tried on my own network, I bought one just to test out and never returned it to Walmart, to help out a friend and my dad as well. They all work great and snappy with exception to the encoding through scrcpy and adb. I dont know what else to troubleshoot. I dont guess you can get your hands on one of these boxes? The only commonality on both networks is two different asus routers that run merlin firmware, One is an eero mesh network 1 gen, the other is an asus mesh network, all have hardwired backbones on gigabit. Shields, 4k tivostreams, android tvs from sony work just fine, zidoo media boxes running android 9, I think the smart tvs are android 8 I rarely use the android tv built into my older sony displays. These Onn boxes from 2023, and still mfg in 2024 are $20 USD at your local wal-mart if in the USA.

nc88keyz commented 1 week ago

7-8 fps is clearly not normal. It should be 60fps.

Here, this is a capture/encoding issue (if you record, you'll get low frame rate too in the recorded file), but I don't know why.

when anydesk output is near admirable.

Anydesk running on the very same device? Every app capturing the screen should also use MediaCodec, so if it behaves differently it probably gives different options.

You can play with options here:

https://github.com/Genymobile/scrcpy/blob/665ccb32f5306ebd866dc0d99f4d08ed2aeb91c3/server/src/main/java/com/genymobile/scrcpy/video/SurfaceEncoder.java#L230-L246

(you can change values with --video-codec-options) Does it work better with --no-audio?

no--difference-with--no-audio-lol

rom1v commented 1 week ago

@nc88keyz Too much information. The problem is a capture/encoding issue, so we don't care about network, bandwith, usb, routers…

Do you get smooth mirroring (60fps) on the very same box with another software?

It seems your device does not have any hardware encoder, that's why it's slow: it encodes in software. But if it works with another software on the very same device, then I'm wrong.

nc88keyz commented 1 week ago

by device you mean the source android device, yes?

Is that even possible for the Onn box to not have an encoder that functions?

so, anydesk is an android app I. the playstore. It's installed on the device ( onn) and the viewer is x64 anydesk client on Win11. It's can stream very fluidly in comparison to the encoder output recieved by scrcpy. I think I mentioned before that the capture is better but not 60fps by any means. Is there a way to verify no encoder is present or disabled?