:date: 2012-10-19 11:56 .. index:: tech, opus, music Opus ==== .. image:: /_images/images/gallery/2012/2012-placeholder/logo-opus_codec.png :alt: Opus logo :align: right :scale: 50 Miracles still seem to happen. You all now that `MP3 `__ has been around for quite a while now. Actually, it's celebrating its 20th anniversary next year. Compared to other encoding formats it's still doing a great job regarding compression and quality, I think. There are alternatives as `Flac `__ and `Ogg `__ and each of them fires up a single holy war about if it's the better coding standard or not. You can't fight religious believes and you can't discuss with extremists, so why start arguing about it. All the other codecs being able to contain DRM aren't even worth mentioning, I think. Since this August 2012 we've got a new contestant in the game: `Opus `__. And I have to admit I'm excited. Opus has been defined by the `Internet Engineering Task Force (IETF) `__ and some happy coding monkeys are already working on the implementation. Currently there's not much that can play an :file:`.opus`-file out there. `Firefox `__ can, though. I was doing a quick and dirty test in order to see what the quality is and how it performs. -------- Installation ------------ There are two ways you can do it: #. Take the one from your repository. That includes the encoding tools and will integrate it into your system. #. Download and compile the latest version on your own. First you have to get the coding/decoding tools for Opus. On http://www.opus-codec.org you can download your package. Somebody was so nice making already the builds for Windows and Apple-users (who always need a hand to get things done ...), but also the latest stable release of the `libopus 1.0.1 `__. The installation/compiling is pretty straight forward: .. code:: bash $ wget http://downloads.xiph.org/releases/opus/opus-1.0.1.tar.gz $ tar -xzf opus-1.0.1.tar.gz $ cd opus-1.0.1 $ ./configure $ make $ sudo make install This will give you a file :file:`opus-demo` which you can use to encode your stuff and try out the encoding. If you go for the options from your repository, you get them in a different way. The package :program:`opus-tools` will leave you with three binaries: * :file:`opusenc` for encoding * :file:`opusdev` for decoding (it's obvious, isn't it?) * :file:`opusinfo` for showing you information about the media files. -------- Usage ----- As you can see from the examples I'm using the repository package from here one: :command:`opusenc` currently can only encode :file:`.wav` files, but that doesn't really matter, does it? I've used :ref:`Amanda <2012-amanda_palmer_theater_is_evil>`'s album for the testing when encoding to :file:`.opus`. .. code:: bash $ ls -lh | grep 02-smile -rw-rw-r-- 1 jt jt 66M 2012-10-19 13:02:55 +0200 02-smile.wav OK, now we're at a point where we can start from. We've got a :file:`wav`-file with 66MB and now let's see what opus can make of that: .. code:: bash $ opusenc --vbr 02-smile.wav 02-smile.opus Encoding using libopus 1.0.1 (audio) ----------------------------------------------------- Input: 44.1kHz 2 channels Output: 2 channels (2 coupled) 20ms packets, 96kbit/sec VBR Preskip: 356 Encoding complete0.6x realtime, 92.48kbit/s ----------------------------------------------------- Encoded: 6 minutes and 27.98 seconds Runtime: 9 seconds (43.11x realtime) Wrote: 4515795 bytes, 19399 packets, 390 pages Bitrate: 92.4814kbit/s (without overhead) Rate range: 82kbit/s to 165.2kbit/s (205 to 413 bytes per packet) Overhead: 0.679% (container+metadata) So it took about nine seconds to encode the 66MB :file:`wav` file to the opus file. And the file-size? .. code:: bash $ ls -lh | grep 02- -rw-rw-r-- 1 jt jt 4,4M 2012-10-19 13:55:56 +0200 02-smile.opus -rw-rw-r-- 1 jt jt 66M 2012-10-19 13:02:55 +0200 02-smile.wav Ups. 4.4MB. Really? Yes, but how does e.g. the :program:`lame` encoder perform here in creating MP3 files?. So I've encoded the :file:`wav` file with a virtual-bit-rate as well. The outcome: .. code:: bash $ lame -v 02-smile.wav 02.smile.vbr.mp3 ... $ ls -lh | grep 02- -rw-rw-r-- 1 jt jt 4,4M 2012-10-19 13:55:56 +0200 02-smile.opus -rw-rw-r-- 1 jt jt 6,6M 2012-10-19 14:00:29 +0200 02-smile.vbr.mp3 -rw-rw-r-- 1 jt jt 66M 2012-10-19 13:02:55 +0200 02-smile.wav Opus has managed to shrink it down to just 4.4 MB, which is 2/3 of the MP3 file size. :command:`opusinfo` gives us more detailed information about what has been done: .. code:: bash $ opusinfo 02-smile.opus Processing file "02-smile.opus"... New logical stream (#1, serial: 2e2d7d65): type opus Encoded with libopus 1.0.1 User comments section follows... ENCODER=opusenc from opus-tools 0.1.5 Opus stream 1: Pre-skip: 356 Playback gain: 0 dB Channels: 2 Original sample rate: 44100Hz Packet duration: 20.0ms (max), 20.0ms (avg), 20.0ms (min) Page duration: 1000.0ms (max), 999.9ms (avg), 980.0ms (min) Total data length: 4515795 bytes (overhead: 0.679%) Playback length: 6m:27.970s Average bitrate: 93.12 kb/s, w/o overhead: 92.48 kb/s Logical stream 1 ended In order to listen to it, I just dropped it into the :program:`firefox` and it played flawlessly. I've listened to it a couple of times and I have to say: yes, it's OK. -------- If now just a single media player would start supporting .opus-files, I see this really becoming the new audio-standard. The future will show how well this codec is going to be implemented. The final step will probably be to at least add the codec as standard on MP3-players and smartphones. Then it will just overrun the current MP3 standard (And everything will be better. *sigh* ). -------- *Update:* `VLC 2.0.4 `__ also `supports now `__ the Opus codec for playing.