Firefox Development Highlights – H.264 & MP3 support on Windows, scoped stylesheets + more

Time for the first look this year into the latest developments with Firefox. This is part of our Bleeding Edge and Firefox Development Highlights series, and most examples only work in Firefox Nightly (and could be subject to change).

H.264 & MP3 support on Windows

Firefox for Android and Firefox OS already support H.264 and MP3. We are also working on bringing these formats to Firefox Desktop. On Windows 7 and above, you can already test it by turning on the preference media.windows-media-foundation.enabled in about:config. Decoding is done on the OS side (no decoder included in Firefox source code, not like WebM or Ogg Theora). For Linux and Mac, work is in progress.

The new Downloads panel has been enabled

We have now enabled the new Downloads panel:

Scoped style attribute

It’s now possible to define scoped style elements. Usually, when we write a stylesheet, we use <style>...</style>, and CSS code is applied to the whole document. If the <style> tag is nested inside a node (let’s say a <div>), and the <style> tag includes the scoped attribute (<style scoped>), then the CSS code will apply only to a subtree of the document, starting with the parent node of the <style> element. The root of the subtree can also be referred via the :scope pseudo-class.

Demo

Scoped style demo support on JS Bin.

Our friends over at HTML5Rocks have also written about it in A New Experimental Feature: scoped stylesheets.

@supports and CSS.supports

In Firefox 17, we shipped the @supports CSS at-rule. This lets you define specific CSS code only if some features are supported. For example:

@supports not (display: flex) {
  /* If flex box model is not supported, we use a different layout */
  #main {
      width: 90%;
  }
}

In Firefox 20, it’s now possible to do the same thing, but within JavaScript:

if (CSS.supports("display", "flex")) {
  // do something relying on flexbox
}

About Paul Rouget

Paul is a Firefox developer.

More articles by Paul Rouget…

About Robert Nyman [Editor emeritus]

Technical Evangelist & Editor of Mozilla Hacks. Gives talks & blogs about HTML5, JavaScript & the Open Web. Robert is a strong believer in HTML5 and the Open Web and has been working since 1999 with Front End development for the web - in Sweden and in New York City. He regularly also blogs at http://robertnyman.com and loves to travel and meet people.

More articles by Robert Nyman [Editor emeritus]…


