jcef 使用的cef动态库是不支持MP4播放的,只支持完全开源的ogg格式,若要能播放MP4需要对 cef进行重新编译
撰写本文时,jcef最新版本用到的cef版本是88,官网最新的已经到91了,我们只能去编译jcef配套的88版本,以免出现兼容性问题和浪费时间。编译一次cef太费时间。
编译环境
1.windows 10 专业版 20H2,I79750H,64GB RAM, 2T NVME SSD
2.ninja
3.cmake
4.visual studio 2019 community
5.300M宽带
6.忍者VPN,class for windows 安装 cft-tap 网卡,将流量全部从此网卡转发,免去配各种代理的麻烦
7.python 2.7+ 以上
ninja、cmake、python 的可执行文件添加到path
开始编译
步骤基本参考官网
创建文件夹
文件夹的名称不要包含特殊字符和除ASCII字符以外的字符,总体长度不要超过35,所在磁盘空闲空间最好有400GB
c:\code\automate
c:\code\chromium_git
下载depot_tools
https://storage.googleapis.com/chrome-infra/depot_tools.zip
将 depot_tools.zip复制到 c:\code 下,winrar 解压到 depot_tools 文件夹
下载自动脚本 automate-git.py
最好选择从对应的要编译的分支的目录去下载这个脚本,我比较了88和master(91)文件并没有区别
https://bitbucket.org/chromiumembedded/cef/raw/master/tools/automate/automate-git.py
将下载的文件复制到 c:\code\automate 下
新建 构建脚本 update.bat
#不构建debug版本,节约时间
--no-debug-build
#MP4支持的重要设置
set GN_DEFINES=is_official_build=true proprietary_codecs=true ffmpeg_branding=Chrome
GYP_DEFINES=buildtype=Official
#构建88版本,如果构建master,此参数可不写
--branch=4324
#执行构建
--force-build
构建32位版本
set CEF_USE_GN=1
set GN_DEFINES=is_official_build=true proprietary_codecs=true ffmpeg_branding=Chrome
set GYP_DEFINES=buildtype=Official
set GYP_MSVS_VERSION=2019
set CEF_ARCHIVE_FORMAT=tar.bz2
set GN_ARGUMENTS=--ide=vs2019 --sln=cef --filters=//cef/*
python ..\automate\automate-git.py --download-dir=c:\code\chromium_git --depot-tools-dir=c:\code\depot_tools --force-build --minimal-distrib --client-distrib --branch=4324 --no-debug-build
构建 64 位版本
set CEF_USE_GN=1
set GN_DEFINES=is_official_build=true proprietary_codecs=true ffmpeg_branding=Chrome
set GYP_DEFINES=buildtype=Official
set GYP_MSVS_VERSION=2019
set CEF_ARCHIVE_FORMAT=tar.bz2
set GN_ARGUMENTS=--ide=vs2019 --sln=cef --filters=//cef/*
python ..\automate\automate-git.py --download-dir=c:\code\chromium_git --depot-tools-dir=c:\code\depot_tools --force-build --x64-build --minimal-distrib --client-distrib --branch=4324 --no-debug-build
打开cmd窗口,执行update.bat 脚本
等待构建完成,大概要24小时左右。构建完成,构建物在目录c:\code\chromium_git\chromium\src\cef\binary_distrib
下
测试
构建生成目录
c:\code\chromium_git\chromium\src\cef\binary_distrib下的win32 client,打开client.exe,输入有mp4的url,发现可以播放mp4了
将win32 client 下的动态库替换jcef构建包里的动态库,jcef with mp4 support ready.
本博客所有文章除特别声明外,均采用 CC BY-SA 3.0协议 。转载请注明出处!