MiniDLNA on the Raspberry Pi

MiniDLNA

MiniDLNA will allow streaming of video, TV, and pictures from the external hard drive to other devices in your home. Perfect for NZBGet and SickBeard

MiniDLNA

Install and configure MiniDLNA

sudo apt-get install minidlna
sudo chown minidlna:minidlna /var/lib/minidlna

Create log and cache files for MiniDLNA, edit the conf file and restart.

sudo mkdir /var/{cache,log}/minidlna
sudo chown minidlna:minidlna /var/{cache,log}/minidlna

Edit the config file

sudo nano /etc/minidlna.conf

media_dir=V,/media/ExtHD/usenet/tv
db_dir=/var/cache/minidlna
log_dir=/var/log/minidlna
inotify=yes
notify_interval=300
listening_ip=[IP of rPi]

Add this to the end of the /etc/sysctl.conf file to fix some issues

sudo nano /etc/sysctl.conf
# minidlna server tweaks
fs.inotify.max_user_watches = 100000
# end of minidlna server tweaks

Give MiniDLNA permissions to view the media_dir. To do this I added the minidlna user to the sbeard group as my media_dir allows the sbeard group to make changes.

sudo usermod -a -G sbeard minidlna

Force-reload MiniDLNA

sudo services minidlna stop
sudo service minidlna force-reload
sudo service minidlna start

Your Raspberry Pi will now be able to stream media over your network.

MiniDLNA Problems

I, and others, have had many problems with MiniDLNA not working the way it should. The following are some problems and how I fixed them.

1. MiniDLNA disconnects from my client every 10-30 minutes.

There are 2 fixes I found for this problem. The first is to set your notify_interval level in the minidlna.conf file to a very high number, such as 90000. This solved the issue for me but since the notify interval was so high MiniDLNA wouldn’t search the media_dir for new files in a long time.

The other fix for me was to turn off UPnP on my router. When I turned it off the issue never came back and I set my notify_interval to 300 and there were no more problems.

2. MiniDLNA doesn’t update its files.db with new files that have beed added to the media_dir.

I fixed this one by changing the path of media_dir and creating a link to where my files are. I used the following steps

Stop the minidlna service and delete the art_cache and files.db file

sudo service minidlna stop
sudo rm -r /var/cache/minidlna/*

Edit minidlna.conf with the path to the new media_dir

sudo nano /etc/minidlna.conf
media_dir=V,/var/lib/minidlna/videos

create a link in /var/lib/minidlna to your ExtHD

sudo ln -s /media/ExtHD/usenet/tv /var/lib/minidlna/videos

Start MiniDLNA and give it time to recreate its Db

sudo service minidlna force-reload

3. MiniDLNA doesn’t have permissions to view newly created folders in the watched media_dir
I solved this by running MiniDLNA as the user root instead of minidlna. Edit init.d and add USER=root near the top.

sudo nano /etc/init.d/minidlna
USER=root

 

Advertisements
Tagged , ,

7 thoughts on “MiniDLNA on the Raspberry Pi

  1. Instead of doing a cron job to rebuild the whole of the database for your media library you can actually change the inotify value in sysctl.conf as explained here: http://www.techjawab.com/2013/05/how-to-configure-inotify-to-work-with.html

    • everbit says:

      Thanks, when I first wrote this section I read somewhere that wheezy on the pi doesn’t support inotify. I tested it by downloading files using SickBeard and NZBGet, I must have not waited long enough for SickBeards post processing to move the files into the media_dir directory. I’ll need to go back and look into it.

  2. Dan Cundy says:

    Do you know how to spin down your hhd when not used?

  3. Victoria says:

    Thank you

  4. Baptiste says:

    Works like a charm. Thx

  5. John Garner says:

    Dan – hd-idle, sdparm, or hdparm (look them up); try them in that order and any site that mentions all of them might well have scripts to help sdparm/hdparm work at startup every time or whatever is needed. hd-idle worked perfect for me on my other tiny Linux distro in a small box (Fonera2.0n)

  6. Tom Denny says:

    +1 for turning off upnp. That did the trick for me too.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Advertisements
%d bloggers like this: