Difference between revisions of "MediaTomb"

From ArchWiki
Jump to: navigation, search
m (Installation)
m (Usage: oops, fix template)
 
(40 intermediate revisions by 17 users not shown)
Line 1: Line 1:
[[Category:Daemons and system services]] <!-- MediaTomb provides a daemon mode -->
+
[[Category:Streaming]]
[[Category:Audio/Video]]                 <!-- stream your digital media; UPnP compatible devices -->
+
[[ja:MediaTomb]]
[[Category:Networking]]                  <!-- stream through your home network -->
+
{{Related articles start}}
{{Article summary start}}
+
{{Related|Streaming media}}
{{Article summary text|An introduction to [http://mediatomb.cc/ MediaTomb], covering installation and basic configuration of the open source UPnP MediaServer.}}
+
{{Related articles end}}
{{Article summary heading|Related}}
+
{{Article summary wiki|Streaming media}}
+
{{Article summary end}}
+
  
 
From [http://mediatomb.cc/ MediaTomb - Free UPnP MediaServer]:
 
From [http://mediatomb.cc/ MediaTomb - Free UPnP MediaServer]:
Line 12: Line 9:
 
:''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 (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.
+
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://sourceforge.net/projects/fuppes 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 ==
Line 18: Line 15:
 
MediaTomb is available in the [[AUR]] via {{AUR|mediatomb}}.
 
MediaTomb is available in the [[AUR]] via {{AUR|mediatomb}}.
  
The latest development version is also available in the [[AUR]] via {{AUR|mediatomb-svn}}.
+
The latest development version is also available in the [[AUR]] via {{AUR|mediatomb-git}}.
  
If you want to make use of your local [[MySQL]] server uncomment
+
Mediatomb can use its own database, or your local [[MariaDB]] server. For more information about the [[MariaDB]] integration visit the [http://mediatomb.cc/pages/documentation#id2855459 Documentation].
 
+
  --disable-mysql
+
 
+
in the corresponding [[Pkgbuild]] file before building the package.
+
 
+
For more information about the [[MySQL]] integration visit the [http://mediatomb.cc/pages/documentation#id2855459 Documentation].
+
  
 
== Configuration ==
 
== Configuration ==
 +
 +
{{Warning|1=The current version of MediaTomb has a serious bug: The {{ic|-i}} command-line option to bind to a specific IP address does not work. Bug reported in 2010 to [https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=693301 Debian] and [http://sourceforge.net/p/mediatomb/bugs/76 Upstream]. The webserver remains accessible on all interfaces, creating a security problem if running on a publically accessible host.}}
  
 
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
 
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
Line 34: Line 27:
 
  $ mediatomb
 
  $ mediatomb
  
to start MediaTomb as the current user and generate a default configuration in {{ic|~/.mediatomb/config.xml}}, or
+
to start MediaTomb as the current user and generate a default configuration in {{ic|~/.mediatomb/config.xml}}, or [[start/enable]] {{ic|mediatomb.service}} to start the MediaTomb daemon and generate a default configuration in {{ic|/var/lib/mediatomb/.mediatomb/config.xml}}.
 +
 
 +
If you want to use the [[MariaDB]] database backend, you can alternatively [[start/enable]] {{ic|mediatomb-mariadb.service}} which will ensure that [[MariaDB]] is up and running before MediaTomb is.
 +
 
 +
== Usage ==
 +
 
 +
The daemon listens on port {{ic|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 {{ic|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 {{ic|/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 {{ic|/}}.
 +
 
 +
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 {{ic|config.xml}} file.
 +
 
 +
<pc-directory upnp-hide="yes"/>
  
# rc.d start mediatomb
+
=== Playstation 3 Support ===
  
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.
+
The following notes assume MediaTomb is running as a system-wide daemon. For a per-user install, the locations of the configuration file will be different (see above).
  
 
For PlayStation 3 support, users must set {{Ic|<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.
Line 61: Line 99:
 
...
 
...
  
<virtual-layout type="disabled">
+
<virtual-layout type="disabled"/>
  
 
...
 
...
Line 96: Line 134:
 
... replacing eth0 with the interface you connect on.
 
... replacing eth0 with the interface you connect on.
  
== Usage ==
+
After configuring MediaTomb to your liking, [[restart]] {{ic|mediatomb.service}}.
  
After configuring MediaTomb to your liking, restart the server by running
+
=== Samsung TV Support ===
  
  # rc.d restart mediatomb
+
For Samsung TV support users should install {{AUR|mediatomb-samsung-tv}} from the [[AUR]], which it's the same as the {{AUR|mediatomb}} package with a few more patches. Note that the TV must have [[wikipedia:Digital_Living_Network_Alliance|DLNA]] support. Also the server and the TV should be connected to the same network.
  
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).
+
The following note assume MediaTomb is running as a system-wide daemon. For a per-user install, the locations of the configuration file will be different (see above).  
  
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:
+
Some models require changes in config.xml. Users should edit the {{Ic|<nowiki><custom-http-headers></nowiki>}} section and add two entries in the {{Ic|<nowiki><mappings></nowiki>}} section for better compatibility.
  
$ mediatomb -p 50500
+
{{hc|/var/lib/mediatomb/.mediatomb/config.xml
 +
|2=<nowiki>
 +
...
  
== Hiding full paths from media players ==
+
<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=017000 00000000000000000000000000"/>
 +
</custom-http-headers>
  
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.
+
<map from="avi" to="video/mpeg"/>
 +
<map from="mkv" to="video/mpeg"/>
  
To hide all of that and only show the directory added, you can change the import script.
+
...
 +
</nowiki>}}
  
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 /.
+
== Troubleshooting ==
  
function addVideo(obj)
+
=== Mediatomb doesn't provide content even though it is added in the webfrontend ===
{
+
    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.
+
Be aware of the fact that the user Mediatomb runs under, has to have read rights on the files that are added to be able to provide them.  
 
+
<pc-directory upnp-hide="yes"/>
+
  
== Systemd Integration ==
+
So if Mediatomb runs under the user 'mediatomb' the (video-)files either have to be owned by the user 'mediatomb' and need to be readable or the files and the user 'mediatomb' have to belong to the same group with the file being readable ('mediatomb' has to be in the group to which the file belongs (the file then needs the read rights for the group to be set)).
  
Using mediatomb with [[systemd]] can be done by using the following service file:
+
=== The Client loses connection after 30 Minutes ===
(Using [[MySQL]])
+
{{hc|/var/lib/systemd/system/mediatomb.service
+
|[Unit]
+
Description&#61;MediaTomb Daemon
+
After&#61;mysql.target network.target
+
  
[Service]
+
Apparently this is related to SSNP message only being sent once which results in the Client dropping its connection in 30 minutes since it thinks the server is gone.
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]
+
In the {{ic|config.xml}} add the alive tag:
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.
+
<alive>180</alive>
# NOTE: For security reasons do not run MediaTomb as root.
+
MEDIATOMB_USER&#61;"mediatomb"
+
  
# Run MediaTomb as this group.
+
Default is {{ic|180}}. See http://mediatomb.cc/pages/documentation#id2856362.
# NOTE: For security reasons do not run MediaTomb as root.
+
MEDIATOMB_GROUP&#61;"mediatomb"
+
  
# Path to MediaTomb config file.
+
=== Problems with discovery ===
MEDIATOMB_CONFIG&#61;"...path to config"
+
  
# Other options you want to pass to MediaTomb.
+
If you experience problem with discovery of MediaTomb service on your device, make sure that it binds to interfaces other than 'lo' - check in /etc/default/mediatomb
# Add "--interface ${MEDIATOMB_INTERFACE}" to bind to a named interface.
+
MEDIATOMB_OPTIONS&#61;""
+
}}
+

Latest revision as of 11:56, 20 October 2016

Related articles

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-gitAUR.

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

Configuration

Warning: The current version of MediaTomb has a serious bug: The -i command-line option to bind to a specific IP address does not work. Bug reported in 2010 to Debian and Upstream. The webserver remains accessible on all interfaces, creating a security problem if running on a publically accessible host.

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 start/enable mediatomb.service to start the MediaTomb daemon and generate a default configuration in /var/lib/mediatomb/.mediatomb/config.xml.

If you want to use the MariaDB database backend, you can alternatively start/enable mediatomb-mariadb.service which will ensure that MariaDB is up and running before MediaTomb is.

Usage

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"/>

Playstation 3 Support

The following notes assume MediaTomb is running as a system-wide daemon. For a per-user install, the locations of the configuration file will be different (see above).

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.

After configuring MediaTomb to your liking, restart mediatomb.service.

Samsung TV Support

For Samsung TV support users should install mediatomb-samsung-tvAUR from the AUR, which it's the same as the mediatombAUR package with a few more patches. Note that the TV must have DLNA support. Also the server and the TV should be connected to the same network.

The following note assume MediaTomb is running as a system-wide daemon. For a per-user install, the locations of the configuration file will be different (see above).

Some models require changes in config.xml. Users should edit the <custom-http-headers> section and add two entries in the <mappings> section for better compatibility.

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

<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=017000 00000000000000000000000000"/>
</custom-http-headers>

...

<map from="avi" to="video/mpeg"/>
<map from="mkv" to="video/mpeg"/>

...

Troubleshooting

Mediatomb doesn't provide content even though it is added in the webfrontend

Be aware of the fact that the user Mediatomb runs under, has to have read rights on the files that are added to be able to provide them.

So if Mediatomb runs under the user 'mediatomb' the (video-)files either have to be owned by the user 'mediatomb' and need to be readable or the files and the user 'mediatomb' have to belong to the same group with the file being readable ('mediatomb' has to be in the group to which the file belongs (the file then needs the read rights for the group to be set)).

The Client loses connection after 30 Minutes

Apparently this is related to SSNP message only being sent once which results in the Client dropping its connection in 30 minutes since it thinks the server is gone.

In the config.xml add the alive tag:

<alive>180</alive>

Default is 180. See http://mediatomb.cc/pages/documentation#id2856362.

Problems with discovery

If you experience problem with discovery of MediaTomb service on your device, make sure that it binds to interfaces other than 'lo' - check in /etc/default/mediatomb