Jan 27, 2009

DivX 3.11 now supported on the PS3

Thanks to firmware update 2.60, the Playstation 3 can now play videos encoded with the DivX 3.11 codec. That's good news, since we all have some of these still lying around :)

Now, could we get support for the Matroska container, please?

Jan 24, 2009

'Guitar Hero: Metallica' tracklist revealed

According to Blabbermouth.net, here's the compete tracklist for 'Guitar Hero: Metallica'. A bit too much focus on the post Black Album era, but that was to be expected. The oldies in there should be painful enough :)
  • All Nightmare Long
  • Battery
  • Creeping Death
  • Disposable Heroes
  • Dyers Eve
  • Enter Sandman
  • Fade To Black
  • Fight Fire With Fire
  • For Whom The Bell Tolls
  • Frantic
  • Fuel
  • Hit The Lights
  • King Nothing
  • Master of Puppets
  • Mercyful Fate (Medley)
  • No Leaf Clover
  • Nothing Else Matters
  • One
  • Orion
  • Sad But True
  • Seek And Destroy
  • The Memory Remains
  • The Shortest Straw
  • The Thing That Should Not Be
  • The Unforgiven
  • Welcome Home (Sanitarium)
  • Wherever I May Roam
  • Whiplash
As a bonus, if you downloaded the 'Death Magnetic' album for Xbox and PS3, the ten songs will also be available in the game.

The game also includes 21 more songs from other artists, including Slayer, Judas Priest and Machine Head

You can view the official trailer here.

PS: when do we get the 'Guitar Hero: Iron Maiden' edition ? Come on!!!

Status update on mediatomb 0.12

The authors of mediatomb, my favorite UPnP streaming media server, just posted a status update on the long-awaited 0.12 release:

"Well… we tried. Really. So what went wrong?

Basically there were two things that delayed everything: first – we were swamped with work and did not have much time to work on the project, second – the DVD feature knocked me out. :)

We desperately wanted to finish it for 0.12, but it turned out to be much more complicated than originally assumed. We will have another go at this, if it does not work out the feature will be postponed for 0.13.

Apart from that there are the usual things for a new release – config.xml migration, testing, documentation… ok, you probably want to know: when?

All I can say is – this year :)

...and for the inpatient – SVN is actually quite stable."

So there you have it. It's quite likely that the DVD feature (i.e. browsing and streaming directly from ISO images) will not be part of the 0.12 release. You can still play VOB files, of course.

Everything else is indeed working, as presented in my previous posts on mediatomb, so go ahead and don't wait for the release!

Once again, kudos to the mediatomb team. This is a fantastic open source project.

VirtualBox 2.1.2 released

If you still haven't tried the VirtualBox x86 virtualizer, now is really the time. I'm using it daily with multiple images (Windows XP, OpenSolaris, CentOS), and it's really super easy and very stable. Perfect virtualization for the desktop.

2.1.2 is a maintenance release, fixing and tuning a large number of issues on all hosts. VirtualBox is pre-packaged for all major Linux distributions, so this easy upgrade is just a couple of clicks away.

Jan 23, 2009

HOWTO: H.264 YouTube videos in mediatomb (no more transcoding for PS3!)

As you probably know (and as explained on Wikipedia), YouTube supports several video formats. Until then, mediatomb could only stream standard videos based on the H.263 video codec, which required on-the-fly transcoding to be properly played on the Playstation 3. I showed you how to do this in this previous super-popular article ;)

But hey, things have changed and as of revision 1998, mediatomb now supports the H.264 format, which is natively played by the PS3. This means that we no longer need to transcode YouTube videos :)

First of all, you need to check what revision you have:

ubuntu% cd src/mediatomb
ubuntu% svn info
Path: .
URL: https://svn.mediatomb.cc/svnroot/mediatomb/trunk/mediatomb
Repository Root: https://svn.mediatomb.cc/svnroot/mediatomb
Repository UUID: f010a08f-7000-0410-b1fc-cb24403df210
Revision: 2018
Node Kind: directory
Schedule: normal
Last Changed Author: jin_eld
Last Changed Rev: 2018
Last Changed Date: 2009-01-22 19:42:33 +0100 (Thu, 22 Jan 2009)

I'm all set, but if you have a revision older than 1998, you need to update your sources ('svn update') and rebuild mediatomb.

Then, all it takes is changing the YouTube configuration in ~/.mediatomb/config.xml, from:

<YouTube enabled="yes" refresh="28800" update-at-start="yes" purge-after="604800" racy-content="exclude">

to:

<YouTube enabled="yes" format="mp4" hd="no" refresh="28800" update-at-start="yes" purge-after="604800" racy-content="exclude">

Although the videos will now be based on the H.264 codec, they will still have the .flv extension, so you also need to remove any transcoding profile for flv files, i.e. something similar to:

<transcode mimetype="video/x-flv" using="video-generic"/>

Now, restart mediatomb and browse your playlists. As you can see, the videos now appear as AVC (which is another name for H.264):


This is confirmed by displaying the file properties during streaming: 128 Kbit/s stereo AAC audio and H.264 video :)


Enjoy!

Jan 19, 2009

HOWTO: building evolution on Ubuntu 8.10 (to fix IMAP slowness...)

[Updated on 2009/01/29: evolution 2.24.3-0ubuntu1 - available in today's package updates - fixes the IMAP issue. I guess people yelled hard enough!]

I finally got around to upgrading my Ubuntu laptop this week-end.

The 8.04-->8.10 upgrade process went like a breeze. However, if you use the evolution e-mail client with an IMAP account storing large folders, chances are you will face the same issues as I did, namely evolution being completely unresponsive and unbelievably slow...

This issue has been around for a while (see bug #558883 on the Gnome Bugzilla). I'm not quite sure it's really fixed and given the Gnome release schedule, the next evolution release would probably be quite far away...

I kind of like evolution and I don't want to switch to another client, so I digged around and found an easy way to rebuild the latest evolution source from the SVN repository, thanks to this fantastic post by Paul Smith (Mr "make", as in GNU make).

First of all, let's install a few dependencies:
ubuntu% sudo apt-get install bison flex libenchant-dev libnss3-dev ccache \
evolution-dev gnome-common gtk-doc-tools libsoup2.4-dev
As of now (mid-January 2009), evolution also requires libical 0.43 or higher. If you need to build it from source, here's how:
ubuntu% svn co https://freeassociation.svn.sourceforge.net/svnroot/freeassociation/trunk freeassociation
ubuntu% cd freeassociation/libical
ubuntu% cmake .
ubuntu% sudo make install
Now, let's build evolution. First, let's fetch the Makefile:

ubuntu% wget http://mad-scientist.us/Makefile

Then, change the Makefile to remove support for libgweather. I neither need it nor want it, so I didn't waste any time trying to install it. You can either modify the file or apply the patch below:
ubuntu% diff -u Makefile.old Makefile
--- Makefile.old 2008-05-29 14:20:42.000000000 +0200
+++ Makefile 2009-01-19 13:36:01.000000000 +0100
@@ -183,7 +183,8 @@
evolution-data-server_PREREQS := glib libsoup libbonobo gtkhtml
evolution-data-server_CONFIG_OPTS = \
--with-openldap=yes --enable-gnome-keyring=yes --with-e2k-debug \
- --with-gconf-source='xml:merged:$(PREFIX)/etc/gconf/gconf.xml.defaults'
+ --with-gconf-source='xml:merged:$(PREFIX)/etc/gconf/gconf.xml.defaults'\
+ --without-weather

# I decided to disable scrollkeeper since otherwise Evolution will try
# to register it, and this requires root privileges.
@@ -194,7 +195,8 @@
--enable-nss=yes --enable-smime=yes --enable-plugins=all \
--enable-cairo-calendar=yes --enable-imap4=yes --with-e2k-debug \
--disable-scrollkeeper $(CONFIG_exchange-$(ENABLE_exchange)) \
- --with-gconf-source='xml:merged:$(PREFIX)/etc/gconf/gconf.xml.defaults'
+ --with-gconf-source='xml:merged:$(PREFIX)/etc/gconf/gconf.xml.defaults'\
+ --without-weather

evolution-exchange_PREREQS := glib libsoup libbonobo evolution-data-server evolution
evolution-exchange_CONFIG_OPTS = \
Now you can run 'make'... and wait a while :)

Once this is complete, the new evolution has been built and installed. Before you can run it, you need to:
  • modify /etc/bonobo-activation/bonobo-activation-config.xml, by adding <item>$PREFIX/lib/bonobo/servers</item> in the <searchpath> section,

  • kill the bonobo-activation-server process (it will restart automatically).
I would also recommend backing up your evolution directory:

ubuntu% cd ~
ubuntu% mv .evolution .evolution-backup

You can now start /opt/evo/bin/evolution-svn and read your e-mail at last...

Jan 16, 2009

HOWTO: processing multichannel audio (DTS, AC3, WAV)

DVDs have made multichannel audio popular, most notably DTS and Dolby Labs' AC3, and it looks like no one will settle down for good old stereo anymore :)

The purpose of this article is to show you to handle multichannel audio streams, which may be found in DVDs and in multimedia files.

For this, we'll use the following tools:
  • ffmpeg, the best general-purpose tool for audio transcoding. I showed you how to build it in a previous article.

  • libdca and its tools, a library specialized in decoding the DTS Coherent Acoustics (DCA) codec,

  • aften, an advanced AC3 encoder which improves on the one included in ffmpeg,

  • audiosplit and audiocombine, two nice and simple tools which split and combine (duh) multichannel WAV files.

  • mediainfo : the best tool to learn everything there is know on the true nature of your media files. I also showed you how to build it in a previous article.
1) Installing libdca

At the time of this writing, the latest version is 0.0.5. Let's get the source, build it and install it:

ubuntu% wget http://download.videolan.org/pub/videolan/libdca/0.0.5/libdca-0.0.5.tar.bz2
ubuntu% bzip2 -d
libdca-0.0.5.tar.bz2
ubuntu% tar xvf libdca-0.0.5.tar
ubuntu% cd libdca-0.0.5
ubuntu% ./configure --prefix=/usr/local
ubuntu% make
ubuntu% sudo make install


This obviously installs the library itself, but also the dcadec tool which we'll use later on.

2) Installing aften

In order to build aften, we need to install cmake:

ubuntu% sudo apt-get install cmake


Now, let's get the source, build it and install it. At the time of this writing, the latest version is 0.0.5.

ubuntu% svn co https://aften.svn.sourceforge.net/svnroot/aften aften
ubuntu% cd aften

ubuntu% mkdir default
ubuntu% cd default
ubuntu% cmake .. -DCMAKE_INSTALL_PREFIX:STRING="/usr/local"
ubuntu% make
ubuntu% sudo make install


3) Installing audio_split and audio_combine

These tools require the libsndfile library:

ubuntu% sudo apt-get install libsndfile1-dev


Now, let's build the tools:

ubuntu% wget http://freshmeat.net/redir/audio_combine/72754/url_zip/audio_combine1.00.zip
ubuntu% unzip
audio_combine1.00.zip
ubuntu% cd audio_combine
ubuntu% make

There is no installation procedure, so just copy audio_split and audio_combine to /usr/local/bin.

4) Example #1: (DTS --> AC3 5.1) & (DTS --> AC3 stereo) with ffmpeg

Let's look at thesample file:
ubuntu% mediainfo audio.dts                           
General
Complete name : audio.dts
Format : DTS
Format/Info : Digital Theater Systems
File size : 9.04 MiB
Duration : 49s 381ms
Overall bit rate : 1 536 Kbps

Audio
Format : DTS
Format/Info : Digital Theater Systems
Bit rate mode : Constant
Bit rate : 1 536 Kbps
Channel(s) : 6 channels
Channel positions : Front: L C R, Surround: L R, LFE
Sampling rate : 48.0 KHz
Resolution : 16 bits
As you can see, this is DTS 5.1 at 1,536Kbit/s. We can easily convert it to AC 5.1 with ffmpeg:
ubuntu% ffmpeg -i audio.dts -acodec ac3 -ac 6 -ab 448k audio.ac3
448 KBit/s is the maximum authorized AC3 bitrate for DVDs. However, if you intend to play the file on the Playstation 3, you can go up to 640Kbit/s.

We can also convert the DTS file to 2-channel AC3:
ubuntu% ffmpeg -i audio.dts -acodec ac3 -ac 6 -ab 448k audio.ac3
Any other number of channel leads to this error (e.g. 3 channels) :
'Resampling with input channels greater than 2 unsupported.
Can not resample 6 channels @ 48000 Hz to 3 channels @ 48000 Hz'

All in all, ffmpeg is a nice and easy solution if you want to preserve the same number of channels or if you want to downmix to stereo. Anything more complex requires other tools.

5) Example #2: (DTS --> AC3 5.1) with dcadec and aften

Let's revisit the previous example but with different tools. We'll use dcadec to decode the DTS file and aften to encode it to AC3.

In in simplest form, dcadec plays DTS files:
ubuntu% dcadec audio.dts
What we really want to do is to decode it to a WAV file:
ubuntu% dcadec -o wav6 audio.dts > audio.wav6
For the sake of completeness, you could also do this:
ubuntu% ffmpeg -i audio.dts audio.wav6
One way or the other, we've just created a 6-channel WAV file:
ubuntu% mediainfo audio.wav6          
General
Complete name : audio.wav6
Format : Wave
File size : 55.2 MiB
Duration : 50s 240ms
Overall bit rate : 9 216 Kbps

Audio
Format : FFFE
Codec ID : FFFE
Codec ID/Info : Extensible wave format
Codec ID/Hint : Extensible
Bit rate : 9 216 Kbps
Channel(s) : 6 channels
Sampling rate : 48.0 KHz
Resolution : 32 bits
Here's the file displayed by Audacity: 6 channels indeed!


Now, let's encode this file as to 6-channel AC3 @ 640 Kbit/s with aften:
ubuntu% aften -b 640 audio.wav6 audio.ac3
That's it! In fact, you can do it in one step by piping the dcadec output into aften:
ubuntu% dcadec -o wav6 audio.dts - | aften -b 640 - audio.ac3
What's the point of doing this instead of using ffmpeg? Well, dcadec and especially aften have plenty of options which allow very fine control on the output file. Why don't you check for yourself with 'dcadec -h' and 'aften -longhelp' ? ;)

6) Example #3: (DTS --> AC3 3.0) with dcadec and aften

In this example, we're going to encode the DTS file to AC3.0, i.e. we'll just use the left front, center front and right front channels.

Why would you want to do that? Well, less channels allow a lower bitrate, so saving space is an obvious reason. Another one could be to keep the orginal bitrate and "spend" the savings to increase the quality of the front channels. We'll try both :)

Anyway, the channel order for the sample file is front left, front right, front center, low frequency effect (LFE), surround left and surround right. Thus, we only need channel 1, 2 and 3 from that file.

