Social Icons

Showing posts with label minidlna inotify. Show all posts
Showing posts with label minidlna inotify. Show all posts

Install MiniDLNA on Raspberry Pi



*These steps works both on Raspbian Wheezy & Jessie*

Install MiniDLNA
sudo apt-get update
sudo apt-get install minidlna


Open and edit MiniDLNA's configuration file
sudo vi /etc/minidlna.conf

Configure your media directory
media_dir=V,/media/NASDRIVE/Movies

Note:
Adding "V," as prefix to the path will restrict the media dir to video content type.
Similarly, "A," for Audio and "P," for pictures respectively.

Set a name for your DLNA servers, this will show up on clients
friendly_name=RasPiDLNA

Set inotify to yes to let MiniDLNA automatically pick up file / media changes
inotify=yes
notify_interval=300 

Un-comment the line
log_dir=/var/log

Add minidlna user to pi group
sudo usermod -a -G pi minidlna

Force Restart MiniDLNA to let it build it's media database
sudo service minidlna force-reload

Check the logs at /var/logs (check if your media library is being indexed)
tail -f  minidlna.log



Viola... Your video collection should soon  show up on your DLNA devices :)

How to configure inotify to work with MiniDLNA and pickup changes in media_dir

With the advent smart computing devices like ARM processor based Raspberry Pi there has been a significant rise is people setting up their home DLNA Servers for streaming their multimedia collections like movies, videos, pictures directly to their internet enabled or DLNA enabled smart TVs. Even almost all modern Android devices are capable to receiving DLNA streams.

MiniDLNA is one of the very popular DLNA server being used by raspbian users and also by users of Arch Linux and even a large community of Ubuntu users, mainly due to to it's fairly small size and simple ease of use. However there is some issue with MiniDLNA in automatically picking up changes / additions to the media_dir (Media Directory) i.e. more often it doesn't picks up any new file if added to the folder and updates the database which appears on your DLNA renderer like TV.

It generally throws the following warning in the logs:
[2012/10/19 18:35:41] inotify.c:195: warn: WARNING: Inotify max_user_watches [8192] is low or close to the number of used watches [4] and I do not have permission to increase this limit.  Please do so manually by writing a higher value into /proc/sys/fs/inotify/max_user_watches.

While most of the solutions suggests setting up a cron job to rebuild the whole of the database at some specific time but hardly any of them address the fix to real issue or some says that the kernel or OS version doesn't supports the inotify feature. Also I don't like the idea of rebuilding the whole media library database every day or every time a new file is added, as ideally it should just add the new file in the media database  Some of you might have even tried to update /proc/sys/fs/inotify/max_user_watches but probably failed with a error "E667: Fsync failed" at the vi.

Solution:
Edit sysctl.conf (A file for defining kernel parameters)
sudo nano /etc/sysctl.conf

Find and change as below if the following line exists or add at the bottom:
fs.inotify.max_user_watches=65536

Save the file Ctrl + X and Y(es)

Now run the below command, you should be able to see the values you have set:
sudo /sbin/sysctl -p

Finally restart MiniDLNA service and things should be working:
sudo service minidlna restart

Note: Make sure you have inotify enabled and a notify interval is set as per your requirement in /etc/minidlna.conf per the following settings
inotify=yes
notify_interval=300