Genymobile / scrcpy

Display and control your Android device
Apache License 2.0
111.07k stars 10.65k forks source link

Video encoding #3857

Open xAffan opened 1 year ago

xAffan commented 1 year ago

Is your feature request related to a problem? Please describe. The current video encoding codecs are not fast enough, since they are more optimized for quality and size rather than speed. This compromises latency and causes video to be choppy and laggy. Ruins a use for scrcpy (gaming).

Describe the solution you'd like More encoding codecs to be implemented such as vp8, vp9, h263, avc, mpeg etc. Thus, the best one can be chosen depending on the user's use case. In my case, low latency, but doesn't care about quality too much.

Describe alternatives you've considered Transmitting the video raw but it is not viable because the transfer speeds won't be able to keep up.

Additional context Most of the smartphones have hardware encoders for the codecs mentioned above. It is only natural that scrcpy adds support for them.

xAffan commented 1 year ago

Please update

rom1v commented 1 year ago

Most of the smartphones have hardware encoders for the codecs mentioned above

It seems that devices typically don't have hardware encoders for the other formats (so it's way slower). For example, I tested vp8 and vp9 on my device (OnePlus 7 Pro), vpx encoding is software. Devices almost all have hardware h264 encoders, which are often very fast (it depends on the device). Btw, avc is H.264.

since they are more optimized for quality and size rather than speed

That's not true, typically the real time hardware encoders on Android devices are not very efficient in term of compression, to provide fast encoding with low resource consumption.

If you experience performance issues, check if your device has another h264 encoder which provides better performance (scrcpy --list-encoders). Then, to reduce latency, you can reduce the resolution and bit rate (scrcpy -m1024 -b2M).

You could also try advanced H.264 options to use the baseline profile instead of the main profile (see https://github.com/Genymobile/scrcpy/pull/1325#pullrequestreview-404667615).