Let's decode the DTS file to WAV:
ubuntu% dcadec -o wav6 audio.dts > audio.wav6
Then, let's split the multichannel WAV file into individual mono WAV files:
ubuntu% audio_split audio.wav6 fl.wav fr.wav fc.wav lfe.wav sl.wav sr.wav
Now, we'll recombine the 3 channels we want to keep and encode them to AC3:
ubuntu% aften -acmod 3 -chconfig "3/0" -ch_fl fl.wav -ch_fc fc.wav -ch_fr fr.wav audio.ac3
progress: 100% | q: 264.5 | bw: 31.0 | bitrate: 256.0 kbps
ubuntu% ls -l audio.ac3
-rw-r--r-- 1 julien julien 1608704 2009-01-16 21:23 audio.ac3
Now, with the maximum AC3 bitrate:
ubuntu% aften -b 640 -acmod 3 -chconfig "3/0" -ch_fl fl.wav -ch_fc fc.wav -ch_fr fr.wav audio.ac3
progress: 100% | q: 379.9 | bw: 60.0 | bitrate: 640.0 kbps
ubuntu% ls -l audio.ac3
-rw-r--r-- 1 julien julien 4021760 2009-01-16 21:25 audio.ac3
That's a much bigger file : let your ears decide if the second file sounds better than the first :)

This is just a quick introduction to aften, which also offers many sound processing settings for you to play with. Have fun and as always, all comments welcome.

IFPI: Digital Music Report 2009

The IFPI, which represents the recording industry worldwide, has just published its 2009 report on digital music. Here are the key figures.
  • Worldwide figures
    • Total sales: $3.7 billion, +25% compared to 2007
    • Digital platforms now account for around 20 per cent of recorded music sales, up from 15 per cent in 2007
    • Album downloads: +37%
    • Single track downloads: 1.4 billion tracks, +24%
  • US (more information here)
    • 50% of the global digital market value
    • Single downloads: 1.1 billion tracks, +27% compared to 2007
    • Album downloads: 66 million albums, +32% compared to 2007
  • Japan
    • Mobile single downloads: 140 million tracks, +26% compared to 2007
  • UK (more information here)
    • Single downloads: 110 million tracks, +42% compared to 2007
    • Album downloads: 10.3 million albums, +65% compared to 2007, now accounting for 7.7% of the album market
  • France
    • Single downloads: 14.5 million tracks, +20% compared to 2007
    • Album downloads: 1.4 million albums, +27% compared to 2007
  • Germany
    • Single downloads: 37.4 million tracks, +22% compared to 2007
    • Album downloads: 4.4 million albums, +57% compared to 2007

France is super late and not catching up. What a surprise...

You can get the full report here.

Jan 15, 2009

Scrum art at Digiplug, part 3

Super Mario! Beamer-assisted design! Proof of the Digiplug / Accenture synergy! ;)

Jan 12, 2009

Press release: Digiplug selects Telecity Group for its digital asset management platform

Paris, January 12th 2008: Digiplug, a provider of IT solutions and services dedicated to the production and distribution of multimedia content, has chosen to host its IT infrastructure in TelecityGroup’s two data centres in Paris.

Through its digital asset management and supply chain solutions Digiplug manages and supplies content distribution networks for the largest music labels in 50 countries and over 200 delivery platforms. In addition, Digiplug provides dedicated solutions for retail sites, content downloading or distribution for telecom operators, device manufacturers and resellers, enabling them to distribute audio or video content to consumers effectively. While meeting strict security criteria Digiplug ensures its customers have service continuity for their global content distribution chains and also provides them with strong SLA guarantees.

Faced with rapidly growing customer requirements, Digiplug needed to expand its online storage and distribution infrastructure and turned to TelecityGroup for support.

"In TelecityGroup we have found a reliable partner who has the capacity to cater for the very strong growth in our IT infrastructure requirements while at the same time meeting our exacting needs for redundancy, high availability, physical security and service quality in the data centre,” says M. Simon, Technical Director at Digiplug. “We chose TelecityGroup for its fast response times, their professional approach and its very high levels of logical security and redundancy,” continues M. Simon. “TelecityGroup provides Digiplug with a highly reliable hosting solution.”

To meet Digiplug's increasing needs in terms of security and continuity – including the increasing load prompted by the processing of products intended for online use - TelecityGroup developed a robust, multi-operator IP network to guarantee resilient Internet connectivity and significant bandwidth utilisation. Due to the extensive networks available on the same site, TelecityGroup has installed flexible and scaleable connectivity designed to suit all companies for whom IP services are critical.

"With its European infrastructure and global connectivity hubs, TelecityGroup is a true partner who can meet all our hosting needs. TelecityGroup also has a remarkable pedigree in customer satisfaction; its staff are attentive, highly responsive, flexible and very professional, which is a real bonus in our market environment", continues M. Simon.

About Digiplug:

Digiplug provides SaaS solutions for the production, management and distribution of multimedia (audio, video) content. Today, Digiplug is a top partner for music labels. It uses the solutions it develops to manage the production and global distribution of digital content for 3 of the 4 music majors: Universal Music since 2001, Warner Music and Sony Music Entertainment since 2003. Every day, Digiplug distributes thousands of products on behalf of music major in more than 50 countries and to some 200 platforms (content supplies, transcoding services, etc.). Digiplug also has a large portfolio of solutions for digital content distributors: content aggregation, download platforms, storefront animation (web, wap) coupled with performance statistics.

For more information, visit: http://www.digiplug.com/

About TelecityGroup:

TelecityGroup is the leading premium operator of network independent data centres in Europe offering a range of flexible, scalable data centre and value added services. TelecityGroup specialises in the design, build, and management of highly connected and secure environments in which customers can house their technical, web and internet infrastructure. Each of its data centres acts a connectivity and content hub facilitating the storage, sharing and distribution of data, content and media. TelecityGroup shows its ongoing leadership in exploring and adopting technologies which help minimise the impact of its operations on the environment. Its data centres in France have been the first in the industry to subscribe to the EDF’s “Equilibre+” offer certifying that the equivalent of 21% of the electricity consumed by TelecityGroup France has been generated from renewable sources of energy.

Headquartered in London, TelecityGroup operates 20 network independent data centres across seven European countries. The data centres are located in prime positions for commerce and connectivity, including Amsterdam, Dublin, Frankfurt, London, Manchester, Milan, Paris and Stockholm. TelecityGroup is listed on the London Stock Exchange (LSE: TCY)

For more information, visit: http://www.telecitygroup.com/

Press contacts:

Trimedia agency

Aurélia Renaud / Marie Myrmigelis
Tél : 01 55 30 71 04
aurelia.renaud@trimedia.fr / marie.myrmigelis@trimedia.fr

TelecityGroup

Stéphane Duproz / Managing Director
Tél : 01 49 97 30 68
stephane.duproz@telecity.com

Digiplug
Virginie Sitter, Solutions Marketing Manager
virginie.sitter@digiplug.com

Jan 10, 2009

HOWTO: converting mkv files to play on the PS3

There's no doubt that Matroska is a great open source container that can store anything (and the kitchen sink too). Unfortunately, as of today, it's not well supported by consumer devices. So, unless you decide to use your computer for viewing, you need to convert mkv files into something that your device can play.

The purpose of this article is to show how to do that for the PS3. It may very well work on other devices, but don't blame if it doesn't :)

