scrcpy icon indicating copy to clipboard operation
scrcpy copied to clipboard

Add H264/H265/AV1 GPU accelerated video decode support

Open Ciancy28 opened this issue 1 year ago • 1 comments

  • [x] I have checked that a similar feature request does not already exist.

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.

Ciancy28 avatar Mar 12 '23 16:03 Ciancy28

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 avatar Mar 12 '23 17:03 rom1v

Oh, there are some news regarding this in SDL3:

  • https://github.com/libsdl-org/SDL/issues/5405
  • https://github.com/libsdl-org/SDL/pull/8366

rom1v avatar Oct 10 '23 13:10 rom1v