Setup MiniDLNA on Ubuntu

DLNA allows you to play home network media on all compatible devices over the network. Last year I wrote a post on how to setup MiniDLNA, the free media server software in ubuntu 10.04. I also pointed out the limitations of MiniDLNA media server and why I moved away from it. Since then there has been several updates to MiniDLNA and it is being very actively developed. At the time of writing this the latest version was 1.0.24, which several good fixes and upgrades. I am particularly happy that it now supports subtitles. The full change log can be found here. This post explains how to setup MiniDLNA server for Ubuntu for streaming content to media players over the network.

UPDATE (July 6, 2013): Check this post for an updated guide on how to compile and install the latest version of MiniDLNA (now ReadyMedia) on Ubuntu.

Setup MinidlnaI was intrigued by the changes and decided to take one more dip and test the new version on my Ubuntu Server 12.04 LTS Precise Pangolin. That said, the description below should work most past releases too. My TV and Bluray player setup is still the same: LG 42" LED TV and LG Bluray Player. With that taken care of, below is how I installed and configured MiniDLNA.

Download and Setup MiniDLNA

To install MiniDLNA, download it from here: http://sourceforge.net/projects/minidlna/files/minidlna/. Go into the latest version folder and download the file named minidlna_X.X.XX_static.tar.gz. Alternatively, you could add the PPA repository to your /etc/apt/sources.list and install as described below:

sudo add-apt-repository ppa:stedy6/stedy-minidna
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install minidlna

Sourceforge normally has the most recent versions and is my preferred way of installing MiniDLNA. My MiniDLNA runs on a headless server with Webmin running. If yours is a similar setup then this webmin module offers a easy way to edit your configuration file, restart, and rescan MiniDLNA.

Best Android TV Boxes:
  1. NVIDIA SHIELD TV Pro Home Media Server - $199.99 Editors Pick
  2. Amazon Fire TV Streaming Media Player - $89.99
  3. WeTek Play 2 Hybrid Media Center - $134.00
  4. Kukele Octacore Android TV Box - $179.99
  5. U2C Android TV Box - $95.99

Configure MiniDLNA

The next step to setup MiniDLNA on Ubuntu is to configure MiniDLNA. Extract the downloaded tar file:

tar -zxvf filename.tar.gz

This results in files: /usr/sbin/minidlna, /etc/minidlna.conf, and a bunch of files within /usr/share folder. Normally you can ignore the /usr/share folder and everything within this. CD into the location of first 2 files (minidlna and minidlna.conf) and move them as follows:

sudo mv minidlna /usr/sbin/
sudo mv minidlna.conf /etc/minidlna.conf

Then configure minidlna.conf file. Below is my new minidlna.conf file:

# port for HTTP (descriptions, SOAP, media transfer) traffic
port=8200

# network interfaces to serve, comma delimited.
# network_interface=eth0

# set this to the directory you want scanned.
# * if have multiple directories, you can have multiple media_dir= lines
# * if you want to restrict a media_dir to a specific content type, you
# can prepend the type, followed by a comma, to the directory:
# + "A" for audio (eg. media_dir=A,/home/jmaggard/Music)
# + "V" for video (eg. media_dir=V,/home/jmaggard/Videos)
# + "P" for images (eg. media_dir=P,/home/jmaggard/Pictures)
media_dir=V,/home/user/media/Movies
media_dir=P,/home/user/media/Photos
media_dir=A,/home/user/media/Music

# set this if you want to customize the name that shows up on your clients
friendly_name=My-MiniDLNA

# set this if you would like to specify the directory where you want MiniDLNA to store its database and album art cache
db_dir=/home/user/.minidlna

# set this if you would like to specify the directory where you want MiniDLNA to store its log file
log_dir=/var/log

# set this to change the verbosity of the information that is logged
# each section can use a different level: off, fatal, error, warn, info, or debug
log_level=general,artwork,database,inotify,scanner,metadata,http,ssdp,tivo=fatal

# this should be a list of file names to check for when searching for album art
# note: names should be delimited with a forward slash ("/")
album_art_names=Cover.jpg/cover.jpg/AlbumArtSmall.jpg/albumartsmall.jpg/AlbumArt.jpg/albumart.jpg/Album.jpg/album.jpg/Folder.jpg/folder.jpg/Thumb.jpg/thumb.jpg

# set this to no to disable inotify monitoring to automatically discover new files
# note: the default is yes
inotify=yes

# set this to yes to enable support for streaming .jpg and .mp3 files to a TiVo supporting HMO
enable_tivo=no