This article is a work in progress. Are covered so far:
  • Example #1: (mkv file, H.264, AC3) --> (MPEG-2 TS file, H.264, AC3)
  • Example #2: (mkv file, H.264, AC3) --> (MPEG-2 PS file, H.264, AC3)
  • Example #3: (mkv file, H.264, AC3) --> (MP4 file, H.264, AAC)

  • Example #4: (mkv file, H.264 level 5.1, DTS 5.1) --> (MP4 file, H.264 level 4.1, AAC)

  • Example #5: (mkv file, MPEG-2 video, DTS 5.1 + AC3) --> (MPEG-2 PS file, MPEG-2 video, AC3)
  • Example #6: (mkv file, MPEG-2 video, DTS 5.1 + AC3) --> (MPEG-2 PS file, MPEG-2 video, AC3 5.1)
  • Example #7: (mkv file, MPEG-2 video, DTS 5.1 + AC3) --> (MP4 file, H.264 video, AAC)
1) Pre-requisites

Before we start, let's prepare our toolbox:
  • mediainfo : the best tool to learn everything there is know on the true nature of your media files. I showed you how to build it in a previous article.

  • mkvtoolnix : a collection of tools to inspect, extract and build mkv files.

    ubuntu% sudo apt-get install mkvtoolnix

  • ffmpeg : the best general-purpose audio & video transcoding tool. I also showed you how to build it in a previous article.

  • MP4Box : a nice MP4 manipulation tool, which we'll use for multiplexing.

    ubuntu% sudo apt-get install gpac

  • tsMuxer : another great tool for multiplexing. You can download a pre-compiled version here. Just copy the tsMuxer binary in /usr/local/bin.
2) Audio & video formats supported by the PS3

Let's take at a look at what the PS3 actually supports, That way, we will avoid any unnecessary transcoding. Remember that the content we're dealing has already been compressed, so any additional processing would certainly degrade quality. Also, video encoding takes a LOT of time, especially with HD files...

According to the online manual, the PS3 supports:
  • MPEG-1 video, with MPEG-1 layer 2 audio

  • MP4 container : H.264/MPEG-4 AVC High Profile video, with AAC LC audio

  • MPEG-2 PS container (aka VOB file): MPEG-2 video, with either one of these audio formats : MPEG-2 Audio Layer 2, AAC LC, AC3 (Dolby Digital), LPCM audio

  • MPEG-2 TS container :
    • MPEG-2 video, with either one of these audio formats : MPEG-2 Audio Layer 2, AAC LC, AC3 (Dolby Digital)
    • H.264/MPEG-4 AVC video, with AAC LC audio
  • AVCHD, AVI, DivX and VC-1 (WMV), which are less likely to be encountered in mkv files.
So what does this mean? Well, here are a few rules:
  • Obviously, the PS3 does not support the mkv container. Any input file in this format must be at least remuxed.

  • The PS3 does support DTS audio, but only when played from actual disks, i.e. not from files. Thus, any input stream in this format must be transcoded.

  • MP3 audio, Vorbis audio and so on are not supported and must be transcoded.

  • If you want AC3 audio, you must use a MPEG-2 TS/PS container.

  • If you want to stick with the MP4 container, you really have no options but H.264 video and AAC audio.
3) Getting things done

Now that we know what is supported and what isn't, we can pick the right solution, i.e. preserve the quality of the input file and save time.

The approach will always be the same:
  • inspect the mkv file and identify the nature of its streams,

  • extract the video stream and the audio stream (possibly among several available ones)

  • depending on what your audio setup supports, select a format for the audio output (AC3 will do you no good if you don't have a Dolby Digital setup)

  • based on the previous item and on what the PS3 supports, transcode the audio and/or video stream

  • remux the audio and the video stream into a container supported by the PS3

  • play the file :)
Let's look at real-life examples and sort them out!

4) Example #1: (mkv file, H.264, AC3) --> (MPEG-2 TS file, H.264, AC3)

Let's look at our input file with mediainfo (edited for brevity):

ubuntu% mediainfo video.mkv
General
Complete name : video.mkv
Format : Matroska
File size : 1.09 GiB
Duration : 41mn 48s
Overall bit rate : 3 740 Kbps

Video
Format : AVC
Format/Info : Advanced Video Codec
Format profile : High@L3.1
Codec ID : V_MPEG4/ISO/AVC
Width : 1 280 pixels
Height : 720 pixels
Frame rate : 23.976 fps

Audio
Format : AC-3
Format/Info : Audio Coding 3
Codec ID : A_AC3
Channel(s) : 6 channels
Channel positions : Front: L C R, Surround: L R, LFE

You can also use mkvinfo (part of the mkvtoolnix package):

ubuntu% mkvinfo video.mkv
| + Track number: 1
| + Track type: video
| + Codec ID: V_MPEG4/ISO/AVC
| + Video track
| + Pixel width: 1280
| + Pixel height: 720

| + Track number: 2
| + Track type: audio
| + Codec ID: A_AC3

So what is this file? It's a 2-track mkv file: track 1 is H.264 video (1280x720), track 2 is AC3 6-channel audio. Both formats are supported by the PS3, and since they're high quality it would be a shame to transcode them. Let's try a simple remuxing into... no, not MP4 because it doesn't support AC3: we have to use MPEG-2 TS.

This is where tsMuxer comes in. The good thing about it is that we don't have to extract the individual streams, this will be handled for us.

Although tsMuxer is a command-line tool, it can only read its parameters from a file (let's call it tsmuxer.meta):
MUXOPT --no-pcr-on-video-pid --new-audio-pes --vbr
V_MPEG4/ISO/AVC, video.mkv, level=4.1, insertSEI, contSPS, track=1, lang=eng
A_AC3, video.mkv, track=2, lang=eng
Ignore the first line and look at the next two. On each of them, we're describing a stream and telling tsMuxer what format it is and where to find it (file name and track number). Don't worry, this information is dumped by mediainfo or mkvinfo (go back and check), so you shouldn't have any problem writing the file :)

Now, we're ready to remux:

ubuntu% tsMuxeR tsmuxer.meta video.m2ts
output removed
Mux successful complete.
Muxing time: 5 min 25 sec

That's all: this file plays fine on the PS3 (I'm streaming it right now using mediatomb). Total time: about 10 minutes. And we preserved the original quality of the input file.

5) Example #2: (mkv file, H.264, AC3) --> (MPEG-2 PS file, H.264, AC3)

Here, we'll use the same input file as example #1, but we'll remux it to MPEG2-PS (aka the VOB format). This is also interesting if you want to do without tsMuxer.

Wouldn't it be nice to be able to just do this?

ubuntu% ffmpeg -i video.mkv -acodec copy -vcodec copy -r 23.976 -f vob video.mpg
[NULL @ 0x8076d00]error, non monotone timestamps 15030 >= 7470
av_interleaved_write_frame(): Error while opening file


As you can see, it doesn't work. Not sure why... Let's use a two-step solution instead. First, let's extract the streams from the mkv file:

ubuntu% mkvextract tracks video.mkv 1:video.h264 2:audio.ac3

Now, let's remux the streams into a MPEG2-PS container:

ubuntu% ffmpeg -i video.h264 -i audio.ac3 -map 0.0:0 -map 1.0:0 -acodec copy -vcodec copy -r 23.976 -f vob video.mpg

That's it. This solution is a little bit longer than the previous one, but it works and doesn't require you to write the tsMuxer meta file :)

6) Example #3: (mkv file, H.264, AC3) --> (MP4 file, H.264, AAC)

Here, we'll also use the same input file as example #1. For whatever reason, we need to use the MP4 container (maybe to be able to play that file on another device). This means that we must also drop AC3 in favor of AAC.

