Dec 28, 2008

HOWTO: adding Last.fm scrobbling to mediatomb

Lastfmlib is C / C++ library allowing music applications to "scrobble" tracks on last.fm.

A patch has been recently released to integrate this library with mediatomb, so let's get to work :)

FYI, this is written using Ubuntu 8.04 and mediatomb 0.12 (SVN build 1997). I also assume you have a mediatomb source tree ready (if not, here's how).

1) Installing lastfmlib

First of all, we need to fetch the log4cpp library, which is used by lastfmlib to log its actions (very useful for troubleshooting!).

ubuntu% sudo apt-get install liblog4cpp5-dev

Now, let's fetch the lastfmlib source (0.1.3 at the time of this writing) as well as the mediatomb patch:

ubuntu% wget http://lastfmlib.googlecode.com/files/lastfmlib-0.1.3.tar.gz
ubuntu% wget http://lastfmlib.googlecode.com/svn/trunk/mediatomb.patch

Building the library is very straightforward:

ubuntu% tar xvfz lastfmlib-0.1.3.tar.gz
ubuntu% cd lastfmlib-0.1.3
ubuntu% ./configure --prefix=/usr/local --enable-logging
ubuntu% make
ubuntu% sudo make install
ubuntu% sudo ldconfig

Done! Let's patch mediatomb now.

2) Patching & building mediatomb

In the mediatomb source directory, let's apply the patch:

ubuntu% patch -p0 < ../lastfmlib-0.1.3/mediatomb.patch All hunks should be successful. Now, run configure to take lastfmlib into account:

ubuntu% ./configure --prefix=/usr/local
output removed
checking lastfmlib/lastfmscrobbler.h usability... yes
checking lastfmlib/lastfmscrobbler.h presence... yes
checking for lastfmlib/lastfmscrobbler.h... yes
output removed
CONFIGURATION SUMMARY ----
output removed
lastfm : yes
output removed

OK, the library has been properly detected. Now, let's (re)build mediatomb:

ubuntu% make clean
ubuntu% make
ubuntu% sudo make install

3) Configuring mediatomb

In the mediatomb config file (~/.mediatomb/config.xml), we need to add this to the top-level section:
<lastfm enabled="yes">
<username>Your_LastFM_username</username>
<password>Your_LastFM_password</password>
</lastfm>
That's it :)

4) Testing!

Now, let's start mediatomb, fire up the PS3 (or whatever device you're streaming to) and play some mp3 tracks.

In the lastfmlib log, you should see something similar to this:

ubuntu% tail -f /tmp/lastfmliblog.txt
1230460109 INFO : Authentication successfull for user: Your_LastFM_username
1230460109 INFO : Authenticate thread finished
1230462337 INFO : startedPlaying Tanker Mot Tind (Gryning)
1230462517 INFO : startedPlaying Ved Steingard
1230462517 INFO : sendInfo thread started
1230462517 INFO : Track "Tanker Mot Tind (Gryning)" can be committed: conditions OK
1230462517 INFO : Buffered tracks submitted
1230462517 INFO : sendInfo thread finished

And now the mediatomb console output:

2008-12-28 12:05:37 INFO: Artist: Borknagar
2008-12-28 12:05:37 INFO: Title: Tanker Mot Tind (Gryning)
2008-12-28 12:08:37 INFO: Artist: Borknagar
2008-12-28 12:08:37 INFO: Title: Ved Steingard

Of course, you can also log in on your last.fm account and see the tracks listed there. Pretty cool :)

One (very minor) gripe: scrobbling doesn't seem to work for file formats which are not natively handled by the PS3, notably FLAC. Maybe metadata extraction works differently for these files, as they need to be transcoded on the fly? Or have I missed something ? Anyway, I contacted the author about this, I'll post more details when I get them.

[Updated on 2009/01/02] Says Dirk Vanden Boer, the author of the library: "I haven't tried playing files that need be transcoded yet, I'll take a look and see if a different code path is taken in case of transcoding". I'll keep you posted.

That's it for today :)

Dec 27, 2008

HOWTO: quick reference on audio & video encoding with ffmpeg

The purpose of this article is to serve as a quick reference on how to use ffmpeg for audio and video encoding. Boy can these ffmpeg flags be tricky to remember, especially codec names: they can really drive me crazy :)

Let's cover audio encoding first (MPEG, MP3, AAC, 3GPP AMR, OGG, FLAC & WMA). Then, we'll talk about video (MPEG, FLV, XVID, MP4, Theora, WMV, H.264 & MKV), with a tiny bit of benchmarking as well. Finally, we'll try some heavy duty video compression for mobile devices.

BTW, all these examples work (!) with the latest ffmpeg and all output files have been successfully tested with VLC 0.9.8a.

1) Audio encoding

The audio.wav sample file is PCM audio (pcm_sb16le) inside a WAV container.

Some generic audio options:
  • -f: the output file format (i.e container)
  • -acodec: the codec to use for encoding
  • -ab: the bitrate in bits per second (e.g. 64000, 64k, etc)
  • -ar: the sampling rate in Hertz (e.g. 22000, 44100, etc)
  • -ac: the number of channels (e.g. 1 for mono, 2 for stereo, etc)

MPEG-1 layer 2 audio

% ffmpeg -i audio.wav -acodec mp2 -ab 192k audio.mp2

MPEG-1 layer 3 audio, Constant Bit Rate (CBR)

% ffmpeg -i audio.wav -acodec libmp3lame -ab 192k audio.mp3

MPEG-1 layer 3 (MP3) audio, Variable Bit Rate (VBR)

% ffmpeg -i audio.wav -acodec libmp3lame -aq [0-255] audio.mp3
0: highest quality (weird, I know).

AAC audio, Constant Bit Rate (CBR)

% ffmpeg -i audio.wav -f adts -acodec libfaac -ab 192k audio.aac

AAC audio, Variable Bit Rate (VBR)

% ffmpeg -i audio.wav -f adts -acodec libfaac -aq [0-255] audio.aac

0:lowest quality, 255:highest quality

3GPP AMR Narrow band (AMR-NB), 8KHz, 6.7Kbit/s

% ffmpeg -i audio.wav -f 3gp -acodec libamr_nb -ac 1 -ar 8000 -ab 6.7k audio.3gp

3GPP AMR Wideband (AMR-WB), 16KHz, 23.85Kbit/s

% ffmpeg -i audio.wav -f 3gp -acodec libamr_wb -ac 1 -ar 16000 -ab 23.85k audio.3gp

OGG Vorbis, Constant Bit Rate (CBR)

% ffmpeg -i audio.wav -f ogg -acodec libvorbis -ab 192k audio.ogg

OGG Vorbis, Variable Bit Rate (VBR)

% ffmpeg -i audio.wav -f ogg -acodec libvorbis -aq [0-255] -ab 192k audio.ogg

0:lowest quality, 255:highest quality

FLAC

% ffmpeg -i audio.wav -acodec flac audio.flac

Windows Audio Media v2

% ffmpeg -i audio.wav -acodec wmav2 -ab 256k audio.wma

2) Video encoding


The video.mpg sample file is a 3-minute video clip : 352x288 resolution, MPEG-2 PS container, MPEG-1 video (1700 Kbit/s), MPEG-1 layer 2 audio (224 Kbit/s) --> 41.7 MB.

Here, just for reference, I will also look at the encoding time and at the size of the output file. FYI, I'm running these tests on a 1.83GHz Intel Core 2 CPU.

Some generic video options:
  • -f: the output file format (i.e container)
  • -vcodec: the codec to use for encoding
  • -b: the bitrate in bits per second (e.g. 1024k)
  • -r: the rate in frames per second (e.g. 25)
  • -async 1: synchronize the start of the audio and video streams

MPEG-2 PS container, MPEG-2 video, audio untouched

% ffmpeg -i video.mpg -f mpeg -vcodec mpeg2video -acodec copy video2.mpg

'copy' can be used to leave the audio / video source stream as is.

FLV container, H263 video, MPEG-1 layer 3 (MP3) audio

% ffmpeg -i video.mpg -f flv -vcodec flv -r 25 b 1024k -acodec libmp3lame -ab 128k -ac 2 video.flv

--> 20 seconds, 6.4 MB

AVI container, XVID video, MPEG-1 layer 3 (MP3) audio

% ffmpeg -i video.mpg -f avi -vcodec libxvid -r 25 -b 1024k -acodec libmp3lame -ab 128k -ac 2 video.avi

--> 29 seconds, 24.7 MB.

MPEG4 container, MPEG-4 video (Simple profile, L1), AAC-LC audio

% ffmpeg -i video.mpg -f mp4 -vcodec mpeg4 -r 25 -b 1024k -acodec libfaac -ab 128k -ac 2 -async 1 video.mp4

--> 22 seconds, 24.6 MB

OGG container, Theora video, Vorbis audio

% ffmpeg -i video.mpg -f ogg -vcodec libtheora -r 25 -b 1024k -acodec libvorbis -ab 128k -ac 2 -async 1 video.ogg

--> 1 minute 24 seconds, 24.4 MB

AVI container, Windows Media Video 8 (WMV9), Windows Media Audio 2 (WMA2)

% ffmpeg -i video.mpg -f avi -vcodec wmv2 -r 25 -b 1024k -acodec wmav2 -ab 128k -ac 2 -async 1 video.avi

