Chromium 嵌入式框架 MP3 支持

发布于 2024-12-13 19:01:26 字数 342 浏览 1 评论 0 原文

我已经下载了适用于 Windows 的 Chromium Embedded Framework r306 并构建了它。不幸的是,它显示它不支持 mp3:

<script>
var a = document.createElement("audio");
document.write(a.canPlayType('audio/mpeg'));
</script>

输出为空,当我尝试打开 mp3 文件时,它无法播放(ogg 是可播​​放的)。

与此同时,谷歌浏览器会写出“也许”(并且它实际上会播放)。

如何在 CEF 中添加对 MP3 的支持?

I've downloaded Chromium Embedded Framework r306 for Windows and built it. Unfortunately, it shows, that it doesn't support mp3:

<script>
var a = document.createElement("audio");
document.write(a.canPlayType('audio/mpeg'));
</script>

Output is empty and when I try to open an mp3 file, it can't be played (ogg is playable).

The same time Google Chrome writes "maybe" (and it actually plays).

How can I add support for MP3 in CEF?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

静待花开 2024-12-20 19:01:26

Marshall Greenblatt(Chromium 嵌入式框架的维护者)解决了缺乏对 MP3(和 AAC)支持的问题)在 Chromium 和 CEF 中 此错误报告(请参阅评论#7,复制如下):

MP3 和 AAC 等编解码器包含在 Google Chrome 版本中,但不包含在 Chromium 版本中。这是因为这些格式不开放并且需要许可。在没有许可协议的情况下将这些编解码器与您的应用程序一起分发可能会违反某些国家/地区的法律。如果合适,您应该与律师讨论。

Marshall Greenblatt (the maintainer of the Chromium Embedded Framework) addresses the lack of support for MP3 (and AAC) in Chromium and CEF in this bug report (see comment #7, copied below):

Codecs like MP3 and AAC are included in Google Chrome releases but not Chromium builds. This is because these formats are not open and require licensing. Distributing these codecs with your application without a licensing agreement may violate the law in certain countries. You should discuss with a lawyer if appropriate.

勿忘心安 2024-12-20 19:01:26

注意:在继续操作之前请考虑法律问题

有一种方法可以在 CEF 中启用 MP3 支持,但您必须修改源代码分发中的 cef.gypi,重新生成 Visual Studio 项目并重建。

分步说明:

在此处输入图像描述
输入图像描述这里
a在此处输入图像描述
输入图像描述这里
a在此处输入图像描述
输入图像描述这里

NOTE: PLEASE CONSIDER LEGAL ISSUES BEFORE PROCEEDING

There is a way to enable MP3 support in CEF, but you'll have to modify the cef.gypi in the source distribution, regenerate the visual studio projects and rebuild.

Step by step instructions:

enter image description here
enter image description here
aenter image description here
enter image description here
aenter image description here
enter image description here

提笔落墨 2024-12-20 19:01:26

有一种方法可以在 CEF 中启用 MP3 支持,但您必须修改源代码分发中的 cef.gypi,重新生成 Visual Studio 项目并重建。

详细构建说明:
https://bitbucket.org/chromiumembedded/cef/wiki/BranchesAndBuilding

启用专有编解码器支持:
http://code.google.com/p/chromiumembedded/issues/详情?id=371

将 'proprietary_codecs': 1 添加到您的 cef.gypi 配置中,以便根据 net/base/mime_util.cc 的要求定义 USE_PROPRIETARY_CODECS。

您还需要正确构建 avcodec、avformat 和 avutil DLL。幸运的是,您可以从 Google Chrome 本身的安装目录($User/AppData/Local/Google/Chrome/$Version)获取这些内容。

There is a way to enable MP3 support in CEF, but you'll have to modify the cef.gypi in the source distribution, regenerate the visual studio projects and rebuild.

Detailed build instructions:
https://bitbucket.org/chromiumembedded/cef/wiki/BranchesAndBuilding

Enabling proprietary codecs support:
http://code.google.com/p/chromiumembedded/issues/detail?id=371

Add 'proprietary_codecs': 1 to your cef.gypi configuration so that USE_PROPRIETARY_CODECS will be defined as required by net/base/mime_util.cc.

You'll also need proper builds of the avcodec, avformat and avutil DLLs. Luckily, you can just get these from the installation directory of Google Chrome itself ($User/AppData/Local/Google/Chrome/$Version).

萌酱 2024-12-20 19:01:26

自上次回答以来,启用专有编解码器(即 H.264 和 MP3)的选项已被移动。

您可以阅读我的答案,其中包含有关如何使用启用的专有编解码器编译CEF的所有详细

信息魔法现在发生在这里:

set GN_DEFINES=is_official_build=true proprietary_codecs=true ffmpeg_branding=Chrome

有 2 个批处理文件您应该更新/创建(如发现此处):

c: \code\chromium_git\update.bat:

set CEF_USE_GN=1
set GN_DEFINES=is_official_build=true proprietary_codecs=true ffmpeg_branding=Chrome
set GN_ARGUMENTS=--ide=vs2015 --sln=cef --filters=//cef/*
python ..\automate\automate-git.py --download-dir=C:\code\chromium_git --depot-tools-dir=C:\code\depot_tools --no-distrib --no-build

c:\code\chromium_git\chromium\src\cef\create.bat:

set CEF_USE_GN=1
set GN_DEFINES=is_win_fastlink=true proprietary_codecs=true ffmpeg_branding=Chrome
set GN_ARGUMENTS=--ide=vs2015 --sln=cef --filters=//cef/*
call cef_create_projects.bat

有2 篇 wiki 文章解释了如何构建 CEF/Chromium:

  1. https://bitbucket.org/ chromiumembedded/cef/wiki/MasterBuildQuickStart.md
  2. BranchesAndBuilding 在同一 wiki 中

the options to enable proprietary codecs (i.e. H.264 and MP3) have been moved since the last answer.

you can read my answer with all the details on how to compile CEF with enabled proprietary codecs

the magic now happens here:

set GN_DEFINES=is_official_build=true proprietary_codecs=true ffmpeg_branding=Chrome

there is 2 batch files that you should update/create (as found here):

c:\code\chromium_git\update.bat:

set CEF_USE_GN=1
set GN_DEFINES=is_official_build=true proprietary_codecs=true ffmpeg_branding=Chrome
set GN_ARGUMENTS=--ide=vs2015 --sln=cef --filters=//cef/*
python ..\automate\automate-git.py --download-dir=C:\code\chromium_git --depot-tools-dir=C:\code\depot_tools --no-distrib --no-build

c:\code\chromium_git\chromium\src\cef\create.bat:

set CEF_USE_GN=1
set GN_DEFINES=is_win_fastlink=true proprietary_codecs=true ffmpeg_branding=Chrome
set GN_ARGUMENTS=--ide=vs2015 --sln=cef --filters=//cef/*
call cef_create_projects.bat

There is 2 wiki articles that explain how to build CEF/Chromium:

  1. https://bitbucket.org/chromiumembedded/cef/wiki/MasterBuildQuickStart.md
  2. and BranchesAndBuilding in the same wiki
も让我眼熟你 2024-12-20 19:01:26

仅支持 MP3 编解码器构建 Google Chrome 时,请检查 chromium 的编解码器支持

在客户端,兼容方式可能是Flash,查看google翻译的代码。

MP3 codec only be supported When build to Google Chrome, check chromium's Codec Support.

On client side, the compatible way may be Flash, check google translate's code.

梦开始←不甜 2024-12-20 19:01:26

我按照 null1941 的答案中的步骤操作,除了与修改 build.ps1 脚本有关的一些注意事项之外,它们工作得很好

step 16 e. search for any instances of 3.y.z and replace them with the current version you are building (from the folder name containing the builds ex. 3.2272.32.gbda8dc7).  

in function DownloadNuget it is trying to see if you have nuget in a specific place and if it isn't there it tries to go get it.  Problem is DownloadFile would fail if the save directory didn't already exist. so you can manualy create or add this to the function:
    $Nuget_dir = Join-Path $env:LOCALAPPDATA .\nuget
    if(-not (Test-Path $Nuget_dir))
    {
        mkdir $Nuget_dir
    }

change line: "Copy-Item $Cef64\include $CefInclude -Recurse | Out-Null" to use $Cef32 if you don't have 64bit cef folders

I followed the steps in null1941's answer and they worked great save a few caveats having to do with modifying the build.ps1 script

step 16 e. search for any instances of 3.y.z and replace them with the current version you are building (from the folder name containing the builds ex. 3.2272.32.gbda8dc7).  

in function DownloadNuget it is trying to see if you have nuget in a specific place and if it isn't there it tries to go get it.  Problem is DownloadFile would fail if the save directory didn't already exist. so you can manualy create or add this to the function:
    $Nuget_dir = Join-Path $env:LOCALAPPDATA .\nuget
    if(-not (Test-Path $Nuget_dir))
    {
        mkdir $Nuget_dir
    }

change line: "Copy-Item $Cef64\include $CefInclude -Recurse | Out-Null" to use $Cef32 if you don't have 64bit cef folders
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文