We have already inspected the file, so let's extract the streams:

ubuntu% mkvextract tracks video.mkv 1:video.h264 2:audio.ac3

Then, we need to transcode the audio stream to AAC (let's use high-quality VBR):

ubuntu% ffmpeg -i audio.ac3 -acodec libfaac -aq 255 -ar 44100 -ac 2 -async 1 -vsync 1 audio.aac

Now, we'll use MP4Box to remux the initial video stream and the new audio stream into an MP4 container:

ubuntu% MP4Box -new -add audio.aac -add video.h264 -fps 23.976 video.mp4
AAC import - sample rate 44100 - MPEG-4 audio - 2 channels
AVC-H264 import - frame size 1280 x 720 at 23.976 FPS
Import results: 60146 samples - Slices: 1027 I 36894 P 22225 B - 1 SEI - 968 IDR
Stream uses B-slice references - max frame delay 2
Saving video-ps3.mp4: 0.500 secs Interleaving


That's it :)

7) Example #4: (mkv file, H.264 level 5.1, DTS 5.1) --> (MP4 file, H.264 level 4.1, AAC)

Here, we'll use a new sample file (for the sake of brevity, I will just display the relevant lines):
ubuntu% mediainfo video2.mkv
General
Complete name : video2.mkv
Format : Matroska

Video
Format : AVC
Format/Info : Advanced Video Codec
Format profile : High@L5.1
Muxing mode : Container profile=Unknown@5.1
Codec ID : V_MPEG4/ISO/AVC
Frame rate : 23.976 fps

Audio
Format : DTS
Format/Info : Digital Theater Systems
Codec ID : A_DTS

ubuntu% mkvinfo video2.mkv

| + A track
| + Track number: 1
| + Track type: video
| + Codec ID: V_MPEG4/ISO/AVC

| + A track
| + Track number: 2
| + Track type: audio
| + Codec ID: A_DTS
OK, so track 1 is H.264 video and track 2 is DTS audio. Let's extract them:

ubuntu% mkvextract tracks video2.mkv 1:video.h264 2:audio.dts

According to what I've said earlier, H.264 is supported, so all we have to do is to transcode the audio... right?

Wrong :) Take another look at the video stream: format profile is "High @ Level 5.1" (note: this has nothing to do with 5.1 audio!). Unfortunately, the PS3 cannot play anything above Level 4.1, so this video stream needs to be fixed. Does this mean we have to reencode it and lose quality?

Nope :) We're going to change the level right in the binary file. For this purpose, you need an hexadecimal editor. I recommend ghex2, which can easily be installed with 'sudo apt-get install ghex'.

just go 'ghex2 video.h264' and look at the first 8 bytes of the file: they should read '00 00 00 01 67 64 00 33'. Hmm... 0x33 in decimal is '51', which means 'level 5.1' : let's change this byte to 0x29 ('41' in decimal) to 'downgrade' the video to level 4.1 and save the file.

Now, let's take care of the audio stream. As above, we'll use high quality VBR:

ubuntu% ffmpeg -i audio.dts -acodec libfaac -aq 255 -ar 44100 -ac 2 -async 1 -vsync 1 audio.aac

The last operation is to remux the initial video stream and the new audio stream into an MP4 container:

ubuntu% MP4Box -new -add audio.aac -add video.x264 -fps 23.976 video.mp4

That's it. I'm not sure the level hack will always work, but it did in this case and we avoided any video transcoding.

8) Example #5: (mkv file, MPEG-2 video, DTS 5.1+ AC3) --> (MPEG-2 PS file, MPEG-2 video, AC3)

Let's take a look at this one (output edited for brevity)
ubuntu% mediainfo video3.mkv 
General
Complete name : video3.mkv
Format : Matroska
File size : 73.9 MiB
Duration : 50s 240ms
Overall bit rate : 12.3 Mbps

Video
Format : MPEG Video
Format version : Version 2
Format profile : Main@High
Format settings, Matrix : Default
Codec ID : V_MPEG2
Width : 1 920 pixels
Height : 1 080 pixels

Audio #1
Format : DTS
Format/Info : Digital Theater Systems
Codec ID : A_DTS
Language : Russian

Audio #2
Format : AC-3
Format/Info : Audio Coding 3
Codec ID : A_AC3
Language : English

ubuntu% mkvinfo video3.mkv
| + Track number: 1
| + Track type: video
| + Codec ID: V_MPEG2

| + Track number: 2
| + Track type: audio
| + Codec ID: A_DTS

| + Track number: 3
| + Track type: audio
| + Codec ID: A_AC3
Track #1 is full HD MPEG-2 video, track #2 is DTS audio in Russian and track #3 is AC3 audio in English. Let's extract them:

ubuntu% mkvextract tracks video3.mkv 1:video.mpeg 2:audio.dts 3:audio.ac3

If like me you don't speak Russian, you'll pick track #3 :) If you do speak Russian, please refer to the next example for DTS-->AC3 conversion.

One option would be to remux tracks #1 and #3 into an MPEG-2 TS container (like we did in example #1). Unfortunately, tsMuxer chokes on the video stream ('Can't detect stream type').

Let's try to remux in an MPEG-2 PS container. For this, we'll use ffmpeg but without any transcoding:

ubuntu% ffmpeg -i video.mpeg -i audio.ac3 -map 0.0:0 -map 1.0:0 -acodec copy -vcodec copy -f vob video.mpg

That's it!

9) Example #6: (mkv file, MPEG-2 video, DTS 5.1 + AC3) --> (MPEG-2 PS file, MPEG-2 video, AC3 5.1)

We'll use the same input file as in example #5, but this time we'll use convert the DTS audio stream and convert it to AC3.

Let's take another look at the DTS stream:

ubuntu% mediainfo audio.dts
General
Complete name : audio.dts
Format : DTS
Format/Info : Digital Theater Systems
File size : 9.04 MiB
Duration : 49s 381ms
Overall bit rate : 1 536 Kbps

Audio
Format : DTS
Format/Info : Digital Theater Systems
Bit rate mode : Constant
Bit rate : 1 536 Kbps
Channel(s) : 6 channels
Channel positions : Front: L C R, Surround: L R, LFE
Sampling rate : 48.0 KHz
Resolution : 16 bits

Since the DTS stream has 6 channels, we can either transcode it to 2-channel AC3 or 6-channel AC3. Let me show you both:

ubuntu% ffmpeg -i audio.dts -acodec ac3 -ar 48000 -ab 448k -ac 2 audio-2ch.ac3


ubuntu% ffmpeg -i audio.dts -acodec ac3 -ar 48000 -ab 448k -ac 6 audio-6ch.ac3


448 KBit/s is the maximum authorized AC3 bitrate for DVDs. However, with the Playstation 3, we could go up to 640Kbit/s.

Now, let's remux the video and audio streams (I'll use 6-channel AC3 here):

ubuntu% ffmpeg -i video.mpeg -i audio-6ch.ac3 -map 0.0:0 -map 1.0:0 -acodec copy -vcodec copy -f vob video.mpg

That's it.

10) Example #7: (mkv file, MPEG-2 video, DTS 5.1 + AC3) --> (MP4 file, H.264 video, AAC)

We'll use the same input file as in example #5. Let's assume that - like in example #3 - we need to use the MP4 container. This means that we must convert the video stream to H.264 and our preferred audio stream (AC3 for this purpose) to AAC.

Please note that this is not the best option! The video compression will be lossy and all the longer that we're dealing with a 1920x1080 video stream. As far as audio is concerning, we're moving from 6-channel AC3 to stereo AAC. So, unless you really need the MP4 container, I strongly suggest that you use the solution described in example #6.

Anyway, let's get started and extract the MPEG-2 and AC3 streams:

ubuntu% mkvextract tracks video3.mkv 1:video.mpeg 3:audio.ac3

Then, let's encode the audio stream to AAC:

ubuntu% ffmpeg -i audio.ac3 -acodec libfaac -aq 255 -ar 44100 -ac 2 -async 1 -vsync 1 audio.aac

Now, the big one: encoding the MPEG-2 stream to H.264:

ubuntu% ffmpeg -i video.mpeg -f rawvideo - | x264 --level 4.1 --crf 21 --bframes 16 --b-pyramid --ref 4 --mixed-refs --weightb --partitions all --threads 2 -o video.h264 - 1920x1080

Let's explain this line a bit: as you can see, we're using ffmpeg to decode the video stream to raw video and we're piping the output into the x264 encoder. The reason for this is avoid any H.264 default value that could be set by ffmpeg: indeed, piping guarantees that all H.264 flags will be set by x264.

What about the x264 flags? '--level 4.1' sets the H.264 level (the PS3 can't play anything above 4.1, please see example #4 for more information). '--crf 21' select Constant Rate Factor encoding, with default quality. '--bframes 16 --b-pyramid --ref 4 --mixed-refs --weightb --partitions all' are frame options which seem to strike the right balance between quality and encoding time (please see this article for more information). Finally, '--threads 2' will create 2 encoding threads.

FYI, on a dual-core PC @ 1.83 GHz, this command took 8 minutes to encode a 50-second video! Now you understand why you don't want to do this unless you have no other option.

Now, the final step: remuxing into an MP4 container

ubuntu% MP4Box -new -add video.h264 -add audio.aac -fps 25 video.mp4

That's it!

11) What's next

These examples should get you started. I will be adding tips and tricks as I am faced with increasingly hostile mkv files ;) In the meantime, have fun and as always, all comments welcome.

Updated 2009/01/16: this post has more advanced information on DTS to AC3 conversion.

x264 benchmarks (individual flags & motion estimation)

As discussed before, finding the right set of x264 flags is a rather complex task. What do these flag mean? What's their effect on encoding time? On file size? On quality? All these are valid questions and the purpose of this article is to experiment and try to answer them.

For this purpose, I will encode the same video with different flag combinations, measure encoding time and file size, and stream it on my PS3 using mediatomb. This is also a way to check that the PS3 supports the encoding flags I'm going to try.

1) A quick look at the test file

I decided to pick a low resolution, high bitrate MPEG video. This way, artifacts will be much more visible when the video is displayed on a large screen, and it will also be interesting to see how much x264 can compress this any further.

Here's what mediainfo reports:
ubuntu% mediainfo video.mpg 
General
Complete name : video.mpg
Format : MPEG-PS
File size : 41.8 MiB
Duration : 2mn 59s
Overall bit rate : 1 954 Kbps

Video
ID : 224 (0xE0)
Format : MPEG Video
Format version : Version 1
Format settings, Matrix : Default
Duration : 2mn 59s
Bit rate mode : Constant
Bit rate : 1 594 Kbps
Nominal bit rate : 1 700 Kbps
Width : 352 pixels
Height : 288 pixels
Display aspect ratio : 4/3
Frame rate : 25.000 fps
Scan type : Progressive
Bits/(Pixel*Frame) : 0.629

Audio
ID : 192 (0xC0)
Format : MPEG Audio
Format version : Version 1
Format profile : Layer 2
Duration : 2mn 59s
Bit rate mode : Constant
Bit rate : 224 Kbps
Channel(s) : 2 channels
Sampling rate : 44.1 KHz
Resolution : 16 bits
Video delay : 280ms
2) Test "methodology"

Although I will also encode audio to AAC, I will only be benchmarking video: encoding times and file sizes discussed below are for the video stream only.

Regarding video encoding, I've opted for Constant Rate Factor encoding (--crf flag), with the same quality factor on all tests. Indeed, I'm not looking to achieve "the best encoding" (whatever that is): instead, I'm really trying to highlight the relative impact of a given flag on encoding.

All tests are performed on Ubuntu 8.04, running on an 1.83GHz Intel Core 2 CPU (T5600 @ 1.83GHz). For the record, here are the actual commands, based on ffmpeg SVN-r16452 and MP4Box 0.4.4:

% ffmpeg -i video.mpg -vn -acodec libfaac -aq 255 -ar 44100 -ac 2 -async 1 video.aac
% time ffmpeg -i video.mpg -f rawvideo - | x264 $X264_FLAGS -o video.264 - 352x288
% MP4Box -new -add video.aac -add video.264 video.mp4
3) Finding out the default values

The first problem is to find out what default values x264 is using. It would not make a lot of sense to start tweaking if we don't know what the starting point it. Fortunately, mediainfo is able to dump encoding flags, so let's do a quick vanilla run (X264_FLAGS="--crf 21"):

ubuntu% mediainfo video.mp4
output removed
Format profile : Main@L1.3
output removed
Encoding settings : cabac=1 / ref=1 / deblock=1:0:0 / analyse=0x1:0x111 / me=hex / subme=6 / psy_rd=1.0:0.0 / mixed_ref=0 / me_range=16 / chroma_me=1 / trellis=0 / 8x8dct=0 / cqm=0 / deadzone=21,11 / chroma_qp_offset=-2 / threads=1 / nr=0 / decimate=1 / mbaff=0 / bframes=0 / keyint=250 / keyint_min=25 / scenecut=40 / rc=crf / crf=21.0 / qcomp=0.60 / qpmin=10 / qpmax=51 / qpstep=4 / ip_ratio=1.40 / aq=1:1.00

OK, so:
  • no B frames (bframes=0)

  • only 1 reference frame (ref=1), no mixed references (mixed_ref=0)

  • partitions (analyse=0x111): p8x8,b8x8,i8x8,i4x4

    Extracted from 'x264.h':
    /* Analyse flags
    */
    #define X264_ANALYSE_I4x4 0x0001 /* Analyse i4x4 */
    #define X264_ANALYSE_I8x8 0x0002 /* Analyse i8x8 (requires 8x8 transform) */
    #define X264_ANALYSE_PSUB16x16 0x0010 /* Analyse p16x8, p8x16 and p8x8 */
    #define X264_ANALYSE_PSUB8x8 0x0020 /* Analyse p8x4, p4x8, p4x4 */
    #define X264_ANALYSE_BSUB16x16 0x0100 /* Analyse b16x8, b8x16 and b8x8 */


  • motion estimation method: hex (me=hex)

    Extracted from 'x264 --longhelp':
    --me Integer pixel motion estimation method
    - dia: diamond search, radius 1 (fast)
    - hex: hexagonal search, radius 2
    - umh: uneven multi-hexagon search
    - esa: exhaustive search
    - tesa: hadamard exhaustive search (slow)

  • subpixel motion estimation method: 6 (subme=6)

    Extracted from 'x264 --longhelp':
    --subme Subpixel motion estimation and mode decision
    - 0: fullpel only (not recommended)
    - 1: SAD mode decision, one qpel iteration
    - 2: SATD mode decision
    - 3-5: Progressively more qpel
    - 6: RD mode decision for I/P-frames
    - 7: RD mode decision for all frames
    - 8: RD refinement for I/P-frames
    - 9: RD refinement for all frames
4) Testing individual flags

