Using MP3 & MP4 (H.264) using the video & audio tags.

JPL42 edited this page Dec 30, 2016 · 6 revisions
Clone this wiki locally

NOTE: some content in this wiki applies only to 0.12 and earlier versions. For official documentation on 0.13 and later, see

Due to licensing issues, the pre-built binary doesn't ship with the necessary codecs for patented media formats. If you require support for these formats, see the instructions below.

Consult a lawyer if you do not understand the licensing constraints and require patented media formats in your application.


In the pre-built libffmpegsumo.dll, the following codecs are supported:


The following demuxers are supported:


As nw.js is based on Chromium, the media components are essentially the same. In order to use MP3 and H.264, you'll need to compile ffmpeg with corresponding options. (Please note that MP3 and H.264 codecs are licensed under the GPL in ffmpeg).

Alternatively, you can try to use the media libraries from Chrome. It has been reported to work, but it hasn't been properly tested, so it may or may not work for you in latest version.

Warning: linking code licensed under the GPL code requires you to license your code under the GPL as well


You will need files from the matching Chrome version. (For example, 0.6.x is based on Chromium 28)

  1. Locate the Chrome\Application folder (e.g. C:\Program Files\Google)

  2. Copy ffmpegsumo.dll to your nw.js distribution directory.


The directory location may vary according to the Linux distribution you are using. Under Ubuntu, it's located at /opt/google/chrome. Copy to the nw.js folder.


Head to your Applications folder and right-click on Google Chrome. Select Show Package Contents and navigate to Versions > Most recent # > Framework > Libraries.

Copy to Framework.framework/Libraries/.

Build it Yourself

If you are building nw.js, open src/third_party/ffmpeg/chromium/scripts/, and search around line 379 for the following directives:

# Google Chrome & ChromeOS specific configuration.
add_flag_chrome --enable-decoder=aac,h264,mp3
add_flag_chrome --enable-demuxer=mp3,mov
add_flag_chrome --enable-parser=aac,h264,mpegaudio

Change them to:

add_flag_common --enable-decoder=aac,h264,mp3
add_flag_common --enable-demuxer=mp3,mov
add_flag_common --enable-parser=aac,h264,mpegaudio

Then follow the short directions here:

You'll also need to patch the ffmpeg repo (or define the branding gyp variable to Chrome, untested)

diff --git a/ffmpeg.gyp b/ffmpeg.gyp
index ac059f0..1b0424c 100644
--- a/ffmpeg.gyp
+++ b/ffmpeg.gyp
@@ -54,7 +54,7 @@
       ['chromeos == 1', {
         'ffmpeg_branding%': '<(branding)OS',
       }, {  # otherwise, assume Chrome/Chromium.
-        'ffmpeg_branding%': '<(branding)',
+        'ffmpeg_branding%': 'Chrome',


You'll also need to turn on the resource loader's support in Chromium's code, or your format will be treated as a non standard d MIME type and won't be loaded. See src/net/base/ for more. You might also want to look into code in other files guarded by the 'USE_PROPRIETARY_CODECS' macro.


the 'USE_PROPRIETARY_CODECS' macro can be done by setting 'proprietary_codecs%': 1 in file build/common.gypi