Scrcpy: poor performance (high lag & low frame-rate) on cheap MediaTek budget phone

Created on 23 Jul 2018  路  8Comments  路  Source: Genymobile/scrcpy

Greetings.

I just tried scrcpy for the first time, and I really like the concept.

One thing that confuses me, however, is the many references to great performance, and lack of negative reports here on github, when my first & only convenient experience with it seemed to suffer greatly.

Is there anything I can do to help find, diagnose, or workaround this bottleneck?

Details:

  • Phone: BLU Studio X
  • CPU: MT6737
  • connected via USB 2.0 / 480Mbps
  • linux fedora 28
  • "very capable" pc hardware

Observations:

  • ~simply launching scrcpy seems to interfere with my linux gui (window shadows become black boxes), but it is returned to normal once scrcpy exits~
  • there is a significant time-lag between when an image is displayed on the android screen, and it appears on the computer (I estimate at approx. 2 seconds)
  • there is a very low frame rate (I estimate somewhere in the 5-to-10 fps range)
  • If I just look at the Android screen, the input lag is nearly zero... silky-smooth!
  • the CPU usage on the android device seems to be quite low! (~3%)

What I have tried:

  • using the bandwidth limiter - results in poor image quality, but the same lag & frame-rate
  • mucking with the target frame & i-frame rates in the ScreenEncoder
  • setting MediaFormat.KEY_PRIORITY to 0 (real-time)
  • re-arranging the encoding loop to re-use the codec, rather than rebuilding it

Next I'll try a "real" phone :-) ... whenever I find the time.

Thanks for making this! & making it open-source!

performance

Most helpful comment

Wow! It's suddenly quite usable! How did I overlook that? Thanks!!!"

Is there anything more to be gained by this ticket, or should it be closed?

All 8 comments

Almost forgot! This was the only interesting logcat statement I could find (repeated, but not incessantly):

07-23 14:32:18.859  1760 19397 E GraphicBufferSource: mLatestBufferUseCount is already 0.

There were also some debug messages about audio codec latency tokens, but they didn't seem super-interesting:

07-23 14:32:18.859  1760 19394 I VDO_LOG : [WRAPPER] ReleaseYUV
07-23 14:32:18.859  1760 19394 I VDO_LOG : [WRAPPER] UpdateBitstreamWP
07-23 14:32:18.859  1760 19394 I VDO_LOG : Encode size 175
07-23 14:32:18.859  1760 19394 D MtkOmxVenc: [0xb0e72800] AVC EncTime=84, RGB_2_YUV=0, buf timestamp=303242289 (303242289910) IsKey(0), Size(175) : in VA=0xAF81C460, offset=0x00000000, t=303242289910, len=12, flags=0x00000010 : out VA=0xA9D40000, offset=0x00000000
07-23 14:32:18.859  1760 19394 D MtkOmxVenc: [0xb0e72800] b0e72800 EBD (0xB5499460) (0xAF81C460), mNumPendingInput(0)
07-23 14:32:18.859  1760 19394 D MtkOmxVenc: [0xb0e72800] b0e72800 FBD (0xB5499280) (0xA9D40000) 303242289910 (175), mNumPendingOutput(7)
07-23 14:32:18.859  1760 19397 E GraphicBufferSource: mLatestBufferUseCount is already 0.
07-23 14:32:18.860 19377 19392 D ACodec  : give LatencyToken 541, 175
07-23 14:32:18.860 19377 19392 D ACodec  : [OMX.MTK.VIDEO.ENCODER.AVC] onOutputBufferDrained ID 13

the CPU usage on the android device seems to be quite low! (~3%)

What about the CPU usage on the computer?

There is no noticeable increase in cpu load while scrcpy is running (about 2% of one core).

Does it work better if you record your device screen:

adb shell screenrecord /sdcard/file.mp4
adb pull /sdcard/file.mp4

?

Yes. With that method, the frame rate is perfect.

One thing I notice, is a peculiar assortment of resolutions in the diagnostic output...

scrcpy startup:

  • "INFO: Initial texture: 720x1280"

screenrecord startup:

  • "The max width/height supported by codec is 640x480"

Playing the screenrecord output file:

  • Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 368x640, 634 kb/s, SAR 1:1 DAR 23:40, 9.67 fps, 90k tbr, 90k tbn, 180k tbc (default)

And with:

scrcpy -m640

?

Wow! It's suddenly quite usable! How did I overlook that? Thanks!!!"

Is there anything more to be gained by this ticket, or should it be closed?

OK, so your device hardware may not encode video fast enough above 640px. On "real" devices, it should work at 50~60 fps at 1920脳1080.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cordac1 picture cordac1  路  4Comments

fleytman picture fleytman  路  4Comments

behzadpooldar picture behzadpooldar  路  4Comments

swamikamal picture swamikamal  路  3Comments

targor picture targor  路  3Comments