These are the tests I'm going to run to try to find out what each additional flags costs and brings:
  1. --crf 21 : default values

  2. --crf 21 --bframes 16 : enable B frames (up to 16 consecutive frames)

  3. --crf 21 --bframes 16 --b-pyramid : allow B frames to be referenced by other frames

  4. --crf 21 --bframes 16 --b-pyramid --ref 8 --mixed-refs : allow up to 8 frames to be referenced by P frames & allow references for partitions (instead of macroblocks)

  5. --crf 21 --bframes 16 --b-pyramid --ref 8 --mixed-refs --weightb : allow weights to be set on referenced frames

  6. --crf 21 --bframes 16 --b-pyramid --ref 8 --mixed-refs --weightb --partitions all : enable all partitions

  7. --crf 21 --bframes 16 --b-pyramid --ref 8 --mixed-refs --weightb --partitions all --8x8dct --direct-8x8 1 : enable 8x8 partitions in I frames

  8. --crf 21 --bframes 16 --b-pyramid --ref 8 --mixed-refs --weightb --partitions all --8x8dct --direct-8x8 1 --no-fast-pskip : examine P frames more closely

  9. --crf 21 --bframes 16 --b-pyramid --ref 8 --mixed-refs --weightb --partitions all --8x8dct --direct-8x8 1 --no-fast-pskip --subme 7 : work harder on subpixel motion estimation

  10. --crf 21 --bframes 16 --b-pyramid --ref 8 --mixed-refs --weightb --partitions all --8x8dct --direct-8x8 1 --no-fast-pskip --subme 8 : work even harder on subpixel motion estimation

  11. --crf 21 --bframes 16 --b-pyramid --ref 8 --mixed-refs --weightb --partitions all --8x8dct --direct-8x8 1 --direct auto --no-fast-pskip --subme 9 : work extremely hard on subpixel motion estimation :)
5) Results on individual flags

Here are the results on the encoding time (click for a larger version):

Here are the results on the size of the output file (click for a larger version):

Here are the sequential variations, i.e. from one test case to the next (click for a larger version):


6) Testing motion estimation

Here are the tests I'm going to run to compare different motion estimation methods, with both default and advanced subpixel motion estimation.

All these tests also include '
--crf 21 --bframes 16 --b-pyramid --ref 8 --mixed-refs --weightb --partitions all --8x8dct --direct-8x8 1 --no-fast-pskip'.
  1. --me hex --subme 6 : hexagonal search, default subpixel processing

  2. --me hex --subme 9 : hexagonal search, maximum subpixel processing

  3. --me umh --subme 6 : uneven multi-hexagon search, default subpixel processing

  4. --me umh --subme 9 : uneven multi-hexagon search, maximum subpixel processing

  5. --me esa --subme 6 : exhaustive search, default subpixel processing

  6. --me esa --subme 9 : exhaustive search, maximum subpixel processing

  7. --me tesa --subme 6 : hadamard exhaustive search, default subpixel processing

  8. --me tesa --subme 9 : hadamard exhaustive search, maximum subpixel processing
7) Results on motion estimation

Here are the results on the encoding time (click for a larger version):

Here are the results on the size of the output file (click for a larger version):

Here are the sequential variations, i.e. from one test case to the next (click for a larger version):

8) Conclusion (?)

Hmm, some really interesting figures in there: I need to think about it, so let's call it day for now :)

I'll come back to these numbers very soon and I'll try to to explain / guess what they mean. All comments welcome, of course!

Jan 8, 2009

UK record sales for 2008

After the US numbers, here are the UK sales for 2008 as reported by Billboard:

Album sales (physical & digital): 133.6 million, -3.2% compared to 2007.

Digital album sales: 10.3 million, +65% compared to 2007. They account for 7.7% of the album market.

Single sales (physical & digital): 115.1 million, +33% compared to 2007.

Single sales (physical): 4.8 million, -43.5% compared to 2007.

Compared to the US, adoption of digital music in the UK is not as widespread. However, a number of factors will certainly help close the gap:
  • growth rates are higher,
  • new digital offers are available (notably from Amazon UK),
  • physical distribution options are dwindling, as retailers either go bankrupt or decide to stop selling CDs

Jan 7, 2009

HOWTO: ffmpeg & x264 presets

As discussed earlier, the ffmpeg command line can be quite daunting, especially when used to encode x264 video...

Wouldn't it be nice to store your favorite options in a configuration file once and for all? Yes it would and yes you can!

Finding the ffmpeg / x264 preset files

Just head for the ffmpeg source and look at the ffpresets directory:

ubuntu% cd ffmpeg/ffpresets
ubuntu% ls
libx264-default.ffpreset libx264-hq.ffpreset libx264-normal.ffpreset
libx264-fastfirstpass.ffpreset libx264-max.ffpreset

Nice. Let's copy these to your ffmpeg configuration directory:

ubuntu% mkdir ~/.ffmpeg
ubuntu% cp *.ffpreset ~/.ffmpeg


A (terrifying) look at a preset file

What do you find in a preset file? Well, a long list of ffmpeg flags related to H.264 encoding:

ubuntu% cat libx264-normal.ffpreset
coder=1
flags=+loop
cmp=+chroma
partitions=+parti8x8+parti4x4+partp8x8+partb8x8
me_method=hex
subq=6
me_range=16
g=250
keyint_min=25
sc_threshold=40
i_qfactor=0.71
b_strategy=1
qcomp=0.6
qmin=10
qmax=51
qdiff=4
bf=16
refs=2
directpred=3
trellis=0
flags2=+bpyramid+wpred+dct8x8+fastpskip

Ouch! Welcome to the wonderful world of H.264 encoding ;)

Keep in mind that these are ffmpeg flags (not x264 flags), so although they really are meant to configure the x264 encoding process, they differ from the actual flags that you would pass directly to the x264 encoder. To ease the pain of translating and understanding these flags, you will certainly need:
Don't worry, though. You really don't need to understand all these flags: the main reason for these preset files is obviously to define a number of typical x264 configurations which can be used out of the box.

Using a preset file

So how do you use a preset file? Just set the '-vpre' flag after the '-vcodec' flag (the flag order does matter):

ubuntu% ffmpeg -i video.mpg -vcodec libx264 -vpre normal video.mp4

Alternatively, you can set it to the full path to the preset file (useful if you don't want to keep them in ~/.ffmpeg)

ubuntu% ffmpeg -i video.mpg -vcodec libx264 -vpre ~/myPresets/libx264-normal.ffpreset video.mp4

Easy, isn't it?

Now let's look at the different preset files and run some tests. Here, I will encode a 3-minute MPEG video to H.264 using each of the available presets.

Audio encoding is disabled ('-an') and we let ffmpeg decide how many threads to run ('-threads 0').

'Default quality' preset file

ubuntu% ffmpeg -i video.mpg -f mp4 -vcodec libx264 -vpre default -an -threads 0 video.mp4

--> 39 seconds, 4.68 Mb

As the name implies, settings are default values and generate a video compliant with the 'Main' H.264 profile. If you need to encode to the 'Baseline' profile, you just need to change 'coder=1' to 'coder=0' in the preset file: this will disable CABAC entropy coding, which is only supported in the 'Main' profile and upwards.

'Normal quality' preset file

ubuntu% ffmpeg -i video.mpg -f mp4
-vcodec libx264 -vpre normal -an -threads 0 video.mp4

--> 43 seconds, 4.67 Mb

These settings bring a little bit more quality and generate a video compliant with the 'High' H.264 profile. The key flags is 'dct8x8', which is only supported in the 'High' profile and upwards: removing it will drop back to the 'Main' profile.

I would recommend this preset for everyday use.

'High quality' preset file

ubuntu% ffmpeg -i video.mpg -f mp4
-vcodec libx264 -vpre hq -an -threads 0 video.mp4

--> 1 minute 26 seconds, 4.71 Mb

These settings bring a even more quality, notably a more accurate motion estimation method (umh) and trellis quantization. The output video is compliant with the 'High' H.264 profile.

Encoding time is 2x longer compared to the 'Normal quality' preset. Let your eyes decide if there's a notable improvement :)

'Maximum quality' preset file

ubuntu% ffmpeg -i video.mpg -f mp4
-vcodec libx264 -vpre max -an -threads 0 video.mp4

--> 15 minutes 4 seconds, 4.72 Mb

These settings bring a lot more quality, thanks to generous B-frames settings, a very efficient (but very slow) motion estimation method (tesa) and more trellis quantization. The output video is compliant with the 'High' H.264 profile.

Still, encoding time is 10x longer compared to the 'High quality' preset. Not sure it's really worth it...

That's it for today. We barely scratched the surface and there's much more to be said on H.264, but hopefully this will get you started :)

=================

Updated on 2009/01/19: a while new bunch of lossless & iPod presets have surfaced!

libx264-baseline.ffpreset
libx264-default.ffpreset
libx264-fastfirstpass.ffpreset
libx264-hq.ffpreset
libx264-ipod320.ffpreset
libx264-ipod640.ffpreset
libx264-lossless_fast.ffpreset
libx264-lossless_max.ffpreset
libx264-lossless_medium.ffpreset
libx264-lossless_slower.ffpreset
libx264-lossless_slow.ffpreset
libx264-lossless_ultrafast.ffpreset
libx264-main.ffpreset
libx264-max.ffpreset
libx264-normal.ffpreset
libx264-slowfirstpass.ffpreset

Videos for the Spring 3.0 conference in Paris

Here are the videos from last November's Spring conference in Paris:
All three videos are in English and synchronized with the presentation slides. Happy viewing!

Jan 5, 2009

French Scrum User Group

Xebia have just started a French Scrum User Group. Registration is free and open to everyone.

Says Scrum co-creator Jeff Sutherland: "I would like to welcome everyone to the French Scrum User Group. My hope is that meetings of small groups using Scrum to share experiences will help teams become more successful. Scrum is expanding in France and we can work together to help each other achieve higher production and higher quality for our products and projects and a more rewarding working environment for Scrum teams".

The first meeting is scheduled in Paris on March 19. See you there!

DO NOT scream at your hard drives!

We all know that vibrations hurt the life expectancy of hard drives. But do they impact performance too? This bizarre experiment would tend to confirm it :)



More information on the subject on these Sun blogs: Catching disk latency in the act & Unusual disk latency.

And remember, from now on, be nice and gentle to your drives :)

Jan 4, 2009

HOWTO: compiling mediainfo (CLI & GUI) on Ubuntu

Today, I will cover a must-have tool for anyone who likes to play with audio / video transcoding : mediainfo.

Indeed, mediainfo will tell you everything you need to know about the format and properties of basically any type of picture, audio or video file.

For instance:
ubuntu% mediainfo video.mpg 
General
Complete name : video.mpg
Format : MPEG-PS
File size : 41.8 MiB
Duration : 2mn 59s
Overall bit rate : 1 954 Kbps

Video
ID : 224 (0xE0)
Format : MPEG Video
Format version : Version 1
Format settings, Matrix : Default
Duration : 2mn 59s
Bit rate mode : Constant
Bit rate : 1 594 Kbps
Nominal bit rate : 1 700 Kbps
Width : 352 pixels
Height : 288 pixels
Display aspect ratio : 4/3
Frame rate : 25.000 fps
Scan type : Progressive
Bits/(Pixel*Frame) : 0.629

Audio
ID : 192 (0xC0)
Format : MPEG Audio
Format version : Version 1
Format profile : Layer 2
Duration : 2mn 59s
Bit rate mode : Constant
Bit rate : 224 Kbps
Channel(s) : 2 channels
Sampling rate : 44.1 KHz
Resolution : 16 bits
Video delay : 280ms
And the '-f' flag (for full) will tell you even more! Now you that you're convinced, let's install it :) mediainfo is available both as a command-line tool and as a graphical tool, so I'll show you both installations on Ubuntu 8.04.

1) Installing the command-line version

This is very straightforward:

ubuntu% wget http://ovh.dl.sourceforge.net/sourceforge/mediainfo/MediaInfo_CLI_0.7.8_GNU_FromSource.tar.bz2
ubuntu% bzip2 -d MediaInfo_CLI_0.7.8.tar.bz2
ubuntu% tar xvf MediaInfo_CLI_0.7.8_GNU_FromSource.tar

ubuntu% cd MediaInfo_CLI_0.7.8_GNU_FromSource
ubuntu% sh CLI_Compile.sh
ubuntu% cd MediaInfo/Project/GNU/CLI
ubuntu% sudo make install

Done :) You can now invoke the 'mediainfo' command.

2) Installing the graphical version

The GUI of mediainfo is based on wxWindows, a cross-platform toolkit for GTK (the X Window toolkit), Windows and MacOS.

In our case, we will use GTK, so let's start with the installation of the GTK development library:

ubuntu% sudo apt-get install libgtk2.0-dev

Then, let's install the wxWidgets library, used by the mediainfo GUI. First, we need to update the list of APT repositories by adding the following line to /etc/apt/sources.list:
deb http://apt.wxwidgets.org/ hardy-wx main
Now, let's update the package list and fetch the wxWidgets package:

ubuntu% sudo apt-get update
ubuntu% sudo apt-get install libwxgtk2.8-0


Now we're ready to build the GUI version of mediainfo:

ubuntu% wget http://ovh.dl.sourceforge.net/sourceforge/mediainfo/MediaInfo_GUI_0.7.8_GNU_FromSource.tar.bz2
ubuntu% bzip2 -d MediaInfo_GUI_0.7.8.tar.bz2
ubuntu% tar xvf MediaInfo_GUI_0.7.8_GNU_FromSource.tar

ubuntu% cd MediaInfo_GUI_0.7.8_GNU_FromSource
ubuntu% sh GUI_Compile.sh
ubuntu% cd MediaInfo/Project/GNU/GUI
ubuntu% sudo make install

The GUI version of mediainfo is now available using the 'mediainfo-gui' command.

That's it for the installation of mediainfo. I'm sure you'll find this tool extremely useful and I'll definitely use it in future posts to illustrate audio & video formats.

Jan 2, 2009

US record sales for 2008

These are extracted from the official SoundScan figures reported by Billboard:

Album sales (physical & digital): 428.4 million albums, -14.4% compared to 2007.

Digital album sales: 65.79 million albums, +31.5% compared to 2007. They now account for 15.4% of overall album sales (10% in 2007).

Digital track sales: 1.07 billion, +26.7% compared to 2007. This is the first year to see over 1 billion tracks sold.

Vinyl albums sales: 1.9 million -- more than any other year since SoundScan began tracking data in 1991 (!!!).

Finally, I'm glad to see that two of my favorite bands did well in 2008:
  • AC/DC's Wal-Mart exclusive release, "Black Ice" (Columbia): 1.92 million copies. That's album #5 for the year, which is all the more impressive that it was not released to digital retailers!
  • Metallica's "Death Magnetic" (Warner Bros.): 1.57 million (album #7)
If you want the complete 2007 & 2008 stats, here they are.