Enabling Proprietary Audio/Video Codecs in NW.js

November 1, 2017 Jean-Philippe Côté
published in

Due to licensing issues, NW.js cannot play files encoded with proprietary formats (such as H.264 and AAC) out of the box. However, there is a quick and easy workaround to that problem. This article will tell you what it is.

A bit of background

[TLDR: If you just want the solution, just skip ahead to the step by step recipe.]

NW.js is based on Chromium. Chromium is the open source base off of which Google Chrome is built. The open nature of Chromium forbids it to include support for proprietary codecs and demuxers. This means that the support for codecs in Chromium (and NW.js) is more limited than it is in Google Chrome. 

Out of the box, Chromium/NW.js provides supports for the following audio and video codecs:

These codecs can be used within the following multimedia containers:

  • Ogg (.ogv, .oga)
  • Matroska (.mkv)
  • WebM (.webm)
  • Waveform Audio File Format (.wav)

Support for the above codecs and demuxers is provided by FFmpeg. The FFmpeg library can be compiled in various ways. One such way excludes all proprietary codecs. This is how it’s built by default for NW.js.

So, to include additional codecs, you would have to recompile FFmpeg with the appropriate options. However, recompiling software can be a complex proposition. Fortunately for us, a good soul has been doing that for each new version of NW.js that comes out.


So, here are the steps to go through to expand codec/container support in NW.js:

  1. Go to: https://github.com/iteufel/nwjs-ffmpeg-prebuilt/releases
  2. Download the zip that matches your version of NW.js and target architecture (32bit or 64bit)
  3. Unzip the package. 
  4. Grab the ffmpeg.dll (Windows), libffmpeg.dylib (Mac) or libffmpeg.so (Linux) and overwrite the one found in the NW.js application folder:
    • On Windows, the ffmpeg.dll file to overwrite is right at the root of the folder.
    • On Mac, you have to right-click on nwjs.app and select Show Package Contents. This will allow you to navigate to and overwrite Contents/Versions/xx.xx.xx/libffmpeg.dylib.
    • On Linux, the file to overwrite is lib/libffmpeg.so.

That’s it! Once you have done that, you should be able to play these additional types of content without issues:

  • H.264
  • AAC
  • MP3 (if you had a version older than 0.22.1)

You will also be able to use additional multimedia containers:

  • MP4 (.mp4 & .m4a)
  • QuickTime (.mov)

If you so wish, you can also recompile FFmpeg yourself. You will find a simple script (and platform-specific instructions) on GitHub. You can also find more information on this topic in the NW.js documentation.

Final notes

You should note that the ability to play back a proprietary codec does not dispense you to comply with its licensing terms. Here are some pointers for the most popular codecs:

  • H.264: before using it, you should check out the H.264 licensing terms on the MPEG-LA website;
  • AACper the license, unless you are creating an AAC encoder or decoder, you should be able to distribute AAC-encoded content without having to pay any fees;
  • MP3: on April 27, 2017, the need to get a license from Technicolor and/or The Fraunhoffer IIS has been lifted. So, NW.js now includes support for MP3 decoding in its binary. The method described in this article still applies for older versions of NW.js that didn’t have built-in support (prior to version 0.22.1).

As of this writing, Chromium still does not include native support for MP3. NW.js has to use its own build of FFmpeg to support it.

You can get more information about the FFmpeg licensing terms on their website. Beware that this article does not contain legal advice. For the final word on licensing, you should consult a specialist.


  • pepe

    Good morning Mr. Jean-Philippe I read on your page about Enabling audio / video codecs owners in NW.js, I would like to ask you a simple question that can help me a lot, I developed a game with nw.js, and to play the audio I’ll use WAV (windows PCM) format, I don´t now if I have to use ffmpeg, because wav is a uncompressed format, then maybe is not necessary use ffmpeg, I need to be sure because the application will work in Windows 7,8 and 10 with 32 and 64, the application will be sell and it’s not free, I can´ t make a mistake with this. If you help me with this doubt I’ll be very grateful, thank you…

  • Jean-Philippe Côté

    Usually (but not necessarily), WAV files use PCM audio. This means that they should work without issues in NW.js on the listed platform. However, to be sure, you will have to do your own testing. Cheers!

  • Thomas

    Hallo Jean-Philippe,

    is it possible to include the mpeg2video codec to the ffmpeg.dll ? Mayby someone could link to a precompiled version.

    Thanks a lot


  • Thomas

    Many thanks for quick reply.

    i found the patch on  https://github.com/iteufel/nwjs-ffmpeg-prebuilt/blob/master/patch/win/build_ffmpeg_proprietary_codecs.patch

    where the mpeg2video would be needed to be added.
    But sadly, i’m to capable to compile.


    Hi Jean-Philippe

    This is working perfectly for development environment(npm run devmac). If we are building for production using nwbuild(npm run prodwin), it is not working. Can you help me on this.
    These are the starting scripts we are using
    “scripts”: {
    “devmac”: “nw release/”,
    “prodmac”: “nwbuild –platforms osx64 –buildDir dist/ release/”,
    “prodwin”: “nwbuild –platforms win64 –buildDir dist/ release/”,
    “dev”: “webpack-dev-server –inline –progress –config build/webpack.dev.conf.js”,
    “start”: “npm run dev”,
    “build”: “node build/build.js”

  • Sudharsan

    Thanks – Saved our day – Still helps in 2021

Post a comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.