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

Support HEVC with Alpha #22

Closed yisibl closed 1 year ago

yisibl commented 1 year ago

一直以来,H.264 不具备 Alpha 通道的能力,在网页中有很多场景需要半透明的视频,例如:类似于剪映的视频剪辑工具。

过去,我们只能选择 VP8/VP9 编码,但由于其兼容性不佳,极大的制约了 Alpha 视频的应用。

我测试了最新的 Chrome canary(Mac),似乎还不支持带有 Alpha 通道 HEVC 视频,Safari 中可以播放:

<video autoplay controls src="https://rotato.netlify.app/alpha-demo/movie-hevc.mov"></video>
data:text/html;charset=UTF-8,<body style="background: pink;"><video autoplay controls src="https://rotato.netlify.app/alpha-demo/movie-hevc.mov"></video>
StaZhu commented 1 year ago

试了下Windows可以播,macOS不行,晚点回去Debug下给你反馈,感谢反馈,应该是Bug。

yisibl commented 1 year ago

太感谢了!

StaZhu commented 1 year ago

太感谢了!

基本定位问题所在了,明天我提个CL上去。

StaZhu commented 1 year ago

请今天下午再使用最新版Chrome Canary (107.0.5258.0) 测试一下吧,带Alpha图层的HEVC视频在macOS无法播放的问题已解决,顺手还修了一个H264的bug😂…

yisibl commented 1 year ago

请今天下午再使用最新版Chrome Canary (107.0.5258.0) 测试一下吧,带Alpha图层的HEVC视频在macOS无法播放的问题已解决,顺手还修了一个H264的bug😂…

太棒了。

yisibl commented 1 year ago

带有 alpha 的视频可以播放了,不过背景没有半透明😂

image

Test:

data:text/html;charset=UTF-8,<body style="background: pink;"><video autoplay controls src="https://rotato.netlify.app/alpha-demo/movie-hevc.mov"></video>
StaZhu commented 1 year ago

能否提供一个vp9的可以半透明视频?这个问题看起来是chrome基建的问题?

StaZhu commented 1 year ago

emm,我大概知道了,vp9因为在macos下videotoolbox硬解失败了,走的vpxvideodecoer解码,然后vpx的基建支持alpha图层,这块我看看代码咋搞吧。

yisibl commented 1 year ago

这个是 vp9 的:https://at.alicdn.com/t/975cc5f2-6be1-422b-b233-b1ffae7bc3d7.webm

StaZhu commented 1 year ago

我觉得这似乎引发了另一个bug(辛苦到crbug提个bug吧),这个视频是vp9 profile0的,这个profile是绝对支持macOS硬解的,只要系统版本大于macOS 11.0就可以硬解,但是硬解失败了,为什么会失败可能又是个有趣的问题。 因为vp9有软解解码器兜底,所以能播,但是性能很差。你打开chrome://media-internals可以看到这个视频实际上走的vpxvideodecoder解码了,这绝对是bug.... 23333

yisibl commented 1 year ago

@StaZhu 你说的 vp9 是另外一个问题?和上面说的 HEVC 无法背景透明没关系吧?

所以我应该提交一个这个 975cc5f2-6be1-422b-b233-b1ffae7bc3d7.webm vp9 视频没有走硬件加速的 Bug 对吧?

StaZhu commented 1 year ago

这是两个问题,vp9的问题你提crbug,hevc硬解没有alpha层的我来看

yisibl commented 1 year ago

这是两个问题,vp9的问题你提crbug,hevc硬解没有alpha层的我来看

抄收。

StaZhu commented 1 year ago

当然,如果你愿意提俩crbug也行,总之hevc的alpha layer我来看,vp9的因为是@dale curtis写的,得他看

yisibl commented 1 year ago

感情我们页面上的 WebM(vp9) 在 Chrome 上都没有走硬件加速,终究是错付了。

yisibl commented 1 year ago

提交了:

StaZhu commented 1 year ago

vp9 with alpha在Windows下也没法硬解,也是走的VPXVideoDecoder。以及,刚我在windows也测了下,hevc的也不支持alpha图层的方式显示(会跳过alpha layer),这两点辛苦更新到crbug里把。

StaZhu commented 1 year ago

另,hevc with alpha在Windows下微软Edge浏览器装hevc插件的情况,直接无法播放,这个事情,感觉任重而道远。

StaZhu commented 1 year ago

macOS 的 Fix 本周会提上去(本地跑通了),Windows 由于解码时会跳过 nuh_layer_id != 0 (Alpha图层)的nalu,得点开发量。

yisibl commented 1 year ago

vp9 with alpha在Windows下也没法硬解,也是走的VPXVideoDecoder。以及,刚我在windows也测了下,hevc的也不支持alpha图层的方式显示(会跳过alpha layer),这两点辛苦更新到crbug里把。

要不你去补充吧,我补充的不够专业,哈哈

yisibl commented 1 year ago

另,hevc with alpha在Windows下微软Edge浏览器装hevc插件的情况,直接无法播放,这个事情,感觉任重而道远。

可能最好的方式还是推动 Edge 不用插件,使用 Chrome 一样的解码逻辑。

StaZhu commented 1 year ago

另,hevc with alpha在Windows下微软Edge浏览器装hevc插件的情况,直接无法播放,这个事情,感觉任重而道远。

可能最好的方式还是推动 Edge 不用插件,使用 Chrome 一样的解码逻辑。

可能性不大,你要知道edge的av1也是走的插件

StaZhu commented 1 year ago

请今天下午再使用最新版Chrome Canary (107.0.5272.0) 测试一下吧,带Alpha图层的HEVC视频在macOS播放时无透明度效果已解决(Windows目前依然不支持alpha layer)…