9

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?

Luboš Turek
  • 6,273
  • 9
  • 40
  • 50
noober
  • 4,819
  • 12
  • 49
  • 85

6 Answers6

10

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.

Eugen
  • 537
  • 6
  • 14
Emerick Rogul
  • 6,706
  • 3
  • 32
  • 39
6

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).

Eugen
  • 537
  • 6
  • 14
zah
  • 5,314
  • 1
  • 34
  • 31
  • would you tell me how can I compile this for Delphi XE2? I don't know what should I do exactly! – Kermia Aug 22 '13 at 07:15
  • 1
    Well, these are instructions for rebuilding CEF itself. Once you've done this, you will just use your build in Delphi as a drop-in replacement for the standard binary distribution. – zah Aug 22 '13 at 10:59
  • Thanks, Do you mean I should replace `dll` files only? – Kermia Aug 22 '13 at 11:14
  • Can you please send the compiled binary files to me? – Kermia Aug 24 '13 at 12:22
  • 2
    Sorry, I've done this a while ago and I don't have up-to-date binaries. Also, you should not accept binaries from strangers :) It's true that setting up a Chromium build is rather complicated, but if you follow the instructions at the linked pages, you should be fine. – zah Aug 24 '13 at 15:52
6

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

null1941
  • 972
  • 8
  • 20
  • 1
    need to install cmake also :) – null1941 Apr 11 '16 at 08:48
  • I tried to follow this instruction (Windows 10 / VS 2015) but no joy. Making chromium just returned super helpful "returned with code 1" error and I have no idea where to go now. I have all prerequisites, as instructed. Followed the instruction exactly. Is there an easier option? – Harry May 19 '16 at 12:47
  • Now I got to the point 16g: 'Get-Content : Cannot find path 'B:\Downloads\cef-binary-master\cef-binary-master\cef_binary_3.2704.1414.g185cd6c_windows32\libcef_dll\libcef_dll_wrapper.vcxproj' because it does not exist.' – Harry May 21 '16 at 13:15
  • are you successful in 14 th step? – null1941 May 22 '16 at 14:08
  • Yes, I got very similar output. I searched the files and I found something like "make_projects.bat" (I don't have those files anymore). Project files were generated, but not placed in correct folders. I moved them myself, but it didn't work anyway. I got another error. I'm going to start all process from the start, but Chromium will take circa 8 hours to compile so I left it as a last part of my project. – Harry May 26 '16 at 13:54
  • At the top of your answer you mentioned having to change cef.gypi file, but I don't see that mentioned in any of the subsequent steps, is that missing? or not needed? or? thanks for any help – Jared Wilkin Jun 14 '16 at 18:08
  • @JaredWilkin Step 7 is that one. It sets cef gypi variables which are required to enable Proprietary codecs. https://bitbucket.org/chromiumembedded/cef/src/52f9aacdf556b3f41ed6c12cff63d0686eff1275/cef.gypi?at=master&fileviewer=file-view-default – null1941 Jun 16 '16 at 01:37
  • @null1941 thanks for the info... I followed all the steps was was successful in building cefsharp with support for mp3 and mp4 but had a couple of hiccups not addressed by your steps (all having to do with the build powershell script). probably they have changed it since... I have added the extra stuff I had to do to an additional answer – Jared Wilkin Jun 16 '16 at 15:49
  • Hi I followed all the steps and was successfully able to build mp3 codecs. I am running into a problem where after compiling new cef binary into cefsharp I try to use the dll in my project but I dont see mp3 support in my project. Also my project depends on a library which bring CefSharp 55.0.0 as a dependency. Can somebody suggest what can I do. – user2358262 Jul 02 '17 at 18:11
3

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
Eugen
  • 537
  • 6
  • 14
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - [From Review](/review/low-quality-posts/16900607) – robinCTS Aug 01 '17 at 20:49
  • i added all details from the link. since its a SO link, i was assuming it will "never die" ... – Eugen Aug 01 '17 at 21:13
  • @Eugen Never assume a link won't change or be removed eventually. For SO alone, flags can be made, questions can be deleted, and outside edits can be made; all of which could result in your answer on that link being different from the expected, or being removed altogether. – yanman1234 Aug 03 '17 at 17:26
1

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.

aufula
  • 140
  • 2
  • 6
1

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
Jared Wilkin
  • 231
  • 3
  • 12