mpv-android / mpv-android

#mpv-android @ libera.chat
MIT License
1.81k stars 226 forks source link

Is it possible to use HW decoding for audio ? #870

Closed Nojevah closed 2 months ago

Nojevah commented 2 months ago

Some audio players can use "system" decoders instead of their own (I guess ffmpeg) library. If I use "adb top" in shell, during audio playback (using phone loudspeaker, to avoid Bluetooth conversion), with a USB cable, I can monitor differences between players.

mpv, like every video players, does NOT use system decoders for audio. Even Samsung video player won't use hardware decoder for audio, so I guess it's not possible when there's a video, but who knows, maybe it's possible and nobody has attempted that ? I wanted to know if nobody is interested in this feature for video player, since the idea is to gain on video HW decoding only ? Or if it's just not possible for example to keep video and audio in sync ? Or it's just that you use ffmpeg for lots of things so let's use it for audio decoding too ?

I though using hardware decoding would prevent any audio treatment, but Vanilla music player manages to handle ReplayGain for example (only player to me who can achieve HW + replayGain).

Additional information

Phone info: Samsung A52s with Snapdragon 778G, Android 13 (One UI 5.1) A flac audio file launched with Vanilla music player (could have used Tiny Music Player too), then click on home button, then turn screen off, wait some seconds with "top -m 22 -d 5":

image

The same file, same condition, played with mpv:

image

sfan5 commented 2 months ago

In short: on the typical device a video player runs on the computing resources needed for audio decoding is vastly smaller than what you need to invest for video decoding & presentation (the primary target of optimization), so nobody bothers with audio hardware decoding. Desktop platforms typically don't even have any hardware for this. Exceptions to this are:

You can try passthrough if it works for you (only select codecs), but other than that nobody will invest effort into this because it's not worth it.