-->18 seconds, 24.7 MB

MP4 container, H.264/AVC (Baseline profile, L2.1) video, AAC-LC audio

% ffmpeg -i video.mpg -f mp4 -vcodec libx264 -r 25 -b 1024k -acodec libfaac -ab 128k -ac 2 -async 1 video.mp4

--> 1 minute 19 seconds, 25.5 MB

Matroska container (MKV), H.264/AVC (Baseline profile, L2.1) video, AAC-LC audio

% ffmpeg -i video.mpg -f matroska -vcodec libx264 -r 25 -b 1024k -acodec libfaac -ab 128k -ac 2 -async 1 video.mkv

--> same as above: only the container differs

Or you could have reused the MP4 file above to perform a simple re-muxing of the audio and video streams into a MKV container :

% ffmpeg -i video.mp4 -f matroska -vcodec copy -acodec copy video.mkv

3) Mobile video encoding

Now, let's try some heavy duty compression!

3GPP container, H.263 video, AMR-WB audio

% ffmpeg -i video.mpg -f 3gp -vcodec h263 -b 256k -r 15 -acodec libamr_wb -ac 1 -ar 16000 -ab 23.85k -async 1 video.3gp

--> 15 seconds, 6.1 MB

Let's resize the video to qcif (176x144) and degrade the video stream. Since this is a music video, I can't really degrade the audio stream any further.

% ffmpeg -i video.mpg -f 3gp -s qcif -vcodec h263 -b 96k -r 12 -acodec libamr_wb -ac 1 -ar 16000 -ab 23.85k -async 1 video.3gp

--> 13.2 seconds, 2.7 MB

Let's degrade video even more.

% ffmpeg -i video.mpg -f 3gp -s qcif -vcodec h263 -b 48k -r 10 -acodec libamr_wb -ac 1 -ar 16000 -ab 23.85k -async 1 video.3gp

--> 12.5 seconds, 1.7 MB... and still enjoyable at less than 100 Kbit/s. That's 20x less than the original video.

OK, enough for now. I'll probably keep adding to this page to help my failing memory :) There's also plenty more to explore, especially on the x264 side, but that's it for today!

Dec 26, 2008

HOWTO: setting up a VOD server with VLC

In a previous article, I showed you how to build VLC from source. Since this build included the live555 streaming libraries, the resulting VLC is able to serve audio / video streams.

Thus, in this article, I'm going to give you a quick overview on how to configure VLC as an on-demand RTSP streaming server, with on-the-fly transcoding thrown in for good measure ;)

First of all, we need a machine to run the VLC server on. Here, it will be 192.168.0.2, an Ubuntu 8.04 machine with VLC 0.9.8a, ffmpeg SVN-r16245 (built from source) and x264 0.65.1057 (built from source).

Then, we need to copy some media files on the server. I'll use an MP3 file (music.mp3) and an MPEG2 video (video.mpg), both located in /home/julien/media.

Now, let's write the VLC configuration file and save it as vlc_vod_config:

# VLC media player VLM command batch
# http://www.videolan.org/vlc/

new MyMusic vod enabled
setup MyMusic input "file:///home/julien/media/music.mp3"

new MyVideo vod enabled
setup MyVideo input "file:///home/julien/media/video.mpg"

new MyVideoMobile vod enabled
setup MyVideoMobile input "file:///home/julien/media/video.mpg" output "#transcode{venc=ffmpeg,vcodec=h264,vb=384,height=120,width=160,fps=20,aenc=ffmpeg,acodec=mp3,ab=64,channels=1}"

It's fairly self explanatory :) As you can see, we need to create an entry for each media we want to stream:
  • the media identifier (MyMusic, MyVideo) following the new keyword is important because it's going to be part of the URL used by the client to access the media.
  • vod stands for Video on Demand (VLC can also do broadcast streams)
  • enabled, well... you get the idea :)
  • setup...input links the identifier to the actual media file we want to stream
The last stream, MyVideoMobile, is based on the same MPEG input file as the MyVideo stream. However, this file will be resized and transcoded on the fly into H264 video and MP3 audio. For example, this could be useful for mobile clients, which require a smaller resolution and a much lower bitrate than PC clients.

Now let's open a terminal on the server and start VLC. We want it to run as an RTSP server on port 5554. We also want to use the telnet interface to configure it and the telnet password will be 'videolan':

ubuntu% vlc -I telnet --telnet-password videolan --rtsp-host 0.0.0.0:5554
output removed
[00000405] telnet interface: telnet interface started on interface 4212

That's it for the server. Now, let's configure it from a client using telnet:

client% telnet 192.168.0.2 4212
Trying 192.168.0.2...
Connected to 192.168.0.2.
Escape character is '^]'.
Password:
Welcome, Master
> load /home/julien/media/vlc_vod_config

Using the show command, we can check the configuration of a stream:

> show MyMusic
show
MyMusic
type : vod
enabled : yes
mux
inputs
1 : file:///home/julien/media/music.mp3
output :
options
instances

This looks good. Let's start a VLC player on the client and connect to a stream:

client% /usr/bin/vlc rtsp://192.168.0.2:5554/MyMusic
VLC media player 0.8.6e Janus

This works :) Thanks to RSTP, you can pause or seek anywhere into the stream. Let's try the video stream now:

client% /usr/bin/vlc rtsp://192.168.0.2:5554/MyVideo
VLC media player 0.8.6e Janus

Same thing: pause, fast forward and rewind all work. In the telnet session, the show command will give you additional info on an active stream:

> show MyVideo
show
MyVideo
type : vod
enabled : yes
mux
inputs
1 : file:///home/julien/media/video.mpg
output :
options
instances
instance
name : 1632621729
state : playing
position : 0.303068
time : 55160000
length : 180556733
rate : 1000
title : 0
chapter : 0
seekable : 1
playlistindex : 1

Now, let's try the mobile video stream:

