StaZhu / enable-chromium-hevc-hardware-decoding

A guide that teach you enable hardware HEVC decoding & encoding for Chrome / Edge, or build a custom version of Chromium / Electron that supports hardware & software HEVC decoding and hardware HEVC encoding.
MIT License
1.15k stars 56 forks source link

在 Android 平台上不支持hevc硬解 #28

Closed lns103 closed 1 year ago

lns103 commented 1 year ago

如题,设备 小米 10 ultra,安卓12,Soc支持硬解hevc 8k60 HDR 之前使用 chrome 104 的时候尝试过参数启动,但是无论怎么折腾都没有hevc支持。 现在使用默认启用hevc的chrome canary 107.0.5302.0,打开 chrome://gpu 仍然没有hevc硬解支持,hevc视频也无法播放

StaZhu commented 1 year ago

稍等哈,我提个mr上去,问问chrome的大佬们,可能是收到fieldtrial实验的影响了,代码已经enable by default了。

StaZhu commented 1 year ago
  1. 107版本Finch放量已开到100%,已联系chrome小哥搞定。
  2. 更新下108.0.5305.0 fieldtrial逻辑已去掉了 这次肯定默认开启了
lns103 commented 1 year ago
  1. 107版本Finch放量已开到100%,已联系chrome小哥搞定。
  2. 更新下108.0.5305.0 fieldtrial逻辑已去掉了 这次肯定默认开启了

感谢,另外Google play store似乎还没放出新版本安装包,只能够下载到107.0.5304.0,但是这个版本的hevc硬解已经可以用了,只是分辨率不能超过3840x2160

StaZhu commented 1 year ago
  1. 107版本Finch放量已开到100%,已联系chrome小哥搞定。
  2. 更新下108.0.5305.0 fieldtrial逻辑已去掉了 这次肯定默认开启了

感谢,另外Google play store似乎还没放出新版本安装包,只能够下载到107.0.5304.0,但是这个版本的hevc硬解已经可以用了,只是分辨率不能超过3840x2160

可以试试最新版的 Chrome Canary 112,只要设备支持,Chrome也已经支持8K了(不过B站和Youtube的8K都是AV1,想看B站HEVC的8K需要改UA)

lns103 commented 1 year ago

可以试试最新版的 Chrome Canary 112,只要设备支持,Chrome也已经支持8K了(不过B站和Youtube的8K都是AV1,想看B站HEVC的8K需要改UA)

用8gen1的平板试了一下,不行,865的手机也是一样,用mx player可以正常播放(视频是b站下载的8k 30 hevc) Screenshot_20230217_134813_Chrome Canary Screenshot_20230217_134830_Chrome Canary 补充一个正式版截图,确实有区别 Screenshot_20230217_135647_Chrome

StaZhu commented 1 year ago

根据你的截图,看起来 8gen1 这个芯片只支持到4096*4096硬解,如果大于这个分辨率,chrome因为软解兜底,所以就播不了,能播也不是硬解。看起来 mx player走的应该是它自带的软解。

StaZhu commented 1 year ago

Pixel 6 Pro支持8K HEVC,Pixel 6 Pro上结果是这样:

