OGG Encoding for HTML5 Audio

The html5 <audio> tag needs an mp3 file and and ogg file to be cross-browser compatible. For best results, only encode raw, wav, or aiff files this way. Mp3 to ogg will look like it works, but the file won't play on Firefox.

Encode

  1. Install oggenc: $ sudo apt-get install vorbis-tools
  2. Encode: $ oggenc -q 6 input.wav -o output.ogg

The HTML:

<audio controls="controls" preload="auto" autobuffer autoplay id="player">
    <source src="http://alialujah.com/files/3513/2641/1365/a-house-a-home.mp3" type="audio/mpeg" />
    <source src="http://alialujah.com/files/3813/2648/7285/a-house-a-home.ogg" type="audio/ogg" />
    Aw dang! Your browser does not support html5.
</audio>

This entry was posted in Musings. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>