client% /usr/bin/vlc rtsp://192.168.0.2:5554/MyVideoMobile
VLC media player 0.8.6e Janus
[00000288] main decoder error: no suitable decoder module for fourcc `h264'.
VLC probably does not support this sound or video format.
[00000274] main playlist: stopping playback

Ah #%$£... Now you see why you HAVE to rebuild VLC from source! Let's try again with the latest VLC:

ubuntu% /usr/local/bin/vlc rtsp://192.168.0.2:5554/MyVideoMobile
VLC media player 0.9.8a Grishenko

Ah, now it works. So do pausing and seeking, even with transcoding.

If you run ps or top on the server, you'll notice that an extra VLC process is running to handle transcoding. Also, in the VLC player, under the Tools / Media Information menu, you can look at the Codec Details and Statistics tabs to check that the stream is indeed H264 / MP3 with a low bitrate.

Anyway, here's what it looks like (click the picture for a larger version):


That's it for today. Have fun with streaming!

Dec 24, 2008

Mediatomb 0.12 on PS3: video thumbnails, YouTube and Apple movie trailers

In a previous article, I explained how to build mediatomb, an open source media server able to stream music and video to UPnP devices, such as the Playstation 3. This build is based on the latest development source tree, so although the next official release (0.12) is still ahead of us, we can already take a look at some new features, namely:
  • improved on-the-fly transcoding.
  • built-in support for video thumbnails (using ffmpegthumbnailer),
  • Apple movie trailers,
  • YouTube video feeds
In this article, I'm going to demonstrate these features on my PS3 and I'm also going to explain how to set them up.

FYI, I'm using Ubuntu 8.04, ffmpeg SVN-r16245 (built from source), ffmpegthumbnailer 1.3.0 (built from source) and x264 0.65.1057 (built from source).

1) Basic configuration

mediatomb only has one config file, located in ~/.mediatomb/config.xml. For more information, please check the mediatomb documentation.

Let's start from the default settings and add a few things.

In the <server> section, set the extended UPnP protocol information for the PS3:
<protocolInfo extend="yes"/>
[Updated on 2009/01/02] Reportedly not needed anymore if you're running the latest PS3 firmware (2.53). Try changing it to 'no' if you're experiencing issues with movie playback.

In the <extension-mimetype> section, add a few entries to map common extensions for video files to the appropriate MIME type:
<map from="avi" to="video/divx"/>
<map from="mkv" to="video/x-matroska"/>
<map from="mts" to="video/mpeg"/>
<map from="ts" to="video/mpeg"/>
<map from="m2ts" to="video/mpeg"/>
<map from="mov" to="video/x-quicktime"/>
<map from="vob" to="video/mpeg"/>
<map from="m4v" to="video/mp4"/>
In the <mimetype-contenttype> section, add a few entries to map MIME types to extensions, so that mediatomb can use the proper method to extract metadata:
<treat mimetype="video/quicktime" as="mov"/>
<treat mimetype="video/x-quicktime" as="mov"/>
2) On-the-fly transcoding

The PS3 supports a limited set of audio & video file formats. For example, it can't play FLAC, FLV, Quicktime, etc. In order to play these files anyway, we need mediatomb to transcode them on the fly and then stream them to the PS3 in a format it can play. Transcoding itself is performed by external tools, such as VLC and ffmpeg.

All we have to do is:
  • list all MIME types which require transcoding,
  • associate each of them to a transcoding profile,
  • define the actual transcoding profiles.
Here's the complete configuration I use:
  • for audio transcoding (OGG and FLAC), a profile based on ffmpeg, which outputs 16-bit PCM stereo audio at 44.1KHz and 192 Kbit/s,
  • for video transcoding (ASF, FLV, Quicktime), a profile also based on ffmpeg, which outputs MPEG-2 video at 25 fps and 4Mbit/s, as well as MPEG stereo audio at at 44.1KHz and 192 Kbit/s.
<transcoding enabled="yes">
<mimetype-profile-mappings>
<transcode mimetype="application/ogg" using="audio-generic"/>
<transcode mimetype="audio/x-flac" using="audio-generic"/>
<transcode mimetype="video/x-ms-asf" using="video-generic"/>
<transcode mimetype="video/x-flv" using="video-generic"/>
<transcode mimetype="video/x-matroska" using="video-generic"/>
<transcode mimetype="video/x-quicktime" using="video-generic"/>
<transcode mimetype="video/quicktime" using="video-generic"/>
</mimetype-profile-mappings>

<profiles>
<profile name="audio-generic" enabled="yes" type="external" >
<mimetype>audio/L16</mimetype>
<first-resource>yes</first-resource>
<accept-url>yes</accept-url>
<sample-frequency>44100</sample-frequency>
<audio-channels>2</audio-channels>
<hide-original-resource>yes</hide-original-resource>
<agent command="ffmpeg" arguments="-ac 2 -ar 44100 -y -i %in -f s16be %out"/>
<buffer size="1048576" chunk-size="4096" fill-size="1024"/>
</profile>

<profile name="video-generic" enabled="yes" type="external">
<avi-fourcc-list mode="ignore">
<fourcc>DX50</fourcc>
<fourcc>DM4V</fourcc>
<fourcc>M4S2</fourcc>
</avi-fourcc-list>
<mimetype>video/mpeg</mimetype>
<accept-url>yes</accept-url>
<first-resource>yes</first-resource>
<hide-original-resource>yes</hide-original-resource>
<accept-ogg-theora>yes</accept-ogg-theora>
<agent command="/usr/local/bin/mediatomb-video-generic" arguments="%in %out"/>
<buffer size="1048576" chunk-size="26214" fill-size="52428"/>
</profile>
</profiles>
</transcoding>
Now, here's the 'mediatomb-video-generic' script. Don't forget to change the path to ffmpeg if needed and to set execute rights ('chmod 755 /usr/local/bin/mediatomb-video-generic'):

[this updated script works for Youtube, Apple trailers and mkv files and doesn't require VLC anymore : thanks to the anonymous reader who contributed it].
#!/bin/bash
INPUT="$1"
OUTPUT="$2"
VIDEO_CODEC="mpeg2video"
VIDEO_BITRATE="4096k"
AUDIO_CODEC="mp2"
AUDIO_BITRATE="192k"
AUDIO_SAMPLERATE="48000"
AUDIO_CHANNELS="2"
FORMAT="dvd"

exec /usr/local/bin/ffmpeg -threads 2 -i "${INPUT}" -vcodec ${VIDEO_CODEC} -b ${VIDEO_BITRATE} \
-acodec ${AUDIO_CODEC} -ab ${AUDIO_BITRATE} -ar ${AUDIO_SAMPLERATE} -ac ${AUDIO_CHANNELS} \
-f ${FORMAT} - > "${OUTPUT}" 2>/dev/null
All right, let's get to the good stuff.

3) Video thumbnails

Assuming you have installed ffmpegthumbnailer, enabling on-the-fly thumbnail generation only requires this addition to the <server> section:
<extended-runtime-options>
<ffmpegthumbnailer enabled="yes">
<thumbnail-size>128</thumbnail-size>
<seek-percentage>5</seek-percentage>
<filmstrip-overlay>yes</filmstrip-overlay>
<workaround-bugs>no</workaround-bugs>
</ffmpegthumbnailer>
</extended-runtime-options>
Let's save these changes, restart mediatomb and browse some videos: MPEG-2 on the left, DivX on the right. Thumbnails are generated on the fly when videos are browsed.



Let's try some different file types.
  • Below on the left: VOB files ripped from a DVD. VOB files really are MPEG-2 files, but since they have a different extension, they wouldn't be viewable if we hadn't mapped the .vob extension to the video/mpeg MIME type.
  • Below on the right: some MKV (Matroska) samples.


This looks much nicer than blank icons :)

4) Apple movie trailers

This feature, found in the Online Services menu, allows you to view movies trailers hosted on an Apple website.

This is very easy to configure. In the <online-content> section, add:
<AppleTrailers enabled="yes" refresh="43200" update-at-start="yes" resolution="640"/>
Save the changes, restart mediatomb and...



It works like this. First, mediatomb fetches an RSS feed, then it parses it and dynamically creates menus where trailers are sorted by genre, release date, etc. Let's go to action movies and hmmm... 2012? What is this?


Wow, the Himalaya overrun by a giant wave, the end of the world, etc. My kind of movie :)



Come on, is this a cool feature or what?

5) YouTube videos

Now, let's go back to the Online Services and enter the YouTube menu. In the mediatomb configuration file, we need to define:
  1. a valid YouTube account (username and password),
  2. the list of video feeds that we'd like to browse.
So, in the <accounts> section, add:
<account user="your_YouTube_username" password="your_YouTube_password"/>
And in the &lt;online-content> section, add:
<YouTube enabled="yes" refresh="28800" update-at-start="yes" purge-after="604800" racy-content="exclude">
<favorites user="your_YouTube_username"/>
<playlists user="your_YouTube_username"/>
<uploads user="your_YouTube_username"/>
<standardfeed feed="most_viewed" time-range="today"/>
<standardfeed feed="top_rated" time-range="this_week"/>
</YouTube>
This is quite customizable, but no official documentation is out yet. A quick look at the code will give you some pointers, though ;)

Save the changes, restart mediatomb and now you can browse your YouTube playlists.



You can also browse the standard YouTube feeds that you have defined: Most Viewed, Top Rated, etc.



All right, that's it for today. Mediatomb is a GREAT project, I can't wait for the official release. In the meantime, there's already plenty to explore.

And by the way, Merry Christmas to all you geeks out there ;)

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

As requested, here's my config.xml file. You just change to change YouTube_Username, YouTube_Password, LastFM_Username & LastFM password to your own values.

<?xml version="1.0" encoding="UTF-8"?>
<config version="1" xmlns="http://mediatomb.cc/config/1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://mediatomb.cc/config/1 http://mediatomb.cc/config/1.xsd">
<server>
<ui enabled="yes" show-tooltips="yes">
<accounts enabled="no" session-timeout="30">
<account user="YouTube_Username" password="YouTube_Password"/>
</accounts>
</ui>
<name>MediaTomb</name>
<udn>uuid:b8b13d59-378e-4cb8-9a87-14f70c70f847</udn>
<home>/home/julien/.mediatomb</home>
<webroot>/usr/local/share/mediatomb/web</webroot>
<storage>
<sqlite3 enabled="yes">
<database-file>mediatomb.db</database-file>
</sqlite3>
</storage>
<protocolInfo extend="yes"/><!-- For PS3 support change to "yes" -->

<extended-runtime-options>
<ffmpegthumbnailer enabled="yes">
<thumbnail-size>128</thumbnail-size>
<seek-percentage>5</seek-percentage>
<filmstrip-overlay>yes</filmstrip-overlay>
<workaround-bugs>no</workaround-bugs>
</ffmpegthumbnailer>
<mark-played-items enabled="no" suppress-cds-updates="yes">
<string mode="prepend">*</string>
</mark-played-items>
</extended-runtime-options>

</server>

<import hidden-files="no">
<scripting script-charset="UTF-8">
<common-script>/usr/local/share/mediatomb/js/common.js</common-script>
<playlist-script>/usr/local/share/mediatomb/js/playlists.js</playlist-script>
<virtual-layout type="builtin">
<import-script>/usr/local/share/mediatomb/js/import.js</import-script>
<dvd-script>/usr/local/share/mediatomb/js/import-dvd.js</dvd-script>
</virtual-layout>
</scripting>
<mappings>
<extension-mimetype ignore-unknown="no">
<map from="mp3" to="audio/mpeg"/>
<map from="ogg" to="application/ogg"/>
<map from="asf" to="video/x-ms-asf"/>
<map from="asx" to="video/x-ms-asf"/>
<map from="wma" to="audio/x-ms-wma"/>
<map from="wax" to="audio/x-ms-wax"/>
<map from="wmv" to="video/x-ms-wmv"/>
<map from="wvx" to="video/x-ms-wvx"/>
<map from="wm" to="video/x-ms-wm"/>
<map from="wmx" to="video/x-ms-wmx"/>
<map from="m3u" to="audio/x-mpegurl"/>
<map from="pls" to="audio/x-scpls"/>
<map from="flv" to="video/x-flv"/>
<map from="avi" to="video/divx"/>
<map from="mkv" to="video/x-matroska"/>
<map from="mts" to="video/mpeg"/>
<map from="ts" to="video/mpeg"/>
<map from="m2ts" to="video/mpeg"/>

<map from="flac" to="audio/x-flac"/>
<map from="mov" to="video/x-quicktime"/>
<map from="vob" to="video/mpeg"/>
<map from="m4v" to="video/mp4"/>
<map from="iso" to="application/x-iso9660-image"/>

</extension-mimetype>
<mimetype-upnpclass>
<map from="audio/*" to="object.item.audioItem.musicTrack"/>
<map from="video/*" to="object.item.videoItem"/>
<map from="application/x-iso9660-image" to="object.item.videoItem"/>
<map from="image/*" to="object.item.imageItem"/>
</mimetype-upnpclass>
<mimetype-contenttype>
<treat mimetype="audio/mpeg" as="mp3"/>
<treat mimetype="application/ogg" as="ogg"/>
<treat mimetype="audio/x-flac" as="flac"/>
<treat mimetype="image/jpeg" as="jpg"/>
<treat mimetype="audio/x-mpegurl" as="playlist"/>
<treat mimetype="audio/x-scpls" as="playlist"/>
<treat mimetype="audio/x-wav" as="pcm"/>
<treat mimetype="video/x-msvideo" as="avi"/>
<treat mimetype="video/divx" as="avi"/>
<treat mimetype="video/mp4" as="mp4"/>
<treat mimetype="audio/mp4" as="mp4"/>

<treat mimetype="video/quicktime" as="mov"/>
<treat mimetype="video/x-quicktime" as="mov"/>

<treat mimetype="application/x-iso9660-image" as="dvd"/>

</mimetype-contenttype>
</mappings>
<online-content>
<!-- Make sure to setup a transcoding profile for flv -->
<YouTube enabled="yes" refresh="28800" update-at-start="yes" purge-after="604800" racy-content="exclude">
<favorites user="YouTube_Username"/>
<playlists user="YouTube_Username"/>
<uploads user="YouTube_Username"/>
<standardfeed feed="most_viewed" time-range="today"/>
<standardfeed feed="top_rated" time-range="this_week"/>
</YouTube>
<AppleTrailers enabled="yes" refresh="43200" update-at-start="yes" resolution="640"/>
</online-content>
</import>

<transcoding enabled="yes">
<mimetype-profile-mappings>
<transcode mimetype="application/ogg" using="audio-generic"/>
<transcode mimetype="audio/x-flac" using="audio-generic"/>
<transcode mimetype="video/x-ms-asf" using="video-generic"/>
<transcode mimetype="video/x-flv" using="video-generic"/>
<transcode mimetype="video/x-matroska" using="video-generic"/>
<transcode mimetype="video/x-quicktime" using="video-generic"/>
<transcode mimetype="video/quicktime" using="video-generic"/>
</mimetype-profile-mappings>
<profiles>

<profile name="audio-generic" enabled="yes" type="external" >
<mimetype>audio/L16</mimetype>
<first-resource>yes</first-resource>
<accept-url>yes</accept-url>
<sample-frequency>44100</sample-frequency>
<audio-channels>2</audio-channels>
<hide-original-resource>yes</hide-original-resource>
<agent command="ffmpeg" arguments="-ac 2 -ar 44100 -y -i %in -f s16be %out"/>
<buffer size="1048576" chunk-size="4096" fill-size="1024"/>
</profile>

<profile name="video-generic" enabled="yes" type="external">
<avi-fourcc-list mode="ignore">
<fourcc>DX50</fourcc>
<fourcc>DM4V</fourcc>
<fourcc>M4S2</fourcc>
</avi-fourcc-list>
<mimetype>video/mpeg</mimetype>
<accept-url>yes</accept-url>
<first-resource>yes</first-resource>
<hide-original-resource>yes</hide-original-resource>
<accept-ogg-theora>yes</accept-ogg-theora>
<agent command="/usr/local/bin/mediatomb-video-generic" arguments="%in %out"/>
<buffer size="1048576" chunk-size="26214" fill-size="52428"/>
</profile>

</profiles>
</transcoding>

<lastfm enabled="yes">
<username>LastFM_Username</username>
<password>LastFM_Password</password>
</lastfm>

</config>

Dec 23, 2008

VirtualBox 2.1.0 released, with much better network support

2.1.0 is a major update for VirtualBox. Here are the main new features:
  • Support for hardware virtualization (VT-x and AMD-V) on Mac OS X hosts
  • Support for 64-bit guests on 32-bit host operating systems (experimental)
  • Added support for Intel Nehalem virtualization enhancements
  • 3D acceleration via OpenGL (experimental)
  • LsiLogic and BusLogic SCSI controllers (experimental)
  • Full support of VMDK (VMware images) and VHD (Microsoft images) including snapshots
  • New NAT engine with signi´Čücantly better performance, reliability and ICMP echo (ping) support
  • New Host Interface Networking implementations for Windows and Linux hosts with easier setup (replaces TUN/TAP on Linux and manual bridging on Windows)
The last item is particularly important, as the default NAT setup in VirtualBox didn't allow guests to act as servers (and rightfully so!).

To run a guest as a server, you had to create a complex network configuration involving TUN/TAP devices, a bridge, etc. It kind of worked (not with wireless though) but who enjoys messing with their network setup? Not me.

Let's try it! Start VirtualBox, select your favorite guest and edit its network settings: that's Settings, then Network (duh). This brings you to the screen below.


All you need to do is:
  1. Set Attached to to 'Host Interface'
  2. Select in Host Interfaces the physical interface you want the guest to access (wlan0 in my case)
  3. Click OK and start the guest
Here's the network configuration for the CentOS 5.2 guest (/etc/sysconfig/network-scripts/ifcfg-eth0):

DEVICE=eth0
ONBOOT=yes
HWADDR=08:00:27:0A:91:29

If all goes well, the guest will use DHCP to get its network setup from my wireless router. Let's boot it.

A few seconds later: grrr, this is not working. Why?

A few minutes later: ah, silly me :) My wireless router is filtering MAC addresses (it's not because you're paranoid that they're not after you) and obviously it has never heard of the MAC address used by the guest. There are two options:
  1. Disable MAC address filtering (no way)
  2. Add the guest's MAC address to the list of authorized clients (you bet!)
OK, let's reboot the guest, log in and run a few network checks....

Ha ha, it looks like DHCP worked: I've got an IP address (ifconfig eth0), a default route to the gateway (route -a) and up to date DNS information (/etc/resolv.conf).

Let's ping the host:

[julien@centos ~]$ ping -c 3 192.168.0.2
PING 192.168.0.2 (192.168.0.2) 56(84) bytes of data.
64 bytes from 192.168.0.2: icmp_seq=1 ttl=64 time=0.340 ms
64 bytes from 192.168.0.2: icmp_seq=2 ttl=64 time=0.220 ms
64 bytes from 192.168.0.2: icmp_seq=3 ttl=64 time=0.276 ms
--- 192.168.0.2 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2006ms
rtt min/avg/max/mdev = 0.220/0.278/0.340/0.052 ms

Good, now let's ping the world :)

[julien@centos ~]$ ping -c 3 www.gnu.org
PING gnu.org (199.232.41.10) 56(84) bytes of data.
64 bytes from www.gnu.org (199.232.41.10): icmp_seq=1 ttl=48 time=141 ms
64 bytes from www.gnu.org (199.232.41.10): icmp_seq=2 ttl=48 time=141 ms
64 bytes from www.gnu.org (199.232.41.10): icmp_seq=3 ttl=48 time=139 ms
--- gnu.org ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2004ms
rtt min/avg/max/mdev = 139.440/140.698/141.344/0.941 ms

DNS and internet access are up as well. Now, let's try it from the host:

ubuntu% ping -c 3 192.168.0.6
PING 192.168.0.6 (192.168.0.6) 56(84) bytes of data.
64 bytes from 192.168.0.6: icmp_seq=1 ttl=64 time=0.401 ms
64 bytes from 192.168.0.6: icmp_seq=2 ttl=64 time=0.221 ms
64 bytes from 192.168.0.6: icmp_seq=3 ttl=64 time=0.235 ms
--- 192.168.0.6 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 1999ms
rtt min/avg/max/mdev = 0.221/0.285/0.401/0.084 ms

ubuntu% ssh julien@192.168.0.6
julien@192.168.0.6's password:
Last login: Tue Dec 23 15:00:58 2008 from 192.168.0.2
[julien@centos ~]$ exit

That's really cool: no more messing around with the network configuration. This makes VirtualBox even greater :)

Dec 22, 2008

HOWTO: compiling mediatomb + ffmpegthumbnailer + all libraries for Ubuntu... and PS3 :)

Today I'd like to talk about mediatomb, a media server with a nice web user interface allowing you to stream your digital media through your home network on a variety of 'Universal Plug and Play' (UPnP) compatible devices... such as the PS3 :)

Of course, you could just go and install a packaged version of the last official release (0.11) with apt-get, but:
  1. 0.11 was released in March'08, which means that you'll be missing the newest features
  2. that's not fun :)
So, let's get to work and take care of all dependencies needed to build mediatomb from source. This procedure was successfully performed on Ubuntu 8.04 and 8.10.

1) Installing ffmpegthumbnailer

ffmpegthumbnailer is a small tool which uses ffmpeg to generate video thumbnails. These thumbnails will be displayed by mediatomb while you're browsing your video collection.

[Updated on 2008/01/02] This supposes that you have built ffmpeg. If not, you may be missing a number of libraries: please check the comments below for solutions.

First, we need to install libpng:

ubuntu% sudo apt-get install libpng12-dev

Now, let's fetch the ffmpegthumbnailer source and build it:

ubuntu% wget http://ffmpegthumbnailer.googlecode.com/files/ffmpegthumbnailer-1.3.0.tar.gz
ubuntu% tar xvfz ffmpegthumbnailer-1.3.0.tar.gz
ubuntu% cd ffmpegthumbnailer-1.3.0
ubuntu% ./configure --prefix=/usr/local
ubuntu% make
ubuntu% sudo make install

OK, let's move on.

2a) Installing libdvdnav and libdvdread from source

These two libraries are used to browse DVD file structures: mediatomb needs them to read and stream DVD ISO images.

Since we're going to build the very latest mediatomb version, let's make sure we have up to date libs as well.

You do need to build and install libdvdread before libdvdnav, or the latter won't link.

ubuntu% wget ftp://ftp6.mplayerhq.hu/MPlayer/releases/dvdnav/libdvdread-4.1.3.tar.bz2
ubuntu% bzip2 -d libdvdread-4.1.3.tar.bz2
ubuntu% tar xvf libdvdread-4.1.3.tar
ubuntu% ./configure2 --prefix=/usr/local --enable-shared
ubuntu% make
ubuntu% sudo make install

ubuntu% wget ftp://ftp6.mplayerhq.hu/MPlayer/releases/dvdnav/libdvdnav-4.1.3.tar.bz2
ubuntu% bzip2 -d libdvdnav-4.1.3.tar.bz2
ubuntu% tar xvf libdvdnav-4.1.3.tar
ubuntu% ./configure2 --prefix=/usr/local --enable-shared
ubuntu% make
ubuntu% sudo make install

2b) Installing libdvdnav and libdvdread from APT

Both are available as APT packages (libdvdread-dev and libdvdnav-dev), but they're not up to date on Ubuntu 8.04. Anyway, if you don't want to build them, here's how to install them quickly:

ubuntu% sudo apt-get install libdvdread-dev libdvdnav-dev

3) Installing everything else

Sqlite3 is one of the two databases that mediatomb can use (the other is mySQL).

ubuntu% sudo apt-get install libsqlite3-dev

Libtag is needed to read tags in MP3 files, FLAC files and so on:

ubuntu% sudo apt-get install libtag1-dev

Libexpat is needed parse XML files:

ubuntu% sudo apt-get install libexpat1-dev

Libexif is needed to read tags stored in some digital pictures.

ubuntu% sudo apt-get install libexif-dev

Libmp4v2 is needed to parse mp4 files.

ubuntu% sudo apt-get install libmp4v2-dev

Libmagic helps to find the MIME type of a file based on the 'magic number' usually stored in the file header.

ubuntu% sudo apt-get install libmagic-dev

Libcurl is used to fetch web content using HTTP requests. This is how mediatomb can fetch YouTube content and stream it.

ubuntu% sudo apt-get install libcurl4-openssl-dev

Last, libmozjs is the JavaScript engine used by mediatomb.

ubuntu% sudo apt-get install libmozjs-dev

4) Building mediatomb

Let's fetch the latest sources from the Subversion repository:

ubuntu% svn co https://svn.mediatomb.cc/svnroot/mediatomb/trunk/mediatomb mediatomb

Now, let's generate the configure script and run it (you need autoconf and automake for this):

ubuntu% cd mediatomb
ubuntu% autoreconf -i
ubuntu% ./configure --prefix=/usr/local
lots of output removed
CONFIGURATION SUMMARY ----
sqlite3 : yes
mysql : missing
libjs : yes
libmagic : yes
inotify : yes
libexif : yes
id3lib : disabled
taglib : yes
libmp4v2 : yes
libdvdnav : yes
ffmpeg : yes
ffmpegthumbnailer : yes
external transcoding : yes
curl : yes
YouTube : yes
Weborama : disabled
Apple Trailers : yes
SopCast : disabled
libextractor : disabled
db-autocreate : yes

As you can see, we have pretty much enabled everything (again, sqlite3 is preferred over mySQL, and taglib over id3lib). Support for SopCast and Weborama isn't completely ready yet, so it's probably safer to leave them out.

All right, let's build mediatomb:

ubuntu% make
ubuntu% sudo make install
ubuntu% sudo ldconfig

And now...

ubuntu% mediatomb
MediaTomb UPnP Server version 0.12.0 - http://mediatomb.cc/
===============================================================================
Copyright 2005-2008 Gena Batsyan, Sergey Bostandzhyan, Leonhard Wimmer.
MediaTomb is free software, covered by the GNU General Public License version 2


All right. Let's power up the PS3 and see if it can see the mediatomb server.



Yes it does. Now using the mediatomb GUI, in just a few clicks, I added some pictures and music to my library. They are almost immediately visible on the PS3:



Not bad at all! That's it for the mediatomb installation. There's still plenty of configuration to do, but this will be the subject of another entry :)

Dec 21, 2008

HOWTO: installing gmake, gcc, svn and git on OpenSolaris

OpenSolaris is a cool OS, but it's lacking a lot of software packages present in all Linux distributions. This should improve gradually, but in the meantime, you probably will have to rebuild a lot of stuff from source.

However, some really basic tools are not installed by default:
  • GNU make,
  • gcc / g++, the GNU C / C++ compilers,
  • svn, a well-known revision control system,
  • git, another well-known revision control system
Let's take care of this.

1) Installing GNU make

julien@opensolaris:~$ sudo pkg install SUNWgmake
DOWNLOAD PKGS FILES XFER (MB)
Completed 1/1 6/6 0.22/0.22
PHASE ACTIONS
Install Phase 31/31
PHASE ITEMS
Reading Existing Index 9/9
Indexing Packages 1/1
julien@opensolaris:~$ gmake
gmake: *** No targets specified and no makefile found. Stop.


2) Installing GNU C / C++

julien@opensolaris:~$ sudo pkg install SUNWgcc
DOWNLOAD PKGS FILES XFER (MB)
Completed 4/4 2086/2086 29.94/29.94
PHASE ACTIONS
Install Phase 2512/2512
PHASE ITEMS
Reading Existing Index 9/9
Indexing Packages 4/4
julien@opensolaris:~$ gcc
gcc: no input files

3) Installing Subversion

julien@opensolaris:~$ sudo pkg install SUNWsvn
DOWNLOAD PKGS FILES XFER (MB)
Completed 4/4 249/249 2.05/2.05
PHASE ACTIONS
Install Phase 372/372
PHASE ITEMS
Reading Existing Index 9/9
Indexing Packages 4/4
julien@opensolaris:~$ svn
Type 'svn help' for usage.

4) Installing Git

Let's build Git from source. You need to download the latest stable release from the Git homepage (1.6.0.6 at the time of writing):

julien@opensolaris:~$ wget http://kernel.org/pub/software/scm/git/git-1.6.0.6.tar.bz2
--20:23:40-- http://kernel.org/pub/software/scm/git/git-1.6.0.6.tar.bz2
=> `git-1.6.0.6.tar.bz2'
Resolving kernel.org... 149.20.20.133, 204.152.191.37
Connecting to kernel.org|149.20.20.133|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1,882,225 (1.8M) [application/x-bzip2]
100%[====================================>] 1,882,225 126.47K/s ETA 00:00
20:23:55 (122.96 KB/s) - `git-1.6.0.6.tar.bz2' saved [1882225/1882225]

julien@opensolaris:~$ bzip2 -d git-1.6.0.6.tar.bz2
julien@opensolaris:~$ tar xvf git-1.6.0.6.tar
julien@opensolaris:~$ cd git-1.6.0.6
julien@opensolaris:~$ ./configure --prefix=/usr/local
julien@opensolaris:~$ gmake
julien@opensolaris:~$ sudo make install
julien@opensolaris:~$ git --version
git version 1.6.0.6

Done! Now we have a basic build environment on OpenSolaris :)

You also may want to check the 'GNU' section in the graphical Package Manager: it lists all GNU packages available for OpenSolaris, including automake, autoconf, etc.

HOWTO: compiling VLC + live555 + all major codecs on Ubuntu

[Updated on 2009/04/03] VLC 0.9.9 is out. Here is the updated tutorial.


In yesterday's post, I showed you how to build a pretty complete ffmpeg.

Today, let's build the latest VLC from source on Ubuntu 8.04.

VLC is the best audio / video player there is, but just like ffmpeg, the binary found in Linux distributions is often outdated and incomplete... and we all know that it's quite frustrating to get stuck with files that you can't play.

For starters, you have to go through yesterday's post:
  1. we need the build directories of ffmpeg and x264 for the VLC build,
  2. up to date versions are required anyway,
  3. building and installing them will take care of a number of dependencies.
Once you've done that, there are additional dependencies to take care of.

1) Installing libmad

MAD is a high-quality MPEG audio decoder. At the time of this writing, the latest version is 0.15.1b. Let's get the source, build it and install it:

ubuntu% wget http://ovh.dl.sourceforge.net/sourceforge/mad/libmad-0.15.1b.tar.gz
ubuntu% tar xvfz libmad-0.15.1b.tar.gz
ubuntu% cd libmad-0.15.1b
ubuntu% ./configure --prefix=/usr/local
ubuntu% make
ubuntu% sudo make install


[Updated on 2009/01/04] If you try to compile libmad with gcc 4.3, you will get the following error: cc1: error: unrecognized command line option "-fforce-mem". To correct this, just remove the -fforce-mem flags from the CFLAGS list in the Makefile.

2) Installing libdca

libdca is a free library for DTS audio. 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

3) Installing libmpeg2

libmpeg2 is a free library for MPEG streams. At the time of this writing, the latest version is 2.0.5.1. Let's get the source, build it and install it:

ubuntu% wget http://libmpeg2.sourceforge.net/files/libmpeg2-0.5.1.tar.gz
ubuntu% tar xvfz libmpeg2-0.5.1.tar.gz
ubuntu% cd
libmpeg2-0.5.1
ubuntu% ./configure --prefix=/usr/local
ubuntu% make
ubuntu% sudo make install


4) Installing TagLib

TagLib is is a library for reading and editing the meta-data of several popular audio formats (MP3, FLAC, etc). At the time of this writing, the latest version is 1.5. Let's get the source, build it and install it:

ubuntu% wget http://developer.kde.org/~wheeler/files/src/taglib-1.5.tar.gz
ubuntu% tar xvfz taglib-1.5.tar.gz
ubuntu% ./configure --prefix=/usr/local
ubuntu% make
ubuntu% sudo make install


5) Installing live555

live555 is a set of libraries for multimedia streaming (RTP/RTCP, RTSP, SIP).

ubuntu% wget http://www.live555.com/liveMedia/public/live555-latest.tar.gz
ubuntu% tar xvfz live555-latest.tar.gz
ubuntu% cd live
ubuntu% ./genMakefiles linux
ubuntu% make

There is no installation procedure for live555. You have to copy the full directory somewhere safe, like /usr/lib.

ubuntu% sudo cp -r live /usr/lib

6) Installing everything else

Now, let's use APT to fetch all the remaining libraries needed by VLC, as well as the Qt4 packages required by the GUI:

ubuntu% sudo apt-get install libavc1394-dev libraw1394-dev libdc1394-dev libdvdread-dev libdvdnav-dev libdvdcss2-dev libfaad-dev libtwolame-dev liba52-dev libvcdinfo-dev libiso9660-dev libcddb2-dev libflac-dev libschroedinger-dev liba52-dev libogg-dev libvorbis-dev liblua5.1-0-dev libgnomevfs2-dev libtag1-dev libqt4-dev

That should really be it...

7) Fetching VLC

Stable sources can be downloaded as a tarball from the VLC download page. At the time of this writing, the latest version is VLC 0.9.8a. If you want to try development snapshots, be my guest but YMMV!

ubuntu% wget http://download.videolan.org/pub/videolan/vlc/0.9.8a/vlc-0.9.8a.tar.bz2
ubuntu% bzip2 -d vlc-0.9.8a.tar.bz2
ubuntu% tar xvf vlc-0.9.8a.tar


8) Adding ffmpeg, x264 and live555 to the mix

For the sake of convenience, let's copy the three build directories into the VLC tree:

ubuntu% cd vlc-0.9.8a
ubuntu% cp -r $YOUR_FFMPEG_BUILD_DIR extras
ubuntu% cp -r $YOUR_X264_BUILD_DIR extras
ubuntu% cp -r $YOUR_LIVE555_BUILD_DIR extras
ubuntu% ls extras
analyser buildsystem contrib ffmpeg live misc package x264

9) Building VLC

Let's go! Don't forget to check your configure output for possible errors.

[Updated on 2009/02/23: added support for XVID & FLV formats through ffmpeg]

ubuntu%
./configure --prefix=/usr/local --with-ffmpeg-tree=extras/ffmpeg --with-x264-tree=extras/x264 --with-live555-tree=extras/live --enable-release --enable-switcher --enable-shout --enable-dc1394 --enable-dv --enable-dvdread --enable-v4l --enable-pvr --enable-gnomevfs --enable-vcdx --enable-faad --enable-twolame --enable-real --enable-realrtsp --enable-flac --enable-tremor --enable-tarkin --enable-theora --enable-ogg --enable-vorbis --enable-a52 --enable-gnomevfs --enable-dca --with-ffmpeg-flv --with-ffmpeg-xvid
UNIX-related output removed
checking for SHOUT... no
configure: WARNING: libshout library not found
checking for LUA... yes
checking proxy.h usability... no
checking proxy.h presence... no
checking for proxy.h... no
checking for NOTIFY... no
checking for TAGLIB... yes
checking for liveMedia/libliveMedia.a in extras/live... /home/julien/tmp/vlc-0.9.8a/extras/live/liveMedia/libliveMedia.a
checking /home/julien/tmp/vlc-0.9.8a/extras/live/liveMedia/include/liveMedia_version.hh usability... yes
checking /home/julien/tmp/vlc-0.9.8a/extras/live/liveMedia/include/liveMedia_version.hh presence... yes
checking for /home/julien/tmp/vlc-0.9.8a/extras/live/liveMedia/include/liveMedia_version.hh... yes
checking for liveMedia version >= 1214895600 ... yes
checking libraw1394/raw1394.h usability... yes
checking libraw1394/raw1394.h presence... yes
checking for libraw1394/raw1394.h... yes
checking for raw1394_get_nodecount in -lraw1394... yes
checking libdc1394/dc1394_control.h usability... yes
checking libdc1394/dc1394_control.h presence... yes
checking for libdc1394/dc1394_control.h... yes
checking for libraw1394/raw1394.h... (cached) yes
checking libavc1394/avc1394.h usability... yes
checking libavc1394/avc1394.h presence... yes
checking for libavc1394/avc1394.h... yes
checking dvdread/dvd_reader.h usability... yes
checking dvdread/dvd_reader.h presence... yes
checking for dvdread/dvd_reader.h... yes
checking for dvdnav-config... /usr/local/bin/dvdnav-config
checking libsmbclient.h usability... no
checking libsmbclient.h presence... no
checking for libsmbclient.h... no
checking for struct _SMBCCTX.close_fn... no
checking for dvbpsi/dr.h... yes
checking for dvbpsi_GenSDTSections in -ldvbpsi... yes
checking linux/videodev.h usability... yes
checking linux/videodev.h presence... yes
checking for linux/videodev.h... yes
checking alsa/asoundlib.h usability... yes
checking alsa/asoundlib.h presence... yes
checking for alsa/asoundlib.h... yes
checking for main in -lasound... yes
checking linux/videodev2.h usability... yes
checking linux/videodev2.h presence... yes
checking for linux/videodev2.h... yes
checking for LIBV4L2... no
configure: WARNING: LibV4L2 support disabled because libv4l2 development headers were not found
checking for new linux/videodev2.h... yes
checking for GNOMEVFS... yes
checking for LIBCDIO... yes
checking for VCDINFO... yes
checking for LIBCDIO... yes
checking for cdrom_msf0 in linux/cdrom.h... yes
checking for scsireq in sys/scsiio.h... no
checking for ioc_toc_header in sys/cdio.h... no
checking for LIBCDDB... yes
checking linux/dvb/version.h usability... yes
checking linux/dvb/version.h presence... yes
checking for linux/dvb/version.h... yes
checking linux/dvb/frontend.h usability... yes
checking linux/dvb/frontend.h presence... yes
checking for linux/dvb/frontend.h... yes
checking X11/Xlib.h usability... yes
checking X11/Xlib.h presence... yes
checking for X11/Xlib.h... yes
checking for inet_pton... yes
checking for inet_ntop... yes
checking ogg/ogg.h usability... yes
checking ogg/ogg.h presence... yes
checking for ogg/ogg.h... yes
checking for oggpack_read in -logg... yes
checking ebml/EbmlVersion.h usability... no
checking ebml/EbmlVersion.h presence... no
checking for ebml/EbmlVersion.h... no
checking libmodplug/modplug.h usability... no
checking libmodplug/modplug.h presence... no
checking for libmodplug/modplug.h... no
checking mpcdec/mpcdec.h usability... no
checking mpcdec/mpcdec.h presence... no
checking for mpcdec/mpcdec.h... no
configure: WARNING: only static linking is available, you must provide a gme-tree
checking mad.h usability... yes
checking mad.h presence... yes
checking for mad.h... yes
checking for mad_bit_init in -lmad... yes
checking id3tag.h usability... no
checking id3tag.h presence... no
checking for id3tag.h... no
configure: WARNING: --with-ffmpeg-tree is deprecated. Use PKG_CONFIG_PATH instead.
checking for AVCODEC... yes
checking libavcodec/avcodec.h usability... yes
checking libavcodec/avcodec.h presence... yes
checking for libavcodec/avcodec.h... yes
checking ffmpeg/avcodec.h usability... no
checking ffmpeg/avcodec.h presence... no
checking for ffmpeg/avcodec.h... no
checking libavutil/avutil.h usability... yes
checking libavutil/avutil.h presence... yes
checking for libavutil/avutil.h... yes
checking ffmpeg/avutil.h usability... no
checking ffmpeg/avutil.h presence... no
checking for ffmpeg/avutil.h... no
checking for AVFORMAT... yes
checking libavformat/avformat.h usability... yes
checking libavformat/avformat.h presence... yes
checking for libavformat/avformat.h... yes
checking ffmpeg/avformat.h usability... no
checking ffmpeg/avformat.h presence... no
checking for ffmpeg/avformat.h... no
checking for libavutil/avutil.h... (cached) yes
checking for ffmpeg/avutil.h... (cached) no
checking for SWSCALE... yes
checking libswscale/swscale.h usability... yes
checking libswscale/swscale.h presence... yes
checking for libswscale/swscale.h... yes
checking ffmpeg/swscale.h usability... no
checking ffmpeg/swscale.h presence... no
checking for ffmpeg/swscale.h... no
checking for POSTPROC... yes
checking libpostproc/postproc.h usability... no
checking libpostproc/postproc.h presence... no
checking for libpostproc/postproc.h... no
checking postproc/postprocess.h usability... no
checking postproc/postprocess.h presence... no
checking for postproc/postprocess.h... no
checking faad.h usability... yes
checking faad.h presence... yes
checking for faad.h... yes
checking for faacDecOpen in -lfaad... no
checking for NeAACDecOpen in -lfaad... yes
checking twolame.h usability... yes
checking twolame.h presence... yes
checking for twolame.h... yes
checking for twolame_init in -ltwolame... yes
checking for zlib.h... (cached) yes
checking sysfs/libsysfs.h usability... no
checking sysfs/libsysfs.h presence... no
checking for sysfs/libsysfs.h... no
checking libtar.h usability... no
checking libtar.h presence... no
checking for libtar.h... no
checking a52dec/a52.h usability... yes
checking a52dec/a52.h presence... yes
checking for a52dec/a52.h... yes
checking for a52_free in -la52... yes
checking for DCA... yes
checking FLAC/stream_decoder.h usability... yes
checking FLAC/stream_decoder.h presence... yes
checking for FLAC/stream_decoder.h... yes
checking for LIBMPEG2... yes
checking vorbis/codec.h usability... yes
checking vorbis/codec.h presence... yes
checking for vorbis/codec.h... yes
checking vorbis/vorbisenc.h usability... yes
checking vorbis/vorbisenc.h presence... yes
checking for vorbis/vorbisenc.h... yes
checking tremor/ivorbiscodec.h usability... no
checking tremor/ivorbiscodec.h presence... no
checking for tremor/ivorbiscodec.h... no
checking speex/speex.h usability... yes
checking speex/speex.h presence... yes
checking for speex/speex.h... yes
checking for speex_decode_int in -lspeex... yes
checking theora/theora.h usability... yes
checking theora/theora.h presence... yes
checking for theora/theora.h... yes
checking for theora_granule_time in -ltheora... yes
checking for SCHROEDINGER... yes
checking png.h usability... yes
checking png.h presence... yes
checking for png.h... yes
checking for png_set_rows in -lpng... yes
checking for x264.h in /home/julien/tmp/vlc-0.9.8a/extras/x264... yes
checking for X264... yes
checking for FLUIDSYNTH... no
checking for ZVBI... no
configure: WARNING: ZVBI library not found. Enabling the telx module instead
checking for KATE... no
checking kate/kate.h usability... no
checking kate/kate.h presence... no
checking for kate/kate.h... no
checking for X11/extensions/dpms.h... yes
checking for DPMSInfo in X11/extensions/dpms.h... yes
checking for X11/Xlib.h... (cached) yes
checking for XShmAttach in -lXext... yes
checking X11/extensions/Xv.h usability... yes
checking X11/extensions/Xv.h presence... yes
checking for X11/extensions/Xv.h... yes
checking for XvPutImage in -lXv... yes
checking for X11/Xlib.h... (cached) yes
checking GL/glu.h usability... yes
checking GL/glu.h presence... yes
checking for GL/glu.h... yes
checking GL/glx.h usability... yes
checking GL/glx.h presence... yes
checking for GL/glx.h... yes
checking X11/extensions/Xinerama.h usability... yes
checking X11/extensions/Xinerama.h presence... yes
checking for X11/extensions/Xinerama.h... yes
checking for XineramaQueryExtension in -lXinerama_pic... no
checking for XineramaQueryExtension in -lXinerama... yes
checking for X11/extensions/xf86vmode.h... no
checking GL/gl.h usability... yes
checking GL/gl.h presence... yes
checking for GL/gl.h... yes
checking for GL/glu.h... (cached) yes
checking for sdl12-config... no
checking for sdl11-config... no
checking for sdl-config... /usr/bin/sdl-config
checking SDL/SDL.h usability... yes
checking SDL/SDL.h presence... yes
checking for SDL/SDL.h... yes
checking SDL/SDL_image.h usability... no
checking SDL/SDL_image.h presence... no
checking for SDL/SDL_image.h... no
checking SDL_image.h usability... no
checking SDL_image.h presence... no
checking for SDL_image.h... no
configure: WARNING: The development package for SDL_image is not installed.
You should install it alongside your SDL package.
checking for FREETYPE... yes
checking fontconfig/fontconfig.h usability... yes
checking fontconfig/fontconfig.h presence... yes
checking for fontconfig/fontconfig.h... yes
checking Carbon/Carbon.h usability... no
checking Carbon/Carbon.h presence... no
checking for Carbon/Carbon.h... no
checking for FRIBIDI... yes
checking for xml2-config... /usr/bin/xml2-config
checking for xmlTextReaderConstName in -lxml2... yes
checking cascade/graphics/CascadeScreen.h usability... no
checking cascade/graphics/CascadeScreen.h presence... no
checking for cascade/graphics/CascadeScreen.h... no
configure: WARNING: Not building Roku HD1000 compatible video output
checking cascade/graphics/CascadeBitmap.h usability... no
checking cascade/graphics/CascadeBitmap.h presence... no
checking for cascade/graphics/CascadeBitmap.h... no
configure: WARNING: Not building Roku HD1000 compatible video output
checking linux/fb.h usability... yes
checking linux/fb.h presence... yes
checking for linux/fb.h... yes
checking soundcard.h usability... no
checking soundcard.h presence... no
checking for soundcard.h... no
checking sys/soundcard.h usability... yes
checking sys/soundcard.h presence... yes
checking for sys/soundcard.h... yes
checking for main in -lossaudio... no
checking machine/soundcard.h usability... no
checking machine/soundcard.h presence... no
checking for machine/soundcard.h... no
checking for PULSE... no
configure: WARNING: pulseaudio library not found
checking for alsa/asoundlib.h... (cached) yes
checking for main in -lasound... (cached) yes
checking deschutes/libraries/hdmachinex225/PCMAudioPlayer.h usability... no
checking deschutes/libraries/hdmachinex225/PCMAudioPlayer.h presence... no
checking for deschutes/libraries/hdmachinex225/PCMAudioPlayer.h... no
checking for UpnpInit in -lupnp... no
checking for QT4... yes
checking for moc-qt4... /usr/bin/moc-qt4
checking for rcc... /usr/bin/rcc
checking for uic-qt4... /usr/bin/uic-qt4
checking Ph.h usability... no
checking Ph.h presence... no
checking for Ph.h... no
checking for BONJOUR... yes
checking for BONJOUR... yes
checking for libgcrypt-config... /usr/bin/libgcrypt-config
checking for LIBGCRYPT - version >= 1.1.94... yes (1.4.1)
checking LIBGCRYPT API version... okay
checking for GNUTLS... yes
checking whether byte ordering is bigendian... no
checking for osso_display_blanking_pause in -losso... no
checking for XSPSetPixelDoubling in -lXsp... no
configure: creating ./vlc-config.in
configure: creating ./config.status
config.status: creating extras/package/win32/vlc.win32.nsi
config.status: creating extras/package/macosx/Info.plist
config.status: creating extras/package/macosx/Resources/English.lproj/InfoPlist.strings
config.status: creating extras/package/macosx/plugin/Info.plist
config.status: creating extras/package/macosx/plugin/InstallerInfo.plist
config.status: creating extras/package/macosx/plugin/English.lproj/InfoPlist.strings
config.status: creating Makefile
config.status: creating projects/activex/Makefile
config.status: creating projects/activex/axvlc.inf
config.status: creating doc/Makefile
config.status: creating extras/package/ipkg/Makefile
config.status: creating libs/loader/Makefile
config.status: creating libs/srtp/Makefile
config.status: creating modules/Makefile
config.status: creating projects/mozilla/Makefile
config.status: creating m4/Makefile
config.status: creating po/Makefile.in
config.status: creating projects/activex/axvlc_rc.rc
config.status: creating projects/mozilla/npvlc_rc.rc
config.status: creating share/Makefile
config.status: creating share/vlc_win32_rc.rc
config.status: creating share/libvlc_win32_rc.rc
config.status: creating src/Makefile
config.status: creating src/test/Makefile
config.status: creating bin/Makefile
config.status: creating test/Makefile
config.status: creating modules/access/Makefile
config.status: creating modules/access/bda/Makefile
config.status: creating modules/access/dshow/Makefile
config.status: creating modules/access/dvb/Makefile
config.status: creating modules/access/mms/Makefile
config.status: creating modules/access/cdda/Makefile
config.status: creating modules/access/rtsp/Makefile
config.status: creating modules/access/rtmp/Makefile
config.status: creating modules/access/v4l2/Makefile
config.status: creating modules/access/vcd/Makefile
config.status: creating modules/access/vcdx/Makefile
config.status: creating modules/access/screen/Makefile
config.status: creating modules/access_filter/Makefile
config.status: creating modules/access_output/Makefile
config.status: creating modules/audio_filter/Makefile
config.status: creating modules/audio_filter/channel_mixer/Makefile
config.status: creating modules/audio_filter/converter/Makefile
config.status: creating modules/audio_filter/resampler/Makefile
config.status: creating modules/audio_filter/spatializer/Makefile
config.status: creating modules/audio_mixer/Makefile
config.status: creating modules/audio_output/Makefile
config.status: creating modules/codec/Makefile
config.status: creating modules/codec/avcodec/Makefile
config.status: creating modules/codec/cmml/Makefile
config.status: creating modules/codec/dmo/Makefile
config.status: creating modules/codec/subtitles/Makefile
config.status: creating modules/codec/spudec/Makefile
config.status: creating modules/codec/xvmc/Makefile
config.status: creating modules/control/Makefile
config.status: creating modules/control/http/Makefile
config.status: creating modules/demux/Makefile
config.status: creating modules/demux/asf/Makefile
config.status: creating modules/demux/avformat/Makefile
config.status: creating modules/demux/avi/Makefile
config.status: creating modules/demux/mp4/Makefile
config.status: creating modules/demux/mpeg/Makefile
config.status: creating modules/demux/playlist/Makefile
config.status: creating modules/gui/Makefile
config.status: creating modules/gui/beos/Makefile
config.status: creating modules/gui/pda/Makefile
config.status: creating modules/gui/macosx/Makefile
config.status: creating modules/gui/minimal_macosx/Makefile
config.status: creating modules/gui/qnx/Makefile
config.status: creating modules/gui/qt4/Makefile
config.status: creating modules/gui/skins2/Makefile
config.status: creating modules/gui/wince/Makefile
config.status: creating modules/meta_engine/Makefile
config.status: creating modules/misc/Makefile
config.status: creating modules/misc/dummy/Makefile
config.status: creating modules/misc/lua/Makefile
config.status: creating modules/misc/memcpy/Makefile
config.status: creating modules/misc/notify/Makefile
config.status: creating modules/misc/testsuite/Makefile
config.status: creating modules/misc/playlist/Makefile
config.status: creating modules/misc/osd/Makefile
config.status: creating modules/misc/stats/Makefile
config.status: creating modules/misc/xml/Makefile
config.status: creating modules/misc/probe/Makefile
config.status: creating modules/mux/Makefile
config.status: creating modules/mux/mpeg/Makefile
config.status: creating modules/packetizer/Makefile
config.status: creating modules/services_discovery/Makefile
config.status: creating modules/stream_out/Makefile
config.status: creating modules/stream_out/transrate/Makefile
config.status: creating modules/video_chroma/Makefile
config.status: creating modules/video_filter/Makefile
config.status: creating modules/video_filter/atmo/Makefile
config.status: creating modules/video_filter/dynamicoverlay/Makefile
config.status: creating modules/video_output/Makefile
config.status: creating modules/video_output/msw/Makefile
config.status: creating modules/video_output/qte/Makefile
config.status: creating modules/video_output/x11/Makefile
config.status: creating modules/visualization/Makefile
config.status: creating modules/visualization/visual/Makefile
config.status: creating modules/visualization/galaktos/Makefile
config.status: creating config.h
config.status: config.h is unchanged
config.status: executing depfiles commands
config.status: executing libtool commands
config.status: executing po-directories commands
config.status: creating po/POTFILES
config.status: creating po/Makefile
config.status: creating vlc-config
Enabled modules: a52 a52tofloat32 a52tospdif access_dv access_filter_bandwidth access_filter_dump access_filter_record access_filter_timeshift access_gnomevfs access_mmap access_realrtsp adjust adpcm alphamask alsa aout_file aout_sdl araw asf atmo audio_format audioscrobbler avcodec avformat avi bandlimited_resampler blend blendbench bluescreen bonjour canvas cc cdda cdg chain cinepak clone cmml colorthres converter_fixed converter_float crop croppadd cvdsub dbus dc1394 deinterlace dolby_surround_decoder dts dtstofloat32 dtstospdif dummy dvb dvb dvbsub dvdnav dvdread dynamicoverlay equalizer erase export extract faad fake fb flac float32_mixer folder freetype gaussianblur gestures glx gnutls gradient grain grey_yuv h264 hal headphone_channel_mixer hotkeys http i420_rgb i420_rgb_mmx i420_rgb_sse2 i420_ymga i420_ymga_mmx i420_yuy2 i420_yuy2_mmx i420_yuy2_sse2 i422_i420 i422_yuy2 i422_yuy2_mmx i422_yuy2_sse2 image inhibit invert libmpeg2 linear_resampler live555 logger logo lpcm m4a m4v magnify marq memcpy memcpy3dn memcpymmx memcpymmxext mono mosaic motion motionblur motiondetect mp4 mpeg_audio mpga mpgatofixed32 mpgv mux_ogg mux_ts noise normvol nsc ogg opengl opengl osd_parser osdmenu oss panoramix param_eq playlist png podcast postproc probe_hal ps psychedelic puzzle pvr qt4 rawvideo rc realaudio realvideo remoteosd ripple rotate rss rv32 sap scale scaletempo schroedinger screen screensaver sharpen shout showintf signals simple_channel_mixer skins2 spatializer spdif_mixer speex spudec stats subsdec subsusf svcdsub swscale t140 taglib telepathy telnet telx theora transform trivial_channel_mixer trivial_mixer trivial_resampler ts twolame ugly_resampler v4l v4l2 vcd vcdx visual vmem vorbis vout_sdl wall wave x11 x264 xml xtag xvideo yuy2_i420 yuy2_i422


libvlc configuration
--------------------
version : 0.9.8a
system : linux
architecture : i686 mmx sse sse2
build flavour : release
vlc aliases : cvlc rvlc svlc qvlc
plugins/bindings :

You can tune the compiler flags in vlc-config.
To build vlc and its plugins, type `./compile' or `make'.