34 comments

  1. Skoua

    Nice!
    So you guys decided to support H264 by relying on the OS?

    January 23rd, 2013 at 09:06

    1. Robert Nyman

      Yep!

      January 23rd, 2013 at 13:23

      1. pd

        and for us XP users?

        February 13th, 2013 at 09:50

        1. Robert Nyman [Editor]

          It’s being discussed in the bug. Hopefully there will be XP support as well.

          February 14th, 2013 at 05:39

          1. pd

            Thanks for the link.

            February 20th, 2013 at 04:30

      2. AK

        And for Mac users.

        April 8th, 2013 at 19:47

  2. Fawad Hassan

    Is @supports standard feature or browser specific?

    January 23rd, 2013 at 10:48

    1. Robert Nyman

      Standard, and I believe it matches the supports(method) in the specification.

      January 23rd, 2013 at 13:38

  3. Dan Forman

    Hey, please enable native codec support on XP and Vista!

    January 23rd, 2013 at 14:16

    1. Robert Nyman

      And with that, you mean built-in support in Firefox? There are a number of licensing and other issues with that, hence going with the decision for now to go with what’s available in the operating system.

      January 23rd, 2013 at 14:51

      1. Dan Forman

        No, I mean just enable playback using native codecs installed on the system, just as with Windows 7. If users (or some app) installs them, just use them, no reason not to..

        January 23rd, 2013 at 15:26

        1. Robert Nyman

          Ah, ok. Well, I believe that is what will happen for other OS versions (then of course, there might be some issues related to that, but still).

          January 23rd, 2013 at 15:49

  4. Arno

    What container formats will this enable? MPEG-TS i.e., live streaming too?

    January 25th, 2013 at 08:54

    1. Robert Nyman [Editor]

      As I understand it, streaming should be supported, but I’m not sure about container formats. There’s a lot of info if you are interested in the implementation bug for it.

      January 25th, 2013 at 14:26

      1. Arno

        No MPEG-TS, which means no “commercial” live streaming basically :o(

        Timestamp: 01/02/2013 13:46:26
        Warning: HTTP “Content-Type” of “video/mp2t” is not supported. Load of media resource http://127.0.0.1:8192/e5a12c7ad2d8fab33c699d1e198d66f79fa610c3.-1 failed.

        I’ll report on the bug page.

        February 1st, 2013 at 05:50

        1. Robert Nyman [Editor]

          Right, too bad. And thanks, please do!

          February 1st, 2013 at 06:40

  5. John A. Bilicki III

    If Internet Explorer and Safari refuse to support standard free and open codecs why the hell is Mozilla working to implement license burdened codecs in Firefox?

    #massive_fail

    February 1st, 2013 at 05:29

    1. Robert Nyman [Editor]

      To begin with, we don’t implement the codec support, we utilize what’s available in the OS. When it comes to the reasoning, please read Video, Mobile, and the Open Web.

      Firefox is basically the only major web browser NOT supporting H.264, and unfortunately we don’t have enough leverage to make all the other web browsers and major video service providers change.

      February 1st, 2013 at 06:43

      1. John A. Bilicki III

        According to my statistics for December 2012 78.57% of my visitors have browsers that support free and open codecs…
        http://www.jabcreations.com/blog/december-2012-browser-market-share

        …and unlike any other statistics I’ve ever seen mine are based on DOM detection, not user agents.

        A standard can never be charged, licensed or in any way be used to gain money otherwise it’s not a standard, period.

        February 1st, 2013 at 06:53

        1. Robert Nyman [Editor]

          That’s great for you. But that doesn’t necessarily mean that that a) applies to all web sites out there, and b) that the most popular video services will support open formats.

          I don’t see this as a standard, more of a de-facto video format as of right now.

          February 1st, 2013 at 07:03

  6. AK

    When is it coming to OSX?

    February 10th, 2013 at 00:01

    1. Robert Nyman [Editor]

      I can’t say more about the timing for that at the moment.

      February 12th, 2013 at 03:27

  7. Matt

    Does anyone know if the h.264 support applies to webRTC conferences too?

    February 20th, 2013 at 14:20

    1. Robert Nyman [Editor]

      No, WebRTC is based on the VP8 codec.

      February 21st, 2013 at 01:26

  8. MG

    I’ve seen all the google about H.264 discussion on firefox that firefox has it bla bla bla, … … …

    more than 100 pages of thios crap and non of how to install it on it

    HOW DA FAK DO I GET IT ON MY FIREFOX

    March 9th, 2013 at 23:30

    1. Robert Nyman [Editor]

      It’s described in the second paragraph in this article. Only supported in Firefox Nightly on Windows at the moment for desktop web browsers, and Firefox on Android.

      March 11th, 2013 at 07:37

  9. MG

    oh crap I need to download new firefox than

    and again to reconfigure all the stuff like tabs and stuff

    ok thanks

    March 11th, 2013 at 11:30

  10. Bhaavan Merchant

    And Linux support? I do have the underlying codecs already, I just need firefox to use them, and make it a plugin free world.

    March 21st, 2013 at 00:56

    1. Robert Nyman [Editor]

      As is mentioned in the post, Linux support is a work in progress.

      March 21st, 2013 at 01:18

  11. kringel

    Dear Mozilla,

    please add something like media.linux-libavcodec-extra.enabled

    Many browsers like Midori, Qupzilla, Chromium take advantes of the libav*(-extra) packages if they are installed. It would be up to the user to have these packages installed from the contrib/non-free/universe package repositories.

    If Firefox can take advantage of codecs on a Windows system, why not on Linux? I hope it’s only “not yet”, because missing H264 support drives me to use Chromium/Chrome. I also hope for a brighter future with VP9.

    Packages: libavcodec-extra-5*, libavdevice-extra-5*, libavfilter-extra-*, libavformat-extra-5*, libavutil-extra-5*, libpostproc-extra-5*, libswscale-extra-*

    March 23rd, 2013 at 22:37

  12. kringel

    Oh, great to see Linux support is also on its way. Thanks! Really looking forward to this. And I hope for the simple use of the libavcodec-* packages, no Gstreamer.

    March 23rd, 2013 at 22:45

  13. nullability

    Tried this out in Firefox 20.0 (release) and it’s pretty slick. When will it be enabled by default?

    April 3rd, 2013 at 12:12

    1. Robert Nyman [Editor]

      Not sure, it’s being evaluated.

      April 4th, 2013 at 03:34

  14. AK

    H.264 on Mac.

    20 came and went away.

    Shit! Shit! Shit!

    Was I better off with Chrome? Well, Ghostery and ABP are there too.

    April 8th, 2013 at 19:47

Comments are closed for this article.