bookmark_borderDLNA server with MiniDLNA under Linux / Raspberry Pi

DLNA is a great service. With a DLNA server you can distribute videos, music or pictures to almost every Smart TV and / or set top box like an Amazon Fire TV. With DLNA you don’t have to bother if you’re TV supports the given file format. DLNA does cover this for you. One of the DLNA services which is easy to install, configure and use is MiniDLNA. This article shows you how to setup a MiniDLNA server under Linux / Raspberry Pi with a few simple steps.

Which hardware to use?

The good thing is, that you don’t have to use an Intel / AMD based machine to stream Full HD over DLNA. Even a Raspberry Pi with an external USB hard drive attached is capable of streaming Full HD movies over a Gigabit Ethernet. If you want to build yourself a DLNA Raspberry Pi server, I would recommend the following hardware:

Whether you go with the Raspberry Pi setup or not, ensure that you have a hard drive which is big enough to store your media files. As the Linux distribution of choice I recommend you Ubuntu or Debian (this tutorial is also written for Debian and Ubuntu). If you’re going with a Raspberry Pi setup, check out Raspbian (which is a Debian made for the Raspberry Pi). To setup your Raspberry Pi with Raspbian, you can checkout the Raspberry Pi image creation tutorial from the Raspberry Pi Foundation.

Why MiniDLNA as the DLNA server software of choice?

Besides MiniDLNA there are plenty of other services available. One of the biggest solutions are MediaTomb and Twonky. Both are the opposite of MiniDLNA. They are coming with complex and more powerful configurations tools. At the same time they are way more resource hungry. MiniDLNA works with a „keep-it-simple“ method. You basically just have to install the service and tell MiniDLNA where the media files you want to stream are located at.
Besides the „keep-it-simple“ factor, MiniDLNA is also a very resource saving solution, as already mentioned. This comes hand in hand with the resources limits a Raspberry Pi is giving us. However, even if you’re going to install a MiniDLNA server on a Intel Core i7, a straight forward easy to install / use solution is always the one you should consider first in my humble opinion.

Install MiniDLNA

The Raspbian, Debian and Ubuntu package repositories are already providing a ready to go MiniDLNA package. With that being said, the following command installs the latest available MiniDLNA package onto your system:

user@raspberrypi:~$ sudo apt-get update && sudo apt-get install minidlna

Depending on your internet speed, the download and installation of the MiniDLNA package should be done within a minute or two.

Configure MiniDLNA

At this point of the tutorial I assume that your (external USB) hard drive is already formatted and filled with the media you want to share over DLNA. To give you a example which is as most as accurate as possible, I also assume that your hard drive is already mounted on your Linux machine under /mnt/usb. If your hard drive is mounted at a different location, simply replace /mnt/usb with the mount point you had chosen.
The configuration file for MiniDLNA is simple. While we could dive deeper into the configuration parameters, we want to keep it as simple as possible as well. The only two parameters which are interesting for our setup for now are media_dir and user. To set these two configuration parameters, open the configuration file with your editor of choice and go on reading this article. The configuration file is located at /etc/minidlna.conf.

Start MiniDLNA as a non-root user

By default MiniDLNA starts it process with the root user. While this makes things easier, it’s a security issue which should be fixed. To do so, scroll down in the MiniDLNA configurations file and search for the following lines:

# Specify the user name or uid to run as (root by default).
# On Debian system command line option (from /etc/default/minidlna) overrides this.
#user=minidlna

Remove the starting hash from the user line. This tells the MiniDLNA Daemon to start the process as the user minidlna. The user minidlna was already created by installing MiniDLNA two steps before.

Add media directories to MiniDLNA

MiniDLNA supports audio, picture and video files. You don’t have to store all files on one single hard disk to share them over MiniDLNA. However, you have to configure a media directory per storage. You can do this in the MiniDLNA configuration file, too:

# Path to the directory you want scanned for media files.
#
# This option can be specified more than once if you want multiple directories
# scanned.
#
# If you want to restrict a media_dir to a specific content type, you can
# prepend the directory name with a letter representing the type (A, P or V),
# followed by a comma, as so:
# * "A" for audio (eg. media_dir=A,/var/lib/minidlna/music)
# * "P" for pictures (eg. media_dir=P,/var/lib/minidlna/pictures)
# * "V" for video (eg. media_dir=V,/var/lib/minidlna/videos)
# * "PV" for pictures and video (eg. media_dir=PV,[...]
media_dir=/var/lib/minidlna

As you can see, in the standard configuration file there is already a media directory configured. However, that’s just an example and you have to change this to the actual directory where your media files are stored. As an example, a setup with three media directories could could look like this:

media_dir=/mnt/usb/audio
media_dir=/mnt/usb/video
media_dir=/mnt/usb/picture

After you’ve added all the desired media directories, save and close the configuration file. To finally apply the changes to the MiniDLNA server, you have to restart the service:

user@server:~$ sudo systemctl restart minidlna

The first scan process could take some minutes. When you’re copying / moving additional files over time into these directories, MiniDLNA will find them automatically. Look at the webinterface if you want to know if the scanning processes is finished (go to the next chapter to find out how to access the MiniDLNA webinterface).

Webinterface

The MiniDLNA service comes with a small webinterface. This webinterface is just for informational purposes. You will not be able to configure anything here. However, it gives you a nice and short information screen how many files have been found by MiniDLNA. MiniDLNA comes with it’s own webserver integrated. This means that no additional webserver is needed in order to use the webinterface.
To access the webinterface, open your browser of choice and either enter the IP address or the hostname of the server / Raspberry you’re want to connect to, followed by the port 8200. For e.g.: http://raspberrypi:8200:

DLNA server - MiniDLNA status page
MiniDLNA status page

As you can see, I’m only streaming video files over my MiniDLNA setup. In the upper table you can see that my MiniDLNA Raspberry setup is ready to stream 1108 video files on demand. The Connected clients table lists the actual connected clients. In this list I see devices like my Smart TV, my Playstation and many others. Even though a lot of these clients aren’t streaming right now, they keep an active connection to the MiniDLNA server. When they start to stream some files, you will see the actual connections in the last cell of the second table.

The actual streaming process

This paragraph is just a short overview how a connection from a client to the configured and running MiniDLNA server could work. In this scenario we simply use a computer which is in the same local area network than the server. As the client software we use the Video Lan Client. Simple, robust, cross-platform and open source. After starting VLC, go to the playlist mode by pressing CTRL+L. You will now see on the left side a category which is called Local Network. Click on Universal Plug’n’Play which is under the Local Network category. You will then see a list of available DLNA service within your local network. In this list you should see your DLNA server. Navigate through the different directories for music, videos and pictures and select a file to start the streaming process:

DLNA server VLC stream
The MiniDLNA server was recognized by VLC (click to enlarge)

This is just an example of how to connect to your MiniDLNA server with a desktop client. VLC is also available for Android devices. Using MiniDLNA with VLC on an Android device even allows you to use the Chromecast to cast a music file, series of pictures or videos to your TV. However, if you have a Smart TV, most of them can connect to DLNA services directly.

Start, Stop and restart MiniDLNA

Starting, stopping or restarting the MiniDLNA service is „business-as-usual“. But just for the records, here are the commands:

user@server:~$ sudo systemctl start minidlna
user@server:~$ sudo systemctl stop minidlna
user@server:~$ sudo systemctl restart minidlna

Conclusion

Setting up your own DLNA server is really easy. If you use a Raspberry Pi in combination with a USB hard disk, you have a cheap but solid and flexible open source based solution. You are not forced to use a prebuild NAS appliance which maybe limits you in the maximal size of the hard disk or the file formats you want to use. Also, installing and configuring your own DLNA solution is a good learning experience. So what you’re waiting for. Start streaming your own movies, pictures and music via DLNA. And if you have any questions or you just want to let me know how your own DLNA setup looks like: Leave a message in the comments below 🙂

Further links

bookmark_borderownCloud/nextCloud collaboration with EtherPad and EtherCalc

Besides Collabora Office there is an easy but reliable way to enable collaboration editing of text and spreadsheet files in ownCloud or nextCloud (just like in proprietary solutions like Microsoft OneDrive or Google Drive). This article describes how to install and enable EtherPad along with EtherCalc in your ownCloud or nextCloud instance.

Requirements and preparation

First you need a running ownCloud or nextCloud instance of course. (Note: If you’re using ownCloud, ensure that you don’t use versions higher than 9.1 right now. As of January 2018, the used plugin for the EtherPad / EtherCalc integration doesn’t work with ownCloud higher than version 9.1.) It doesn’t matter if this instance is running on your local home server, an Raspberry Pi or if you rented some space at a webhosting provider of your choice. If you haven’t already a working nextCloud / ownCloud instance and you’re okay with hosting your cloud files at a provider, I recommend you the German webhoster All-Inkl.com. They offer cheap webhosting packages with an integrated installer. The installer automatically installs an ownCloud or nextCloud instance for you. You can directly start working with it afterwards. Just for the records: I’m using All-Inkl.com as well.
Besides the running instance you also need the ownPad plugin. It extends your ownCloud / nextCloud instance in order to communicate with an etherPad / etherCalc instance. You can download the latest release of ownPad for nextCloud and ownCloud here.

Installation

After you’ve downloaded ownPad you have to extract the plugin. If you’re using Windows, you can use WinRAR or 7-Zip to do this. For Linux you can double click the archive in order to open it or you simply extract the archive with the following command:

user@machine:~$ tar xfvz ownpad.tar.gz

You now have to move the so extracted ownpad directory to your webspace / server and place it under the apps folder of your ownCloud or nextCloud installation. Check that the directory has the chmod rights of 755 after you’ve uploaded it, otherwise ownCloud / nextCloud may be unable to find the plugin later on.

Configuration

As next we have to tell ownCloud / nextCloud how to handle files that are using the filename ending .pad or .calc (the standard filename endings for EtherPad and EtherCalc files). To do so, you have to copy the file mimetypemapping.dist.json from the subdirectory resources/config/, which is located within the ownCloud / nextCloud root directory, to the subdirectory config and rename it afterwards to mimetypemapping.json.
Open the so copied file config/mimetypemapping.json with your favorite text editor and add the following two lines to the end of the file:

 "pad": ["application/x-ownpad"],
 "calc": ["application/x-ownpad"]

So for example the end of the final mimetypemapping.json file could look like this:

 ...
 "yaml": ["application/yaml", "text/plain"],
 "yml": ["application/yaml", "text/plain"],
 "zip": ["application/zip"],
 "pad": ["application/x-ownpad"],
 "calc": ["application/x-ownpad"]
}

Now that every requirement has been met, you can go on and activate ownPad within your ownCloud / nextCloud instance. For nextCloud, click on the upper right (gear symbol) and click on Apps. Search for ownPad and click on Enable:

Deactivated ownPad App in the nextCloud administration overview (click to enlarge)

For ownCloud however, you have to click the category selection on the upper left and select Apps (plus symbol). To your left, click on Disabled in order to get a list of all the apps and plugins that are disabled in your ownCloud instance. Search for ownPad in this list and click on Enable.
Now that you’ve enabled the ownPad plugin you should ensure that EtherPad and EtherCalc are also activated. For nextCloud: navigate to Settings (gear symbol upper right), click on Additional settings and search for the Collaborative documents section. Ensure that both check boxes are set. For ownCloud you find these settings under the upper right (click on your username), followed by a click on Administration. To your left you will see a bunch of options. One of them is Collaborative documents. Click on it in:
Enabled EtherPad / EtherCalc

By default, EtherPad and EtherCalc are using the instances which are provided by the developers. If you want to use another public instance you can always changes these Host lines to your needs. A full list of public instances can be found here.
It is also possible to setup and host your own EtherPad / EtherCalc instance. Take a look at the official setup guide provided by the developers if you want to: How to setup your own EhterPad / EtherCalc instance.

Testing

To test the functionality, create a new EtherPad or EtherCalc file by clicking on the plus icon in your ownCloud / nextCloud file browser:

New file

As you can see, you have two new options which are called Pad and Calc, while Pad is EtherPad (text documents) and Calc is EtherCalc (spreadsheet documents). To create a new spreadsheet document for e.g., click on Calc and give the file a name you desire. After you’ve done this, you will see a new file with a .calc ending in your file browser:
Newly created test EtherCalc file (click to enlarge)

In order to open this file and start editing, just click on it. The EtherCalc editor is going to be loaded and you’re ready to edit the file. If there is no editor popping up (for e.g. your browser wants to download the file instead), recheck that you’ve executed the installation and configuration steps correctly or try a different browser and delete your browser cache as well.
Test EtherCalc file in action. EtherCalc also supports some formulas. (click to enlarge)

About collaboration …

Now that you have a working ownCloud or nextCloud instance with ownPad running, you can start sharing an ownCloud / nextCloud link, which points to your EtherPad or EtherCalc file, with your co-workers. You and your co-workers are able to work simultaneously on that file that way. EtherPad as well as EtherCalc supports color highlighting while multiple people are working on one document. Besides this there is a chat functionality built-in for a better and easier communication. However, you can also use EtherPad and EtherCalc for non collaborative documents.

Final words

At the beginning of this article I mentioned that EtherPad / EtherCalc allows you to do collaboration text / spreadsheet editing like in Microsoft OneDrive or Google Drive. To be honest, to get the same functionality like in these two proprietary solutions you may should better go with Collabora Office which basically provides LibreOffice in your browser. However, for a simple but also effective solution you really should take a look at EtherPad / EtherCalc. It’s easy to setup and use. Besides this it comes with a nice chat functionality which may be helpful as well. And hey, it’s free right? I love open source 😉