All right, let's run make and get some coffee while VLC is building:

ubuntu% make
lots of output removed
make[2]: Leaving directory `/home/julien/tmp/vlc-0.9.8a'
make[1]: Leaving directory `/home/julien/tmp/vlc-0.9.8a'

We're done! Let's check our new VLC before we install it.

7) Checking VLC

ubuntu% ./vlc --version
VLC media player 0.9.8a Grishenko
[00000001] main libvlc debug: VLC media player - version 0.9.8a Grishenko - (c) 1996-2008 the VideoLAN team
[00000001] main libvlc debug: libvlc was configured with ./configure '--prefix=/usr/local' '--with-ffmpeg-tree=extras/ffmpeg' '--with-x264-tree=extras/x264' '--with-live555-tree=extras/live' '--enable-release' '--enable-switcher' '--enable-shout' '-enable-dc1394' '--enable-dv' '--enable-dvdread' '--enable-v4l' '--enable-pvr' '--enable-gnomevfs' '--enable-vcdx' '--enable-faad' '--enable-twolame' '--enable-real' '--enable-realrtsp' '--enable-flac' '--enable-tremor' '--enable-tarkin' '--enable-theora'
'--enable-ogg' '--enable-vorbis' '--enable-a52' '--enable-gnomevfs' '--with-ffmpeg-flv' '--with-ffmpeg-xvid'
[00000001] main libvlc debug: translation test: code is "C"
VLC version 0.9.8a Grishenko
Compiled by julien@ubuntu.
Compiler: gcc version 4.2.4 (Ubuntu 4.2.4-1ubuntu3)
This program comes with NO WARRANTY, to the extent permitted by law.
You may redistribute it under the terms of the GNU General Public License;
see the file named COPYING for details.
Written by the VideoLAN team; see the AUTHORS file.

