Rexdf

The devil is in the Details.

Chromium编码器问题

| Comments

本文记录chromium编译遇到的问题。 Windows上的Chrome浏览器一直都用着一个自己编译的版本。然而最近几个月的编译发现了Twitter的视频似乎没法播放,而Youtube的视频依然是正常的。

问题解决

The media could not be played

如上图所示。 搜索了一圈,尝试了重置浏览器(重新指定一个cache目录)和修改chrome://about似乎都没效果。

但是编译的时候有报一个错误’use_h254’编译选项未定义。那就变有什么编码器不支持了。然后搜了下确实现在默认不带h254的解码器了。但是用proprietary_codecs = true就可以再次启用。

Twitter video

编译配置

下面这个配置是我2015年写的一个自动化脚本,大概一直用到现在2021年,中间可能有几次优化,但是大体上都是2015年那会写的。

首先假设下面的目录树在某个目录,那么其上一级目录要有depot_tools文件夹,然后把如下内容填入。按照如下笔记拖下源码。这个大概20~30分钟就好了。

更新工具链
gclient runhooks
出现问题时使用:
git reset --hard origin/master
更新代码
git rebase-update
gclient sync

目录结构

│ _begin_to_work_x64.bat
├─build_result
├─chromium
│ build.bat
│ buildx64_2.bat
│ buildx86_2.bat
└─src
└─out
├─mybuild
│ args.gn
└─mybuild86
args.gn

_begin_to_work_x64.bat

@echo off
chcp 437
cd /d %~dp0chromium
rem call ..\setup_and_clean.bat
set str=%~dp0
path=%str%..\depot_tools;%path%
set DEPOT_TOOLS_WIN_TOOLCHAIN=0
rem set NO_AUTH_BOTO_CONFIG=%~dp0boto.cfg
rem %comspec% /k "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64
%comspec% /k "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat"

build.bat

@echo off
cd /d %~dp0src
set path=%~dp0..\..\depot_tools;%path%
set DEPOT_TOOLS_WIN_TOOLCHAIN=0
set VERSION_NUMVER=91.0.4432.1
if exist out (
rd /s /q out
)
xcopy %~dp0..\src %~dp0src /E /I /s
call gn gen out/mybuild64 --ide=vs
call gn gen --ide=vs --filters=//chrome out/Default64
call gn gen out/mybuild
call gn gen out/mybuild86
if not exist ..\..\build_result\%VERSION_NUMVER% (
mkdir ..\..\build_result\%VERSION_NUMVER%
)
if not exist ..\..\build_result\%VERSION_NUMVER%\x86 (
mkdir ..\..\build_result\%VERSION_NUMVER%\x86
)
if not exist ..\..\build_result\%VERSION_NUMVER%\x86\chrome.packed.7z (
call ..\buildx86_2.bat %VERSION_NUMVER%
)
if not exist ..\..\build_result\%VERSION_NUMVER%\x64 (
mkdir ..\..\build_result\%VERSION_NUMVER%\x64
)
if not exist ..\..\build_result\%VERSION_NUMVER%\x64\chrome.packed.7z (
call ..\buildx64_2.bat %VERSION_NUMVER%
)
rem shutdown -s -t 600
pause

buildx64_2.bat

@echo off
cd /d %~dp0src
set path=%~dp0..\..\depot_tools;%path%
set DEPOT_TOOLS_WIN_TOOLCHAIN=0
if [%1]==[] goto error
ninja -C out/mybuild chrome
ninja -C out/mybuild chromedriver
ninja -C out/mybuild mini_installer
for %%i in (chrome.packed.7z,chromedriver.exe,mini_installer.exe,setup.exe) do (
if exist out\mybuild\%%i (
copy out\mybuild\%%i ..\..\build_result\%1\x64\
)
)
REM copy out\mybuild\chrome.packed.7z ..\..\build_result\%1\x64\
REM copy out\mybuild\chromedriver.exe ..\..\build_result\%1\x64\
REM copy out\mybuild\setup.exe ..\..\build_result\%1\x64\
ninja -C out/mybuild -t graph all > ..\..\build_result\%1\deps.dot
ninja -C out/mybuild -t targets > ..\..\build_result\%1\targets.txt
if [%2] neq [] (
rd /s /q out\mybuild
)
echo Done.
GOTO :EOF
:error
echo Need a version number.

