lunedì 25 febbraio 2013

Streaming DVD iso with MediaTomb and VLC

Long time ago I backed up a couple of dvds as iso image files and now I'd like to watch them. My DLNA Player is a Sony BDP-S790: it can play video/music/photo files stored on another DLNA-compatible product (DLNA Server) via a network. I will use MediaTomb as DLNA server on Ubuntu 12.10 and VLC to stream video and audio data. VLC will not execute a real transcode saving your cpu: this is very useful, especially if your pc is quite old.

First of all I have to prepare the DLNA-compatible product (MediaTomb):


By default MediaTomb doesn't recognize an ISO file so we want to add a mapping for that to the <extension-mimetype> section in our config.xml. Let's import the mime type information of an iso file manually by adding this line to our /etc/mediatomb/config.xml:

 <map from="iso" to="video/dvdiso"/>


The transcoding section allows to define a way on how to transcode content, so we have to enable it in this way:

 <transcoding enabled="yes"...


Now we can add this line to the transcoding section:

 <transcode mimetype="video/dvdiso" using="vlcimage"/>


vlcimage is the transcoding profile that will handle the mime type above and it will be defined in the profile section.

 <profile name="vlcimage" enabled="yes" type="external">
      <mimetype>video/mpeg</mimetype>
      <accept-url>no</accept-url>
      <first-resource>yes</first-resource>
      <accept-ogg-theora>no</accept-ogg-theora>
      <agent command="vlc" arguments="-I dummy dvdsimple://%in :sout=#duplicate{dst=std{access=file,mux=ps,dst=%out}}} --sout-all vlc:quit"/> <buffer size="14400000" chunk-size="512000" fill-size="120000"/>
 </profile>


Let's have a closer look:

We need to define which mime type we are transcoding to - that's what the player device will see. It must be something it supports and there are also some other limitations: the output format must be streamable - meaning, it must be a format which can be played back without the need of seeking in the stream. So, let's specify our target mime type with <mimetype>video/mpeg</mimetype>

The agent parameter tells MediaTomb which application to execute and it also provides the necessary command line options for it. In the above example the command to be executed is “vlc, it will be called with parameter specified in the arguments attribute. Note the special %in and %out tokens - they are not part of the vlc command line but have a special meaning in MediaTomb. The %in token will be replaced by the input file name (i.e. the file that needs to be transcoded) and the %out token will be replaced by the output FIFO name, from where the transcoded content will be read by MediaTomb and sent to the player.

The parameter sout-all is quite important because it allows us to stream all soundtracks and subtitles: usually DVDs offer different languages. The parameter dvdsimple allows us to stream the DVD without menus. If we want menus we can replace dvdsimple with dvd (untested).

Now, the last step: add these lines  to the protocolInfo section (enabled):

 <custom-http-headers>
      <add header="transferMode.dlna.org: Streaming"/>
      <add header="contentFeatures.dlna.org: DLNA.ORG_OP=01;DLNA.ORG_CI=0;DLNA.ORG_FLAGS=01500000000000000000000000000000"/>
 </custom-http-headers>


to allow the player to pause the stream (forward and rewind won't work): without these lines you can't pause the stream and the player would return an error : Operation not permitted.

Now we can turn on our Sony BDPS790 and select the DLNA Server icon from [Video] on the home menu. Select the file you want to play using the arrows  and press ENTER.

That's all.
Best regards