Looks good. You can verify that your favorite codecs are supported with 'vlc --list', e.g.:

ubuntu% ./vlc --list|grep -i h264
output removed
h264 H264 video demuxer
packetizer_h264 H.264 video packetizer
h264 H264 video demuxer
packetizer_h264 H.264 video packetizer

Let's also run a quick transcoding test:

ubuntu% ./cvlc file://clip.mov --sout="#transcode{vcodec=h264,vb=1024,acodec=mpga,ab=128}:std{access=file,mux=mp4,dst=clip.mp4}" vlc://quit
VLC media player 0.9.8a Grishenko
output removed
x264 [info]: using SAR=53889/54000
x264 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 Cache64
x264 [info]: profile Main, level 5.1
x264 [info]: slice I:141 Avg QP:20.66 size: 14629
x264 [info]: slice P:4027 Avg QP:24.82 size: 8194
x264 [info]: mb I I16..4: 46.2% 0.0% 53.8%
x264 [info]: mb P I16..4: 19.5% 0.0% 23.0% P16..4: 18.3% 11.5% 2.4% 0.0% 0.0% skip:25.4%
x264 [info]: kb/s:1009.4
[00000499] dummy demux: command `quit'
ubuntu% ls -l clip*
-rw-r--r-- 1 julien julien 91322704 2008-12-25 22:08 clip.mov
-rw-r--r-- 1 julien julien 39719104 2008-12-25 22:17 clip.mp4

And since VLC can play that new mp4 clip, I declare this a good build :) Let's install it:

ubuntu% sudo make install

We're done. Now you can enjoy all your media files with a single player!