Genymobile / scrcpy

Display and control your Android device
Apache License 2.0
113.58k stars 10.82k forks source link

Pico Neo 3 stuttering #2819

Open mvurusic opened 3 years ago

mvurusic commented 3 years ago

Environment

I've been using the Pico Neo 2 since Januarry 2021 and I used scrcpy to display the picture from Pico on PC (Windows). It worked all very fine.

In October I got two new Pico Neo 3 devices and no matter what I do and try, the performance is very poor. I get about 1 fps - so it's more a diashow than anything.

I've tried everything i could find on the internet and forums, like reducing the bit-rate, max-size, I tried older versions of scrcpy (every version from 1.6 to 1.20) there is always the same result on both Pico Neo 3 devices. (bitrates: 1M to 25M, there is no difference in the performance)

And no matter what I try, performance on Pico Neo 2 is always perfect and on the Pico Neo 3 always very stuttering.

I also just contacted the support from Pico Neo, but maybe you can help me with any new idea...

By the way: It has to run by USB-cable (and i also tried different cables - every cable worked with Pico Neo 2 - and none made a difference with the Pico Neo 3).

Here are my settings (although i tried many other versions):

scrcpy.exe --crop=1280:1776:400:60 --max-size=800 --bit-rate=1M --max-fps=30 --window-borderless --always-on-top --window-x=100 --window-y=100 --window-width=800 --window-height=600 --display-buffer=100

scrcpy.exe --bit-rate=8M --max-fps=60 --window-borderless --always-on-top --window-x=100 --window-y=100 --window-width=800 --window-height=600

scrcpy.exe --crop=1280:1776:400:60 --max-size=400 --bit-rate=1M --max-fps=30 --window-borderless --always-on-top --window-x=100 --window-y=100 --window-width=800 --window-height=600 --display-buffer=1000

I also added a short Video. The picture inside the Pico Neo 3 was always smooth and i was moving the head all the time. And that's how it's always looking on the Windows screen...

https://user-images.githubusercontent.com/78421427/142998795-0fb5cfea-5fd4-4c0b-a7f9-4a8ee749f469.mp4

Thanks in advance!

Mihael

rom1v commented 3 years ago

This is a problem on the device, the encoder is not able to produce frames at the expected rate.

Did you try another encoder?

mvurusic commented 3 years ago

Ok thank you. I thought so too.

Yes I tried all possible encoders. One of them gave me a blackscreen. The others were all stuttering as well.

rom1v commented 3 years ago

What if you record with screenrecord?

adb shell screenrecord /sdcard/file.mp4
adb pull /sdcard/file.mp4
mvurusic commented 3 years ago

That seemed to work a little better - at least in the main menu:

https://user-images.githubusercontent.com/78421427/143006701-adb4e6fb-6902-48d3-bb7e-2059ec0c6c7c.mp4

mvurusic commented 3 years ago

Tried another one where I switched back to 72 fps (inside the Pico settings) and its stuttering again:

https://user-images.githubusercontent.com/78421427/143007437-fe82a082-d20c-4bb9-b222-950d689436de.mp4

rom1v commented 3 years ago

You could play with the encoder settings.

You could adapt any of the MediaFormat settings via the command line:

# example usage
scrcpy --codec-options=max-fps-to-encoder:float=5,bitrate:int=500000

This overwrites the existing ones (for example passed via --max-fps and --bit-rate), but also allows any other options.

The variables name and type are documented in the MediaFormat page.

For information, here are the options scrcpy configure by default:

https://github.com/Genymobile/scrcpy/blob/57fb08e443272a9d346b036fb421cdf0ccff3074/server/src/main/java/com/genymobile/scrcpy/ScreenEncoder.java#L199-L213

mvurusic commented 3 years ago

So I built scrcpy with different settings in ScreenEncoder.java and also added other setting i found in a different issue:

format.setInteger(MediaFormat.KEY_PROFILE, MediaCodecInfo.CodecProfileLevel.AVCProfileBaseline); format.setInteger(MediaFormat.KEY_LEVEL, MediaCodecInfo.CodecProfileLevel.AVCLevel1);

But unfortunately nothing helped. The stuttering didn't stop.

