Chromium HEVC硬件解码与编码完全指南
【免费下载链接】enable-chromium-hevc-hardware-decodingA 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.项目地址: https://gitcode.com/gh_mirrors/en/enable-chromium-hevc-hardware-decoding
本指南将详细介绍如何在Chrome/Edge浏览器中启用HEVC硬件解码与编码功能,以及如何编译支持HEVC的Chromium和Electron版本。
项目概述
本项目提供了一个完整的解决方案,帮助开发者和用户在Chromium内核的浏览器中实现HEVC硬件加速解码和编码功能。通过本指南,您可以了解HEVC硬解支持的具体Profile、操作系统要求、API接口以及完整的编译流程。
HEVC硬件解码支持的Profile
HEVC硬件解码支持以下四种主要Profile:
- HEVC Main:最高支持8192x8192像素分辨率
- HEVC Main 10:最高支持8192x8192像素分辨率
- HEVC Main Still Picture:最高支持8192x8192像素分辨率
- HEVC Rext:部分支持,具体细节见下表,最高支持8192x8192像素分辨率
硬件解码支持矩阵
| GPU | 8b 420 | 8b 422 | 8b 444 | 10b 420 | 10b 422 | 10b 444 | 12b 420 | 12b 422 | 12b 444 |
|---|---|---|---|---|---|---|---|---|---|
| Apple Silicon (macOS) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ❌ |
| Intel ICL ~ TGLx (Win) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ❌ |
| Intel TGLx+ (Win) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| NVIDIA Turing ~ Ada (Win) | ✅ | ❌ | ✅ | ✅ | ❌ | ✅ | ✅ | ❌ | ✅ |
操作系统要求
- macOS:Big Sur (11.0)及以上版本
- Windows:8及以上版本
- Android:5.0及以上版本
- Linux:Chrome版本号须>=
108.0.5354.0,仅支持VAAPI接口的GPU
API支持情况
视频解码API支持
- File:支持本地文件播放
- Media Source Extensions:支持流媒体播放
- WebCodec:8Bit需要>=
107.0.5272.0,10Bit+HEVC with Alpha需要>=108.0.5343.0 - Encrypted Media Extensions:支持Clearkey和Widevine L1硬件保护
视频编码API支持
- WebCodec:支持macOS、Windows、Android平台
- WebRTC:支持macOS、Windows、Android平台
- MediaRecorder:支持Windows、macOS、Android平台
HDR格式支持对比
| PQ | HDR10 | HDR10+ | HLG | DV P5 | DV P8.1 | DV P8.4 | |
|---|---|---|---|---|---|---|---|
| Chrome Mac | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ | ✅ |
| Chrome Win | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ | ✅ |
| Edge Mac | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ | ✅ |
| Safari Mac | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
在Windows平台,Chrome支持PQ、HDR10(含静态元数据的PQ)、HLG,会基于静态元数据(如果存在)自动进行Tone-mapping处理。
硬件解码验证方法
MediaCapabilities验证
const mediaConfig = { type: 'file', video: { contentType: 'video/mp4;codecs="hev1.1.6.L120.90"', width: 1920, height: 1080, bitrate: 10000, framerate: 30 } } navigator.mediaCapabilities.decodingInfo(mediaConfig) .then(result => { if (result.supported) { console.log('Video can decode!'); } else { console.log('Video can\'t decode!'); } });MediaSource验证
if (MediaSource.isTypeSupported('video/mp4;codecs="hev1.1.6.L120.90"')) { console.log('HEVC main profile is supported!'); }编译指南
环境准备
- 按照官方Chromium编译文档配置开发环境
- 拉取main分支的源代码(HEVC硬件解码代码已合并)
启用HEVC软件解码
- 切换到
src/third_party/ffmpeg目录 - 执行
git am /path/to/add-hevc-ffmpeg-decoder-parser.patch - 执行
git am /path/to/change-libavcodec-header.patch - 执行
git am /path/to/enable-hevc-ffmpeg-decoding.patch
集成Widevine CDM
切换到src目录,执行:
cp -R /path/to/widevine/* third_party/widevine/cdm常见问题解决
显卡支持但无法硬件解码
操作系统版本过低
- Windows:确保使用Windows 8及以上版本
- macOS:确保使用Big Sur及以上版本
显卡驱动问题
部分显卡驱动版本存在BUG,导致D3D11VideoDecoder被禁用。请更新到最新版本显卡驱动。
技术实现差异
Windows平台技术对比
- Edge:使用
VDAVideoDecoder调用MFT解码器 - Firefox:调用
MFT解码器 - Chrome:使用
D3D11VideoDecoder调用D3D11VA解码器
macOS平台技术对比
- Edge和Chrome:使用相同的解码实现
- Safari和Chrome:均使用
VideoToolbox解码器
验证硬件解码是否启用
- 打开
chrome://gpu,搜索"Video Acceleration Information" - 打开
chrome://media-internals播放HEVC视频 - 在Mac上打开活动监视器搜索
VTDecoderXPCService - 在Windows上打开任务管理器查看GPU利用率
通过本指南,您可以全面了解HEVC硬件解码与编码在Chromium项目中的实现细节,并根据具体需求选择适合的配置方案。
【免费下载链接】enable-chromium-hevc-hardware-decodingA 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.项目地址: https://gitcode.com/gh_mirrors/en/enable-chromium-hevc-hardware-decoding
创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考