DLNA on Raspberry Pi

I always wanted to setup a media server at home for the following reasons:

  1. Reduce redundancy - having multiple copies of media for different devices like phone, tablet, smart TV etc
  2. Ease of use - no need to copy files to and from devices to play media (mostly Floyd and movies)
  3. One stop shop with transmission integration - download files on rpi and they appear on the media server

The easiest solution was to turn my RaspberryPi into a DLNA server. For this I required to a few basic packages and had to configure each.

It was a bit hard to find all of them in a single post and hence I’m writing this post.

Packages required #

samba #

Append /etc/samba/smb.conf

[public]
  path = /path/to/public/folder
  browseable = yes
  writeable = yes
  guest ok = no
  read only = no

minidlna #

Edit /etc/minidlna.conf

media_dir=/path/to/public/folder
media_dir=V,/path/to/public/videos/folder
media_dir=A,/path/to/public/music/folder    
media_dir=P,/path/to/public/pictures/folder

friendly_name=rpi

transmission-daemon #

mkdir -p /opt/torr
sudo chown -R debian-transmission /opt/torr

cp /etc/transmission-daemon/settings.json /etc/transmission-daemon/settings_template.json

Edit /etc/transmission-daemon/settings.json

Change the value of download-dir field to /opt/torr

{
    ..
    "download-dir": "/opt/torr",
    ..
}

Time to test! #

sudo service samba stop
sudo service samba start

sudo service minidlna stop
sudo service minidlna start

sudo service transmission-daemon stop
sudo service transmission-daemon start

To test if transmission daemon is running, open http://rpi_ip_addr:9091/transmission/web/

IP address of devices keep changing and hence it is difficult to access it with IP address.
We can solve this problem by using the .local domain. For this we need avahi-daemon and tweak the hosts file

avahi-daemon #

sudo apt-get install avahi-daemon

Edit /etc/init.d/hostname

Change

    127.0.1.1 raspberrypi

to

    127.0.1.1 [new name here]

Reboot rpi

Now you should be able to access your raspberrypi using the URL http://host_name.local

For example, http://raspberrypi.local


PS: Most of the times minidlna does not refresh the collection in the specified folders. We need to explicitly run the following command

sudo minidlna -R
sudo service minidlna restart 

This problem might be because of the inotify functionality of the linux kernel. It has to be enabled by the kernel. A solution is posted here

Courtesy #

 
6
Kudos
 
6
Kudos

Now read this

Markers with D3

Every time I look at the examples page of D3, I’m simply go… @mbostock has transformed how visualizations are created for web. Today I learnt how to use svg markers with D3. I was using force layout to analyze graphs, just like this... Continue →