Video Acceleration Information
Decoding
Decode h264 baseline
96x96 to 8192x4320 pixels
Decode h264 baseline
2x2 to 2048x4080 pixels
Decode h264 baseline
2x2 to 4080x2048 pixels
Decode h264 baseline
96x96 to 4320x8192 pixels
Decode h264 baseline
96x96 to 8192x4320 pixels
Decode h264 baseline
96x96 to 4320x8192 pixels
Decode h264 main
2x2 to 2048x4080 pixels
Decode h264 main
2x2 to 4080x2048 pixels
Decode h264 main
96x96 to 4320x8192 pixels
Decode h264 main
96x96 to 8192x4320 pixels
Decode h264 main
96x96 to 8192x4320 pixels
Decode h264 main
96x96 to 4320x8192 pixels
Decode h264 high
2x2 to 2048x4080 pixels
Decode h264 high
2x2 to 4080x2048 pixels
Decode h264 high
96x96 to 4320x8192 pixels
Decode h264 high
96x96 to 8192x4320 pixels
Decode h264 high
96x96 to 8192x4320 pixels
Decode h264 high
96x96 to 4320x8192 pixels
Decode vp8
2x2 to 2048x2048 pixels (encrypted)
Decode vp9 profile0
2x2 to 2048x2048 pixels (encrypted)
Decode vp9 profile0
96x96 to 2304x4096 pixels (encrypted)
Decode vp9 profile0
360x360 to 2304x4096 pixels
Decode vp9 profile0
96x96 to 4096x2304 pixels (encrypted)
Decode vp9 profile0
360x360 to 4096x2304 pixels
Decode vp9 profile0
96x96 to 2304x4096 pixels (encrypted)
Decode vp9 profile0
360x360 to 2304x4096 pixels
Decode vp9 profile0
96x96 to 4096x2304 pixels (encrypted)
Decode vp9 profile0
360x360 to 4096x2304 pixels
Decode vp9 profile2
2x2 to 2048x2048 pixels
Decode vp9 profile2
96x96 to 2304x4096 pixels
Decode vp9 profile2
96x96 to 4096x2304 pixels
Decode vp9 profile2
96x96 to 2304x4096 pixels
Decode vp9 profile2
96x96 to 4096x2304 pixels
Decode hevc main
96x96 to 8192x4320 pixels
Decode hevc main
96x96 to 4320x8192 pixels
Decode hevc main
2x2 to 2176x4096 pixels
Decode hevc main
2x2 to 4096x2176 pixels
Decode hevc main
96x96 to 8192x4320 pixels
Decode hevc main
96x96 to 4320x8192 pixels
Decode hevc main 10
96x96 to 4320x8192 pixels
Decode hevc main 10
96x96 to 8192x4320 pixels
Decode hevc main 10
96x96 to 4320x8192 pixels
Decode hevc main 10
96x96 to 8192x4320 pixels
Decode hevc main still-picture
2x2 to 2176x4096 pixels
Decode hevc main still-picture
96x96 to 8192x4320 pixels
Decode hevc main still-picture
96x96 to 4320x8192 pixels
Decode hevc main still-picture
96x96 to 4320x8192 pixels
Decode hevc main still-picture
96x96 to 8192x4320 pixels
Decode hevc main still-picture
2x2 to 4096x2176 pixels
Decode av1 profile main
2x2 to 2048x2048 pixels (encrypted)
Encoding
Encode h264 baseline
128x128 to 8192x4320 pixels, and/or 960.000 fps.
Encode h264 baseline
128x128 to 4320x8192 pixels, and/or 960.000 fps.
Encode h264 baseline
16x16 to 2048x1024 pixels, and/or 960.000 fps (software codec).
Encode h264 baseline
16x16 to 1024x2048 pixels, and/or 960.000 fps (software codec).
Encode h264 main
128x128 to 8192x4320 pixels, and/or 960.000 fps.
Encode h264 main
128x128 to 4320x8192 pixels, and/or 960.000 fps.
Encode h264 main
16x16 to 2048x1024 pixels, and/or 960.000 fps (software codec).
Encode h264 main
16x16 to 1024x2048 pixels, and/or 960.000 fps (software codec).
Encode h264 high
128x128 to 8192x4320 pixels, and/or 960.000 fps.
Encode h264 high
128x128 to 4320x8192 pixels, and/or 960.000 fps.
lns103 commented 1 year ago

根据你的截图,看起来 8gen1 这个芯片只支持到4096*4096硬解,如果大于这个分辨率,chrome因为软解兜底,所以就播不了,能播也不是硬解。看起来 mx player走的应该是它自带的软解。

是硬解,没问题,手动切软解会非常卡 Screenshot_20230217_141338_MX Player Screenshot_20230217_141411_MX Player

StaZhu commented 1 year ago

这个就奇怪了,这里的4096*4096是安卓系统API给返回的最大支持的宽高。

chrome 112 之前,这里所有 codec 都是写死的38402160,然后当时做android的小哥好像还忘了加 21603840😓(竖屏的4k视频现在在110上就播不了),但是现在换成用系统API拿最大支持的宽高了,但是按你这个说法其实是安卓自己给的信息都可能不准确。

StaZhu commented 1 year ago

crbug链接在这里:https://bugs.chromium.org/p/chromium/issues/detail?id=1386139 代码mr在这里:https://chromium-review.googlesource.com/c/chromium/src/+/4219883

感觉这个现象挺奇怪的,你能在上面那个crbug链接里,把遇到的情况用英语说一下吗!

总之这个问题要么是系统API有问题,要么是硬件厂商给系统的最大支持宽高是错的。

lns103 commented 1 year ago

这个就奇怪了,这里的4096*4096是安卓系统API给返回的最大支持的宽高。

chrome 112 之前,这里所有 codec 都是写死的3840_2160,然后当时做android的小哥好像还忘了加 2160_3840sweat(竖屏的4k视频现在在110上就播不了),但是现在换成用系统API拿最大支持的宽高了,但是按你这个说法其实是安卓自己给的信息都可能不准确。

似乎读错decoder了,获取到了软解的信息 Screenshot_20230217_142151_Codec Info Screenshot_20230217_142158_Codec Info

StaZhu commented 1 year ago

我去。。。 辛苦老哥在那个crbug里反馈下。。。这个读错了可不行。。。

lns103 commented 1 year ago

crbug链接在这里:https://bugs.chromium.org/p/chromium/issues/detail?id=1386139 (代码mr在这里:https://chromium-review.googlesource.com/c/chromium/src/+/4219883)

