Raspberrypi : Step-by-Step Configuration as a Media Server (DLNA/UnPn)

Raspberry Pi has become very popular since it is released to market since 2011. I got a Raspberry Pi as a gift from my boss. I spent quite some time to get DLNA (minidlna) work, so that I thought to list down steps here. I hope this will helpful to save hours of your time rather than trial and error approach.

Requirement:

Raspberry Pi (I have model B)
Monitor and Keyboard connected to RPI or SSH using Ethernet
Raspberry Pi is setup with Raspbian with initial setup (Ex: wifi/network setup )
[Optional] USB Wifi dongle (I use Comfast WU715N [Ralink Chipset 5370])

Configuration Steps :

Install minidlna using following command
sudo apt-get install minidlna

Configure the minidlna by editing configuration file located in "/etc/minidlna.conf". Also make sure media directories should have access to pi account, since we are going to use pi account to run minidlna service. If you are using a Wifi adapter in RPI, make sure you add network interfaces as shown below. Otherwise your dlna service is not going to be accessible by other users in the LAN.
sudo nano /etc/minidlna.conf

Add/Update following configuration values accordingly

media_dir=A,/media/usb0/songs
media_dir=V,/media/usb0/videos 
media_dir=P,/media/usb0/photos

db_dir=/media/usb0/minidlna

log_dir=/var/log


network_interface=eth0,wlan0
inotify=yes
notify_interval=300

Then save the file using "CTRL+O" and exit using "CTRL+X"

Then open and add/edit "max_user_watches" setting in the file /etc/sysctl.conf 
sudo nano /etc/sysctl.conf
fs.inotify.max_user_watches=65536

Then save the file using "CTRL+O" and exit using "CTRL+X"

Then open and add/edit "USER" setting (in the first half) of the file /etc/init.d/minidlna
sudo nano /etc/init.d/minidlna
USER=pi

Then save the file using "CTRL+O" and exit using "CTRL+X"

Give permission to user "pi" for the media folders using following command.
sudo chmod 774 /media/usb0/videos
sudo chmod 774 /media/usb0/audios
sudo chmod 774 /media/usb0/photos
sudo chown pi:pi /media/usb0/videos
sudo chown pi:pi /media/usb0/audios
sudo chown pi:pi /media/usb0/photos

Now we have configured all the required settings and ready to start the minidlna server with following commands. Make note that, if you change any configuration file, you have to use "force-reload" command to reflect those changes.

sudo service minidlna force-reload
sudo service minidlna start

Your media server is ready in the Raspberry Pi and accessible from other devices in your local network.
[You may use VLC player to test videos to play from your PC]



Comments

Popular posts from this blog

Embedding PowerBI with ASP.NET Core 2 and Angular(2,4,5)

Handling Exit Event of Console Application in C#

CSS text-overflow ellipsis in the beginning of the the text - Left Ellipsis using CSS in a Flex box