Genymobile / scrcpy

Display and control your Android device
Apache License 2.0
108.55k stars 10.45k forks source link

Add H264/H265/AV1 GPU accelerated video decode support #3800

Open Ciancy28 opened 1 year ago

Ciancy28 commented 1 year ago

Is your feature request related to a problem? Please describe. Currently, scrcpy doesen't use the GPU's hardware accelerated video decoding capabilities, which increases resource usage/decode delay, this doesen't impact most modern PCs much, but on systems with weaker processors (especially with AV1), it should make a big difference, as far as I know, there is no downside to using video decoding acceleration, and most applications already use it as expected (web browsers, telegram/whatsapp, video editing software, every media player in existance... scrcpy is the only application I've ever found that doesen't take advantage of this).

Describe the solution you'd like Hardware accelerated video decode should be either an option, or enabled by default and togglable with a parameter.

Describe alternatives you've considered

Additional context H264 scrcpy H264 movie H265 scrcpy H265 movie

I observed the lack of gpu video decoding capabilities on a Windows 11 system with an AMD RX 580 GPU running scrcpy v2.0, I'm not sure if hardware decoding is limited to Linux or Nvidia/Intel GPUs, I couldn't find anything regarding this subject in the documentation, so I think it's missing on every system. I couldn't test the presence of AV1 video decoding capabilities as I don't have an Android device with an AV1 encoder and I don't have a GPU with an AV1 decoder.

rom1v commented 1 year ago

Yes, that would be great. But that's not trivial to keep the decoded image on the GPU until display for all video output. On VLC, we implement interops manually for OpenGL, DirectX, etc. I have not the resource to develop and maintain all video outputs manually. I would like SDL to support it: https://github.com/libsdl-org/SDL/issues/5405

Refs https://github.com/Genymobile/scrcpy/pull/1894

there is no downside to using video decoding acceleration

Now it's better than before, but hardware decoders caused a lot of crashes and other issues. In VLC, whenever such a problem occur, we recommend to disable hardware acceleration.

But of course when it works, it's better to use it.

rom1v commented 11 months ago

Oh, there are some news regarding this in SDL3:

oxwivi commented 3 months ago

SDL is adding Vulkan AV1 decode. How difficult would it be to get scrcpy hooked into using those?