buildx86_2.bat

@echo off
cd /d %~dp0src
set path=%~dp0..\..\depot_tools;%path%
set DEPOT_TOOLS_WIN_TOOLCHAIN=0
if [%1]==[] goto error
ninja -C out/mybuild86 chrome
ninja -C out/mybuild86 chromedriver
ninja -C out/mybuild86 mini_installer
for %%i in (chrome.packed.7z,chromedriver.exe,mini_installer.exe,setup.exe) do (
if exist out\mybuild86\%%i (
copy out\mybuild86\%%i ..\..\build_result\%1\x86\
)
)
REM copy out\mybuild86\chrome.packed.7z ..\..\build_result\%1\x86\
REM copy out\mybuild86\chromedriver.exe ..\..\build_result\%1\x86\
REM copy out\mybuild86\mini_installer.exe ..\..\build_result\%1\x86\
if [%2] neq [] (
rd /s /q out\mybuild86
)
echo Done.
GOTO :EOF
:error
echo Need a version number.

mybuild\args.gn

# Build arguments go here.
# See "gn args <out_dir> --list" for available build arguments.
# enable_nacl = false
ffmpeg_branding = "Chrome"
is_component_build = false
is_debug = false
is_official_build = true
# proprietary_codecs = true
# remove_webcore_debug_symbols = true
rtc_use_h264 = true
symbol_level = 1
blink_symbol_level = 1
# syzygy_optimize = true
# use_jumbo_build = true
media_use_ffmpeg = true
media_use_libvpx = true
proprietary_codecs = true
# use_openh264 = true
google_api_key = "no"
google_default_client_id = "no"
google_default_client_secret = "no"
#x64_arch = "skylake-avx512"

mybuild86\args.gn

# Build arguments go here.
# See "gn args <out_dir> --list" for available build arguments.
enable_nacl = false
ffmpeg_branding = "Chrome"
is_component_build = false
is_debug = false
is_official_build = true
proprietary_codecs = true
#remove_webcore_debug_symbols = true
rtc_use_h264 = true
symbol_level = 1
blink_symbol_level = 1
# syzygy_optimize = true
media_use_ffmpeg = true
media_use_libvpx = true
proprietary_codecs = true
# use_openh264 = true
# use_jumbo_build = true
target_cpu = "x86"
google_api_key = "no"
google_default_client_id = "no"
google_default_client_secret = "no"

额外的笔记

生成编译文件目录
gn gen out/Default
配置编译参数
gn args out\mybuild
列出全部参数
gn args out\mybuild --list
编译
ninja -C out/Default chrome
ninja -C out/mybuild86 chrome && ninja -C out/mybuild chrome
参数
is_component_build = false
is_debug = false
symbol_level = 0
enable_nacl = false
remove_webcore_debug_symbols = true
use_openh264 = true
rtc_use_h264 = true
ffmpeg_branding = "Chrome"
#这个参数会导致错误
enable_wifi_display = true
syzygy_optimize = true
#这个一般不需要
is_win_fastlink = true
#32位的加一行
target_cpu = "x86"
google_api_key = "no"
google_default_client_id = "no"
google_default_client_secret = "no"

编译消耗

chrome编译似乎给100GB内存,32独占物理核,编译依然是2小时左右,时间和我笔记本32GB-8750H时间差不多。不像firefox只要20分钟就能编译完成,似乎远远快于笔记本。

磁盘嘛,一个版本大概50GB,给足100GB笔记满足,如果像我上面脚本一样要编译x86和x64大概需要200GB-300GB的磁盘剩余空间。

ESXI Chromium build

参考资料

  1. Building chromium on OSX
  2. The free and open-source project behind Google Chrome
  3. Checking out and Building Chromium for Windows

Comments