# set this to strictly adhere to DLNA standards.
# * This will allow server-side downscaling of very large JPEG images,
# which may hurt JPEG serving performance on (at least) Sony DLNA products.
strict_dlna=no

# default presentation url is http address on port 80
#presentation_url=http://www.mylan/index.php

# notify interval in seconds. default is 895 seconds.
notify_interval=895

# serial and model number the daemon will report to clients
# in its XML description
serial=12345678
model_number=1

# specify the path to the MiniSSDPd socket
# minissdpdsocket=/var/run/minissdpd.sock

# use different container as root of the tree
# possible values:
# + "." - use standard container (this is the default)
# + "B" - "Browse Directory"
# + "M" - "Music"
# + "V" - "Video"
# + "P" - "Pictures"
# if you specify "B" and client device is audio-only then "Music/Folders" will be used as root
# root_container=.

Continue to next page to fully setup MiniDLNA.

Notes:

  • If you have firewall enabled then allow port 8200.
  • Uncomment "network_interface=eth0" if you want MiniDLNA to bind to your ethernet port.
  • Add your Video, Music, and Photos sources.
  • Add a directory to store the MiniDLNA database. I prefer storing it in my home directory: db_dir=/home/user/.minidlna.
  • Setting the logs folder. I set the log level to "fatal" as I do not like extensive logging.
  • Set inotify=yes (default) to automatically add new files (although I have found this to be not reliable. Below I have described how I automatically refresh my library).
  • Ignore "presentation_url=http://www.mylan/index.php". I my research shows that this does not work as there is not web interface for MiniDLNA.
  • I left this is a default "notify_interval=895". You can set it to lower value if you want MiniDLNA to check for new files more frequently (although I have found this to be not reliable. Below I have described how I automatically refresh my library).
  • You normally will not have to mess with the remaining settings.

Find some of the best rated dlna compatible Bluray players here.

Start MiniDLNA using the following command:

/usr/sbin/minidlna -f /etc/minidlna.conf

To rescan media files the following command works for me:

/usr/sbin/minidlna -R -f /etc/minidlna.conf

Upon starting MiniDLNA builds the index of all the files. I have noticed that this demands a lot of CPU for a few minutes. But it will calm down soon.

Now you should be able to browse and play media from your DLNA server on your client. Please note that not all clients support all features of MiniDLNA. In my case I had no troubles playing avi, mkv, mp4, mov, mp3, flac, and jpg files.

Best Android TV Boxes:
  1. NVIDIA SHIELD TV Pro Home Media Server - $199.99 Editors Pick
  2. Amazon Fire TV Streaming Media Player - $89.99
  3. WeTek Play 2 Hybrid Media Center - $134.00
  4. Kukele Octacore Android TV Box - $179.99
  5. U2C Android TV Box - $95.99

Auto Start MiniDLNA During Boot

If you would like to start the MiniDLNA server automatically when Ubuntu Server boots then create the following file in /etc/init.d:

sudo nano -w minidlna

and enter the following content.

#!/bin/sh
# Mini DLNA

case "$1" in
'start')
/usr/sbin/minidlna -f /etc/minidlna.conf
;;
'stop')
;;
*)
echo "Usage: $0 { start | stop }"
;;
esac
exit 0

Change the ownership and permissions as follows:

sudo chown user: minidlna

sudo chmod 755 minidlna

Save it and restart your server. Immediately after booting the MiniDLNA server starts indexing the files so expect your CPU run high. As soon as it is done you should see all your files on your DLNA client. Unlike previous versions, subtitles now work on several clients.

Starting and Stopping MiniDLNA

You can start and stop MiniDLNA using the following commends:

/etc/init.d/minidlna start
/etc/init.d/minidlna stop

Or, you could use the Webmin Module to do the same.

While I still may not use MiniDLNA (I love my XBMC, NFS, and SMB setup), I am glad to see the active development. I am sure it will be exactly what others may be looking for. So go ahead, setup MiniDLNA on Linux and enjoy streaming!!!

Be the 1 in 200,000. Help us sustain what we do.
106 / 150 by Dec 31, 2024
Join Us (starting from just $1.67/month)

Anand

Anand is a self-learned computer enthusiast, hopeless tinkerer (if it ain't broke, fix it), a part-time blogger, and a Scientist during the day. He has been blogging since 2010 on Linux, Ubuntu, Home/Media/File Servers, Smart Home Automation, and related HOW-TOs.