Here are the logs from Pico Neo 2 (where it works fine) and the Pico Neo 3 (stuttering) with same settings. Maybe you see something I didn't see:

pico2.txt pico3.txt

To me lines 31 to 33 look fishy (pico3.txt), compared to pico2.txt: 12-02 12:17:02.506 1177 2285 E OMXNodeInstance: setParameter(0xf583c304:qcom.encoder.avc, OMX.google.android.index.allocateNativeHandle(0x7f00005d): Input:0 en=0) ERROR: UnsupportedSetting(0x80001019) 12-02 12:17:02.506 1177 2285 I OMX-VENC: WARN: Enable/Disable allocate-native-handle allowed only in secure session 12-02 12:17:02.506 1177 2285 E OMXNodeInstance: setParameter(0xf583c304:qcom.encoder.avc, OMX.google.android.index.allocateNativeHandle(0x7f00005d): Output:1 en=0) ERROR: UnsupportedSetting(0x80001019)

By the way: Pico Support answered that they don't have any stuttering in their Pico Neo 3+scrcpy. They also sent me a video as proof. I tried it on 4 different PCs, 2x Pico Neo 3, one Pico Neo 2 and different cables. Always the same result.

Let me know if you have any other idea.

Thx!

rom1v commented 3 years ago

OMX-VENC: Enable/Disable allocate-native-handle allowed only in secure session

Just to see if the error message is different, could you try with this change:

diff --git a/server/src/main/java/com/genymobile/scrcpy/ScreenEncoder.java b/server/src/main/java/com/genymobile/scrcpy/ScreenEncoder.java
index f98c53d0..ac1f9d87 100644
--- a/server/src/main/java/com/genymobile/scrcpy/ScreenEncoder.java
+++ b/server/src/main/java/com/genymobile/scrcpy/ScreenEncoder.java
@@ -226,6 +226,7 @@ public class ScreenEncoder implements Device.RotationListener {
         // On Android 12 preview, SDK_INT is still R (not S), but CODENAME is "S".
         boolean secure = Build.VERSION.SDK_INT < Build.VERSION_CODES.R || (Build.VERSION.SDK_INT == Build.VERSION_CODES.R && !"S"
                 .equals(Build.VERSION.CODENAME));
+        secure = false;
         return SurfaceControl.createDisplay("scrcpy", secure);
     }

(or you could try the old scrcpy v1.5, before 1fdde490fd2a0b89680a2b5da5e5274192398023 was merged)

You are not alone with this problem on Pico Neo 3: #2835

mvurusic commented 3 years ago

Ok here are the logs pico2_secure.txt pico3_secure.txt

I'm not sure what exactly changed compared to the first logs. By the way: I'm building with scrcpy v1.21

I just tried v1.5 and 1.5.1. They are behaving the same as the other versions (Pico Neo 3 is stuttering, Pico Neo 2 is working).

mvurusic commented 3 years ago

Sorry, I picked the wrong versions to test (1.15 and 1.15.1). Now i tried 1.5 and it's the same behaviour.

mvurusic commented 2 years ago

Here a little update on my current progress:

After wasting quite a lot of time trying to fix the problem i ordered a third PicoNeo3 because i speculated that the problem is on the hardware.

Immediately after i got the headset i tried it with scrcpy and it worked perfectly fine. At that point the Software/Firmware version was v4.2.78. Then I updated the headset to current version v4.3.34 and it's stuttering again.

So the problem seems to be the new Software/Firmware.

Unfortunately there is no way I could go back to v4.2.78. Factory reset only deletes all user-files but does not change SW/FW.

I'm in contact with PicoNeo-Devs and I'll give an update here if there is anything new.

HenryBech commented 2 years ago

I had similar issues and asked on the developer forum for a PUI archive.

"Dear developer, The Neo 3 series do not support downgrade. For screen casting solutions, the Neo 3 series no longer supports scrcpy screen casting, and you can try use Miracast for screen casting. Please refer to the following links for details: https://developer.pico-interactive.com/docs/en/12058/225664/

In addition, our own screen casting solution is expected to be released in Q2."

https://devanswers.pico-interactive.com/index.php?qa=3722&qa_1=is-there-a-pui-archive