How to setup Raspberry Pi–Media Server

In my last post, I had promised to come back with a guide on setting up your Pi as a media server. It has been some time now, but here it follows.

Before we begin, how about some insight to media servers and certain technology standard called DLNA?

We all have a lots of media lying around in various storage devices and we(some of us at least) still use the stone age methods of transferring media to our media players(USB stick to use on smart TV, phones, tablets etc.). How good it would be if we were able to access our media right from its source without getting up from the chair!!

Enter media servers. These are a bit of software running on a network connected computer, which organise, and share your media to anyone connected on to the network. To unify the way these network connected devices access media, a certification standard was formulated by various electronics giants like Sony. The basic idea behind formulating this standard was to ensure that media can be accessed across various platforms with ease. So the media content might be on a windows based server but it could be accessed by DLNA compliant devices which could range from a smart TV with proprietary operating system, or a android based mobile phone(android was just in making back then but the standard was platform independent so could be adopted at a later stage easily) or even a linux based computer. More information on DLNA of Digital Living Network Alliance can be found here.

Anyway, if you are following this guide, it means you are a potential candidate to setup media server on your home network. This guide is specific to Raspbian OS and the prerequisites are to have a Raspberry Pi which is connected to your network(via wired network preferably) and your HDDs with the media folders mounted to an accessible folder. You can follow the guides in my previous posts here and here for that.

Let’s begin!!

Login to you pi via SSH. Remember we are running the device headless since we want to conserve the processing power. In case you are still using desktop, you can launch terminal from the desktop.

First ensure that your Raspbian installation is up-to-date. Run the following commands for that.

sudo apt-get update

sudo apt-get upgrade

Next install minidlna using:

sudo apt-get install minidlna

Once installed, backup the minidlna configuration file using:

sudo cp /etc/minidlna.conf /etc/backup_minidlna.conf

Open the minidlna configuration file in nano for editing using:

sudo nano /etc/minidlna.conf

(you can use sudo leafpad /etc/minidlna.conf to open in leafpad in case you are working on desktop instead of terminal)

In the configuration file, find(using up/dn arrow keys) db_dir and set its value to :

db_dir=/home/pi/.minidlna

Remember, most of these settings are commented out using #. Remove the # to uncomment them and make them usable.

Set minidlna media directories to point at the directories which hold your media as follows:

media_dir=V, /media/WD/movies

Here “V” stands for Videos. For specifying aa audio directory, use “A” and “P” for photos . The above line in the configuration file will specify that one of the media directory to scan for video files only is located /media/WD/movies. I have used WD since I have mounted one of my HDD at /media/WD and the “movies” is a folder in that HDD which contains movies. You will certainly have a different configuration so check your setup and edit this line accordingly.

If you are specifying media_dir=V, /XXX/XXXX/XXX, the server will only serve video files to the network. If you do not specify “V”, it will search for all media contents in music, photos, videos. So the line can also be :

media_dir=/media/WD/movies

You can have multiple configuration lines here. But I suggest you organise the media properly before sharing else your media devices will show you a lot of directories and you will find it difficult to locate specific media in them.

In friendly_name suggest a recognisable name. Mine is :

friendly_name=Raspberry Pi MiniDLNA

You can have anything you like.

Uncomment out the inotify=yes so that the server keeps on searching for new media, whenever you add new files.

Now click ctrl+x.. It will as whether to save the file. Select yes. Then run the following commands.

sudo service minidlna restart

sudo service minidlna force-reload

To ensure minidlna service starts at reboot run the command:

sudo update-rc.d minidlna defaults

No go for a reboot once using:

sudo reboot

If you have done everything right, upon reboot you should be able to see your media server on you DLNA compliant devices, or DLNA media player softwares.

Do ping me in case you have trouble.

Leave a Reply

Your email address will not be published. Required fields are marked *