How to Set up a Free Media Server on Raspberry Pi Using MiniDLNA?
Raspberry Pi?is kept increasing its capabilities with its developing computing power with the passing of time. Its small size with less price makes it an awesome tool to use in many digital projects. We feel excited to share information about one such digital project. Yes, we are going to show you how you can set up a free media server on Raspberry Pi in this blog.
There are different ways to do this. And there are several third-party products available in the market to help you do this. Some of them are free, and some come for a price. But, our intentions are to show you how to set up a free media server on Raspberry Pi in a native way using DLNA protocol. Let’s get started right from the beginning.
Table of Contents
. What Is A Media Server? And, How It Is Different From A File Server?
. What is DLNA?
. What Is Required To Build A Media Server On A Raspberry Pi?
. How To Setup MiniDLNA On The Raspberry PI?
What Is a Media Server? And, How It Is Different From a File Server?
File servers are some centralized places to store data in the form of files. For a typical file server, everything it stores is a file, no matter it is a text, picture, video, pdf, or script file. It just provides you to store the data in an organized way. You should need to navigate the data on your own to access it.
On the other hand, a media server is a layer above the file server. It indexes and catalogs the media files like pictures, audio, and video for you to play. On top of that, it allows you to play them over the network. You don’t have to bother about where the movie files are stored. You can just send your queries and get the results on your screen. As an example, Search all the songs by a singer or an artist. All these additional capabilities make the media server more user-friendly, easier to manage, and more attractive to the user.
What is DLNA?
Let’s give you a short description of the DLNA. First of all, DLNA stands for?Digital Living Network Alliance. It is a media-sharing protocol standard developed by SONY and Intel with a joint association. It is mainly developed to create standards to share the media over the network. Most smart devices like smart TV, smartphones, smart set-top boxes, and any smart devices which have the capability to share media content supports DLNA. Moreover, computer media players, like?windows media player,?VLC, and Plex, will also support DLNA.
DLNA enabled computers to act as media servers. Two things are required to work DLNA,?DLNA server & client. Media share always happens from one server to multiple clients. You can’t share the content between servers or clients alone. Your next question might be, what are these clients & servers? How do they look? DLNA client could be any device that supports DLNA. For example, all the so-called smart devices which can play media over the network. Don’t be scared that you need a big size server to set up a DLNA server. It’s a small application; any buddy can download it on their computers and build their own server. Just to tell you, your windows media player can act as a DLNA server. And most of the NAS devices are shipped with DLNA server applications to stream media stored on them. Let’s see how to set up a free media server on?Raspberry Pi?using miniDLNA.
What Is Required to Build a Media Server on a Raspberry Pi?
Thanks to nutfunny4u for creating this video.
How to Setup MiniDLNA on the Raspberry Pi?
Its lightweight nature allows you to run it on any version of Raspberry Pi. In this section, we are going to show you how to set up a miniDLNA server on Raspberry Pi and stream media files to other smart devices over the network.
We have divided this section into four major subsections, which would give you a better understanding of the complete setup process.
The time needed: 10 minutes.
How to set up miniDLNA on the Raspberry PI?
It’s simple to install as other packages. Let’s install from apt repositories.
$ sudo apt-get install minidlna
2. Create a directory ‘minidlna’ to store its database and log files:
We are creating all the directories under /mnt/data-ext4/ for demonstration purposes.
$ cd /nmt/data-ext4
$ sudo mkdir minidlna
3. Changing the ownership of the ‘minidlna’ directory to the ‘minidlna’ user and ‘minidlna’ group:
If you see the permissions for the minidlna directory, one can write to a directory other than root. It’s never the best idea to grant full permission to all. Instead, we create a new user, ‘minidlna,’ and a group, ‘minidlna,’ and change the ownership to the minidlna user and group. This allows the database and logs to be written in the directory.
$ sudo chown minidlna:minidlna minidlna: chown is the command used to change the ownership of the file. The syntax looks like this, chown user: group directory
4. Ensure the correct permissions on miniDLNA directories:
Let’s take a look at the ownership of the minidlna directory after the chown command.
5. Create a directory to store the music files:
Navigate inside the ‘public’ directory and create a new directory called ‘Music’ inside of it. This time you need not use the sudo command as the ‘public’ directory has full permissions to all users. Upon creating the ‘Music’ directory, see the permissions. This directory is under the user ‘user,’ and the group ‘pi’ and others don’t have write permission on it.
$ cd public
$ mkdir Music
领英推荐
6. Fix the write permissions on the Music directory:
Use the same ‘chown’ command to change the ownership of the Music directory to everyone and give written permission. User ‘noboddy’ and Group ‘nogroup’ eventually makes everyone the owner of the file/directory.
7. Create a few more directories to organize the media content:
Similarly, create whatever directories you want to organize your media files. We have created a few more directories for demonstration.
Create a few more directories inside the public directory inside /mnt/ntfs. And copy some music and movie files into all these directories.
8. Configure miniDLNA config file:
Now, it’s time to direct miniDLNA to pick up the media files from the place it stored. Use your choice of a text editor and edit the config file.
$ sudo nano /etc/minidlna.conf
9. Configure the media directories:
Scroll down to the line where you see ‘media_dir’ and create a list of additional directories that you have created to store media. After = sign, there is a letter, ‘,’ and the path where the files are stored.
A:?Audio files
P:?Picture files
V:?Video files
PV:?Picture and Video files
10. Configure directories to store the database and log files:
Scroll down just below further and set the directories to store the database and log files. Save the changes and close the text editor.
11. Restart the minidlna service:
After making all the required changes restart the minidlna service to write all the changes and it to take effect. Check the status, the service should be up and running if everything is correct.
$ sudo service minidlna restart
12. Set max user watches limit temporarily:
Make sure everything is correct by looking into the log file.
$ cat /mnt/data-ext4/minidlna/log/minidlna.log
Just pay attention to a warning log. It says that it can monitor up to 8192 directories and subdirectories for changes.?If your collection is larger than this, then you can increase the value by editing /proc/sys/fs/inotify/max_user_watches. But this will not survive a reboot.
13. Set max user watches limit permanently:
To set the value forever. Edit the file /etc/sysctl.conf
$ sudo nano /etc/sysctl.conf
Scroll to the bottom and add this line:?fs.inotify.max_user_watches = 65536
14. Configure minidlna service to start on reboot:
There are many ways to do this. One such simple way is here:
$ sudo update.rc.d minidlna defaults
That’s all. But bear in mind large files would take a large time to index and catalog media files. Sometimes it may take a few hours to complete the catalog process.
Now, your Pi is ready to stream media files over the network. This is how you can set up a free media server on?Raspberry Pi?using miniDLNA.
Thank you for reading this article. Please visit the below links to read more such interesting articles. Please leave your comments here below and let us know your feedback. This helps us to bring more such articles.
This post is originally published at?thesecmaster.com.
We thank everybody who has been supporting our work and request you check out?thesecmaster.com?for more such articles.