Difference between revisions of "MediaTomb"

From ArchWiki
Jump to: navigation, search
m (Usage)
m (Just changing some things which I think will make it clearer for beginners. These are problems/fixes I encountered/implemented.)
(39 intermediate revisions by 14 users not shown)
Line 1: Line 1:
[[Category:Daemons and system services (English)]] <!-- MediaTomb provides a daemon mode -->
+
[[Category:Audio/Video]]                <!-- stream your digital media; UPnP compatible devices -->
[[Category:Audio/Video (English)]]                <!-- stream your digital media; UPnP compatible devices -->
+
[[Category:Networking]]                  <!-- stream through your home network -->
[[Category:Networking (English)]]                  <!-- stream through your home network -->
+
<!-- {{i18n|MediaTomb}} -->
+
 
{{Article summary start}}
 
{{Article summary start}}
 
{{Article summary text|An introduction to [http://mediatomb.cc/ MediaTomb], covering installation and basic configuration of the open source UPnP MediaServer.}}
 
{{Article summary text|An introduction to [http://mediatomb.cc/ MediaTomb], covering installation and basic configuration of the open source UPnP MediaServer.}}
 
{{Article summary heading|Related}}
 
{{Article summary heading|Related}}
{{Article summary wiki|Streaming Media via uShare}}
+
{{Article summary wiki|Streaming media}}
 
{{Article summary end}}
 
{{Article summary end}}
  
Line 13: Line 11:
 
:''MediaTomb is an open source (GPL) UPnP MediaServer with a nice web user interface, it allows you to stream your digital media through your home network and listen to/watch it on a variety of UPnP compatible devices.''
 
:''MediaTomb is an open source (GPL) UPnP MediaServer with a nice web user interface, it allows you to stream your digital media through your home network and listen to/watch it on a variety of UPnP compatible devices.''
  
MediaTomb enables users to stream digital media to UPnP compatible devices like the PlayStation 3 and Xbox 360. Several alternatives exist, such as [http://fuppes.ulrich-voelkel.de/ FUPPES], [http://code.google.com/p/ps3mediaserver/ ps3mediaserver], and [[Streaming Media via uShare|uShare]]. One of MediaTomb's distinguishing features is the ability to customize the server layout based on extracted metadata (scriptable virtual containers); MediaTomb is highly flexible.
+
MediaTomb enables users to stream digital media to UPnP compatible devices like the PlayStation 3 (the Xbox 360 is not yet supported). Several alternatives exist, such as [http://fuppes.ulrich-voelkel.de/ FUPPES], [http://code.google.com/p/ps3mediaserver/ ps3mediaserver], and [[uShare]]. One of MediaTomb's distinguishing features is the ability to customize the server layout based on extracted metadata (scriptable virtual containers); MediaTomb is highly flexible.
  
 
== Installation ==
 
== Installation ==
  
MediaTomb is available in the [[Arch User Repository]]: {{Package AUR|mediatomb}}. The latest development version is also available via {{Package AUR|mediatomb-svn}}.
+
MediaTomb is available in the [[AUR]] via {{AUR|mediatomb}}.
 +
 
 +
The latest development version is also available in the [[AUR]] via {{AUR|mediatomb-svn}}.
 +
 
 +
Mediatomb can use its own database, or your local mysql server. For more information about the [[MySQL]] integration visit the [http://mediatomb.cc/pages/documentation#id2855459 Documentation].
  
 
== Configuration ==
 
== Configuration ==
  
Following installation, users should run {{Codeline|mediatomb}} in a terminal to generate a default server configuration file ({{Filename|~/.mediatomb/config.xml}}). The default settings may be sufficient for many users, though changes are required for PlayStation 3 support. Press Ctrl+C to terminate the server after the initial run.
+
The default settings may be sufficient for many users, though changes are required for PlayStation 3 support. MediaTomb may be configured and run per-user or as a system-wide daemon. Following installation, either run
 +
 
 +
$ mediatomb
 +
 
 +
to start MediaTomb as the current user and generate a default configuration in {{ic|~/.mediatomb/config.xml}}, or
 +
 
 +
# /etc/rc.d/mediatomb start
 +
 
 +
to start the MediaTomb daemon and generate a default configuration in {{ic|/var/lib/mediatomb/.mediatomb/config.xml}}. The following notes assume MediaTomb is running as a system-wide daemon.
  
For PlayStation 3 support, users must set {{Codeline|<nowiki><protocolInfo extend="yes"/></nowiki>}}. An "avi" mimetype mapping should also be uncommented for DivX support.
+
For PlayStation 3 support, users must set {{Ic|<nowiki><protocolInfo extend="yes"/></nowiki>}}. An "avi" mimetype mapping should also be uncommented for DivX support.
  
{{File
+
{{hc|/var/lib/mediatomb/.mediatomb/config.xml
|name=~/.mediatomb/config.xml
+
|2=<nowiki>
|content=<nowiki>
+
 
...
 
...
  
Line 39: Line 48:
 
</nowiki>}}
 
</nowiki>}}
  
When importing media to the database, MediaTomb will create a virtual container layout as defined by the {{Codeline|<nowiki><virtual-layout type="..."></nowiki>}} option. That is, media will be organized according to metadata (album, artist, etc.) through creation of virtual database objects. If your media is already organized on the file system, you may disable this feature to significantly improve import performance:
+
When importing media to the database, MediaTomb will create a virtual container layout as defined by the {{Ic|<nowiki><virtual-layout type="..."></nowiki>}} option. That is, media will be organized according to metadata (album, artist, etc.) through creation of virtual database objects. If your media is already organized on the file system, you may disable this feature to significantly improve import performance:
  
{{File
+
{{hc|/var/lib/mediatomb/.mediatomb/config.xml
|name=~/.mediatomb/config.xml
+
|2=<nowiki>
|content=<nowiki>
+
 
...
 
...
  
Line 51: Line 59:
 
</nowiki>}}
 
</nowiki>}}
  
Users may customize the import script to fine-tune the virtual layout. The [http://mediatomb.cc/dokuwiki/scripting:scripting Scripting] section of the MediaTomb wiki provides several examples. Starting with the built-in script available at {{Filename|/usr/share/mediatomb/js/import.js}}:
+
Users may customize the import script to fine-tune the virtual layout. The [http://mediatomb.cc/dokuwiki/scripting:scripting Scripting] section of the MediaTomb wiki provides several examples. Starting with the built-in script available at {{ic|/usr/share/mediatomb/js/import.js}}:
  
  $ cp /usr/share/mediatomb/js/import.js ~/.mediatomb/
+
  $ cp /usr/share/mediatomb/js/import.js /var/lib/mediatomb/.mediatomb/
  
... and edit {{Filename|~/.mediatomb/import.js}} as desired. To utilize the customized script, users must set {{Codeline|<nowiki><virtual-layout type="js"></nowiki>}} and specify the script's location.
+
... and edit {{ic|/var/lib/mediatomb/.mediatomb/import.js}} as desired. To utilize the customized script, users must set {{Ic|<nowiki><virtual-layout type="js"></nowiki>}} and specify the script's location.
  
{{File
+
{{hc|/var/lib/mediatomb/.mediatomb/config.xml
|name=~/.mediatomb/config.xml
+
|2=<nowiki>
|content=<nowiki>
+
 
...
 
...
  
 
<virtual-layout type="js">
 
<virtual-layout type="js">
   <import-script>/home/username/.mediatomb/import.js</import-script>
+
   <import-script>/var/lib/mediatomb/.mediatomb/import.js</import-script>
 
</virtual-layout>
 
</virtual-layout>
  
 
...
 
...
 
</nowiki>}}
 
</nowiki>}}
 +
 +
You may have to specify an interface before MediaTomb will be recognized:
 +
 +
{{hc|/var/lib/mediatomb/.mediatomb/config.xml
 +
|<nowiki>
 +
<server>
 +
...
 +
  <interface>eth0</interface>
 +
...
 +
</server>
 +
</nowiki>}}
 +
 +
... replacing eth0 with the interface you connect on.
  
 
== Usage ==
 
== Usage ==
  
After configuring MediaTomb to your liking, restart the server by running the {{Codeline|mediatomb}} command in a terminal:
+
After configuring MediaTomb to your liking, restart the server by running
  
{{Command
+
# /etc/rc.d/mediatomb restart
|name=mediatomb
+
|content=<nowiki>
+
MediaTomb UPnP Server version 0.11.0 - http://mediatomb.cc/
+
  
===============================================================================
+
The daemon listens on port 50500 by default. To access the web interface and begin importing media, navigate to http://127.0.0.1:50500/ in your favorite browser (JavaScript required).
Copyright 2005-2008 Gena Batsyan, Sergey Bostandzhyan, Leonhard Wimmer.
+
MediaTomb is free software, covered by the GNU General Public License version 2
+
  
2010-03-02 12:13:54    INFO: Loading configuration from: /home/user/.mediatomb/config.xml
+
If running per-user instances of MediaTomb, the default port is 49152. However, it is possible that the port will change upon server restart. The URL for the web interface is output during startup. Users may also specify the port manually:
2010-03-02 12:13:54    INFO: Checking configuration...
+
 
2010-03-02 12:13:54   INFO: Setting filesystem import charset to UTF-8
+
$ mediatomb -p 50500
2010-03-02 12:13:54   INFO: Setting metadata import charset to UTF-8
+
 
2010-03-02 12:13:54   INFO: Setting playlist charset to UTF-8
+
== Hiding full paths from media players ==
2010-03-02 12:13:54    INFO: Configuration check succeeded.
+
 
2010-03-02 12:13:54    INFO: Initialized port: 49152
+
By default, full directory paths will be shown on devices when they are browsing through folders.
2010-03-02 12:13:54   INFO: Server bound to: 192.168.1.50
+
 
2010-03-02 12:13:55    INFO: MediaTomb Web UI can be reached by following this link:
+
For example, if you add the directory /media/my_media/video_data/videos/movies, anyone connecting will have to navigate to the 'movies' directory from the root.
2010-03-02 12:13:55    INFO: http://192.168.1.50:49152/
+
 
</nowiki>}}
+
To hide all of that and only show the directory added, you can change the import script.
 +
 
 +
For example, this script will automatically truncate the whole directory structure specified in the variable video_root. Any directories added directly under the video root path will show up on UPnP devices starting from the that folder rather than /.
 +
 
 +
function addVideo(obj)
 +
{
 +
    var video_root = "/media/main_core/Server_Core_Folder/FTP_Services/Media/";
 +
 +
    var absolute_path = obj.location;
 +
 +
    var relative_path = absolute_path;
 +
 +
    if(absolute_path.indexOf(video_root) == 0)
 +
      relative_path = absolute_path.replace(video_root, "")
 +
 +
   var chain = new Array();
 +
 +
   var pathSplit = relative_path.split("/");
 +
 +
   for(var i = 0; i < pathSplit.length - 1; i++)
 +
      chain.push(pathSplit[i]);
 +
 +
   addCdsObject(obj, createContainerChain(chain));
 +
}
 +
 
 +
To also hide the default PC Directory folder from UPnP device directory listings, add the following directly under the server node of your config.xml file.
 +
 
 +
<pc-directory upnp-hide="yes"/>
 +
 
 +
== Systemd Integration ==
 +
 
 +
Using mediatomb with [[systemd]] can be done by using the following service file:
 +
(Using [[MySQL]])
 +
{{hc|/usr/lib/systemd/system/mediatomb.service
 +
|[Unit]
 +
Description&#61;MediaTomb Daemon
 +
After&#61;mysql.target network.target
 +
 
 +
[Service]
 +
EnvironmentFile&#61;/etc/conf.d/mediatomb
 +
ExecStart&#61;/usr/bin/mediatomb --config $MEDIATOMB_CONFIG  --user $MEDIATOMB_USER --group $MEDIATOMB_GROUP $MEDIATOMB_OPTIONS
 +
Restart&#61;on-failure
 +
RestartSec&#61;5
 +
 
 +
[Install]
 +
WantedBy&#61;multi-user.target
 +
}}
 +
and the corresponding config file
 +
{{hc|/etc/conf.d/mediatomb
 +
|# See the mediatomb(1) manpage for more info.
 +
 
 +
# Run MediaTomb as this user.
 +
# NOTE: For security reasons do not run MediaTomb as root.
 +
MEDIATOMB_USER&#61;"mediatomb"
 +
 
 +
# Run MediaTomb as this group.
 +
# NOTE: For security reasons do not run MediaTomb as root.
 +
MEDIATOMB_GROUP&#61;"mediatomb"
 +
 
 +
# Path to MediaTomb config file.
 +
MEDIATOMB_CONFIG&#61;"...path to config"
  
As shown, MediaTomb will output a link to its web interface. Enter this link in your favorite browser (JavaScript required) to access the web interface and begin importing media.
+
# Other options you want to pass to MediaTomb.
 +
# Add "--interface ${MEDIATOMB_INTERFACE}" to bind to a named interface.
 +
MEDIATOMB_OPTIONS&#61;""
 +
}}
  
MediaTomb can be run as a daemon, if desired. An appropriate script is included with the package at {{Filename|/etc/rc.d/mediatomb}}. Prior to starting the daemon, users should specify their username in {{File|/etc/conf.d/mediatomb}} so the daemon uses the appropriate configuration and database files.
+
Ensure that the specified user and group exists and has access to the config file and database.

Revision as of 11:57, 12 February 2013

Template:Article summary start Template:Article summary text Template:Article summary heading Template:Article summary wiki Template:Article summary end

From MediaTomb - Free UPnP MediaServer:

MediaTomb is an open source (GPL) UPnP MediaServer with a nice web user interface, it allows you to stream your digital media through your home network and listen to/watch it on a variety of UPnP compatible devices.

MediaTomb enables users to stream digital media to UPnP compatible devices like the PlayStation 3 (the Xbox 360 is not yet supported). Several alternatives exist, such as FUPPES, ps3mediaserver, and uShare. One of MediaTomb's distinguishing features is the ability to customize the server layout based on extracted metadata (scriptable virtual containers); MediaTomb is highly flexible.

Installation

MediaTomb is available in the AUR via mediatombAUR.

The latest development version is also available in the AUR via mediatomb-svnAUR.

Mediatomb can use its own database, or your local mysql server. For more information about the MySQL integration visit the Documentation.

Configuration

The default settings may be sufficient for many users, though changes are required for PlayStation 3 support. MediaTomb may be configured and run per-user or as a system-wide daemon. Following installation, either run

$ mediatomb

to start MediaTomb as the current user and generate a default configuration in ~/.mediatomb/config.xml, or

# /etc/rc.d/mediatomb start

to start the MediaTomb daemon and generate a default configuration in /var/lib/mediatomb/.mediatomb/config.xml. The following notes assume MediaTomb is running as a system-wide daemon.

For PlayStation 3 support, users must set <protocolInfo extend="yes"/>. An "avi" mimetype mapping should also be uncommented for DivX support.

/var/lib/mediatomb/.mediatomb/config.xml
...

<protocolInfo extend="yes"/>

...

<map from="avi" to="video/divx"/>

...

When importing media to the database, MediaTomb will create a virtual container layout as defined by the <virtual-layout type="..."> option. That is, media will be organized according to metadata (album, artist, etc.) through creation of virtual database objects. If your media is already organized on the file system, you may disable this feature to significantly improve import performance:

/var/lib/mediatomb/.mediatomb/config.xml
...

<virtual-layout type="disabled">

...

Users may customize the import script to fine-tune the virtual layout. The Scripting section of the MediaTomb wiki provides several examples. Starting with the built-in script available at /usr/share/mediatomb/js/import.js:

$ cp /usr/share/mediatomb/js/import.js /var/lib/mediatomb/.mediatomb/

... and edit /var/lib/mediatomb/.mediatomb/import.js as desired. To utilize the customized script, users must set <virtual-layout type="js"> and specify the script's location.

/var/lib/mediatomb/.mediatomb/config.xml
...

<virtual-layout type="js">
  <import-script>/var/lib/mediatomb/.mediatomb/import.js</import-script>
</virtual-layout>

...

You may have to specify an interface before MediaTomb will be recognized:

/var/lib/mediatomb/.mediatomb/config.xml
<server>
...
  <interface>eth0</interface>
...
</server>

... replacing eth0 with the interface you connect on.

Usage

After configuring MediaTomb to your liking, restart the server by running

# /etc/rc.d/mediatomb restart

The daemon listens on port 50500 by default. To access the web interface and begin importing media, navigate to http://127.0.0.1:50500/ in your favorite browser (JavaScript required).

If running per-user instances of MediaTomb, the default port is 49152. However, it is possible that the port will change upon server restart. The URL for the web interface is output during startup. Users may also specify the port manually:

$ mediatomb -p 50500

Hiding full paths from media players

By default, full directory paths will be shown on devices when they are browsing through folders.

For example, if you add the directory /media/my_media/video_data/videos/movies, anyone connecting will have to navigate to the 'movies' directory from the root.

To hide all of that and only show the directory added, you can change the import script.

For example, this script will automatically truncate the whole directory structure specified in the variable video_root. Any directories added directly under the video root path will show up on UPnP devices starting from the that folder rather than /.

function addVideo(obj)
{
   var video_root = "/media/main_core/Server_Core_Folder/FTP_Services/Media/";

   var absolute_path = obj.location;

   var relative_path = absolute_path;

   if(absolute_path.indexOf(video_root) == 0)
      relative_path = absolute_path.replace(video_root, "")

  var chain = new Array();

  var pathSplit = relative_path.split("/");

  for(var i = 0; i < pathSplit.length - 1; i++) 
      chain.push(pathSplit[i]);

  addCdsObject(obj, createContainerChain(chain));
}

To also hide the default PC Directory folder from UPnP device directory listings, add the following directly under the server node of your config.xml file.

<pc-directory upnp-hide="yes"/>

Systemd Integration

Using mediatomb with systemd can be done by using the following service file: (Using MySQL)

/usr/lib/systemd/system/mediatomb.service 
[Unit]
Description=MediaTomb Daemon
After=mysql.target network.target

[Service]
EnvironmentFile=/etc/conf.d/mediatomb
ExecStart=/usr/bin/mediatomb --config $MEDIATOMB_CONFIG  --user $MEDIATOMB_USER --group $MEDIATOMB_GROUP $MEDIATOMB_OPTIONS
Restart=on-failure
RestartSec=5

[Install]
WantedBy=multi-user.target

and the corresponding config file

/etc/conf.d/mediatomb
# See the mediatomb(1) manpage for more info.

# Run MediaTomb as this user.
# NOTE: For security reasons do not run MediaTomb as root.
MEDIATOMB_USER="mediatomb"

# Run MediaTomb as this group.
# NOTE: For security reasons do not run MediaTomb as root.
MEDIATOMB_GROUP="mediatomb"

# Path to MediaTomb config file.
MEDIATOMB_CONFIG="...path to config"

# Other options you want to pass to MediaTomb.
# Add "--interface ${MEDIATOMB_INTERFACE}" to bind to a named interface.
MEDIATOMB_OPTIONS=""

Ensure that the specified user and group exists and has access to the config file and database.