感觉这个现象挺奇怪的,你能在上面那个crbug链接里,把遇到的情况用英语说一下吗!

StaZhu commented 1 year ago

老哥你这个用的是啥软件看的codec信息,我回去也下一个试试,之前对安卓不是那么了解。

lns103 commented 1 year ago

老哥你这个用的是啥软件看的codec信息,我回去也下一个试试,之前对安卓不是那么了解。

Codec Info 刚刚才在play商店下载的

StaZhu commented 1 year ago

老哥你这个用的是啥软件看的codec信息,我回去也下一个试试,之前对安卓不是那么了解。

Codec Info 刚刚才在play商店下载的

Thanks

StaZhu commented 1 year ago

老哥,晚点我发你个带debug信息的安卓包,你能帮我再测一下吗,现在在编译。

lns103 commented 1 year ago

老哥,晚点我发你个带debug信息的安卓包,你能帮我再测一下吗,现在在编译。

没问题

StaZhu commented 1 year ago

https://lf3-cdn-tos.bytegoofy.com/obj/tcs-client/resources/chromium_112_8k_debug.zip

StaZhu commented 1 year ago

打开chrome://gpu 拉到最下面,把Video Decode的部分贴过来

lns103 commented 1 year ago

Screenshot_20230218_192757_Chromium 1676719728476

lns103 commented 1 year ago

8k视频能看了

StaZhu commented 1 year ago

Wow, 图1是之前播不了8K的那台设备吗,原先是4096x4096,现在出来8192x4320了?

lns103 commented 1 year ago

Wow, 图1是之前播不了8K的那台设备吗,原先是4096x4096,现在出来8192x4320了?

是的,下面那台865手机之前也是4096x4096,现在可以正常播放8k了

StaZhu commented 1 year ago

我再打个包给你,逻辑变成和原来一样的(刚给你的包,只改了一个地方的东西)。能在帮我截个图吗!

lns103 commented 1 year ago

我再打个包给你,逻辑变成和原来一样的(刚给你的包,只改了一个地方的东西)。能在帮我截个图吗!

可以的

StaZhu commented 1 year ago

https://lf3-cdn-tos.bytegoofy.com/obj/tcs-client/resources/chromium_112_8k_debug_2.zip

lns103 commented 1 year ago

Screenshot_20230218_194534_Chromium 1676720860033

StaZhu commented 1 year ago

所以,这两个版本的chromium都能8k,但是chrome canary不行?这不科学,刚发的那个包,逻辑和chrome canary是一样的,没啥变化。

StaZhu commented 1 year ago

现在用最新的Chrome Canary 还是只支持4K吗?我手里的这台小米手机,用Chrome Canary和Chromium(debug_2.zip)结果是完全一致的。

lns103 commented 1 year ago

现在用最新的Chrome Canary 还是只支持4K吗?我手里的这台小米手机,用Chrome Canary和Chromium(debug_2.zip)结果是完全一致的。

我突然发现好像是我的锅,之前chrome canary是从apkmirror下载的,重新从play商店下载就可以🤐(apk mirror上面的那个有个max API 28(安卓9.0

StaZhu commented 1 year ago

OK,那酱紫的话其实就没啥大问题了,至少8K是有的,然后这个chrome://gpu面板里面好多profile有重复的问题,我明天会提个MR上去,修一波。

lns103 commented 1 year ago

OK,那酱紫的话其实就没啥大问题了,至少8K是有的,然后这个chrome://gpu面板里面好多profile有重复的问题,我明天会提个MR上去,修一波。

主要是play商店下载chrome会有trichromelibrary,在不root的设备上清理非常麻烦,而canary日更,清理起来很麻烦,所以就去apkmirror上面下载完整apk包😂

StaZhu commented 1 year ago

Get,具体细节这个就不太懂了,说实话我是iOS党,现在我手里这个还是借的Android机器。

BTW,辛苦你在crbug给Dale Curtis也回一下吧。

lns103 commented 1 year ago

Get,具体细节这个就不太懂了,说实话我是iOS党,现在我手里这个还是借的Android机器。

BTW,辛苦你在crbug给Dale Curtis也回一下吧。

感谢大佬帮助,已经回了,不好意思耽误大佬时间了。 另外trichromelibrary是安卓10引入的,即使是同版本安装也不会覆盖,只会越来越多,用于让Chrome和webview共享内核节约空间,但问题是在更新Chrome和webview之后旧版本trichromelibrary不会自动删除,也不会显示在应用列表。 相当于每一次Chrome内核更新就会占用100多mb空间,对于canary这样的日更内核版本,很快空间就会被莫名占用很多。 我在手机一般是root之后直接进data删,但是平板没有root,使用adb删除过于复杂,就不想安装过多的trichromelibrary

StaZhu commented 1 year ago

🙏👌