Giuseppe Parrello

 

How to install a DLNA server on a router


In this page I describe how to install a DLNA server on a router (Asus RT-AC56U) - we use an Entware package, so please refer to this page on how to install Entware on a router.
We will use the "minidlna" server, one of the most used DLNA server in Linux environments. To install this package, we will use the command line "opkg install minidlna". This will install minidlna server and all dependent packages. Once installed, we can use this command line to know how many files are included in this package:

opkg files minidlna

Package minidlna (1.2.1-2) is installed on root and has the following files:
/opt/bin/minidlna
/opt/etc/minidlna.conf
/opt/etc/init.d/S90minidlna

So we have the binary file called "minidlna", the config file "minidlna.conf" and the script file (S90minidlna) to start/stop the minidlna server.
So if we want to start the minidlna server, we can use the command line "/opt/etc/init.d/S90minidlna start", while to stop it we will use the command line "/opt/etc/init.d/S90minidlna stop". This script can be executed whenever we mount the external USB drive as described on the page "How to install Entware on a router".
We just give a look to the binary file using the command line "minidlna --help":

minidlna --help

Usage:
minidlna [-d] [-v] [-f config_file] [-p port]
[-i network_interface] [-u uid_to_run_as]
[-t notify_interval] [-P pid_filename]
[-s serial] [-m model_number]
[-w url] [-r] [-R] [-L] [-S] [-V] [-h]

Notes:
Notify interval is in seconds. Default is 895 seconds.
Default pid file is /var/run/minidlna/minidlna.pid.
With -d minidlna will run in debug mode (not daemonize).
-w sets the presentation url. Default is http address on port 80
-v enables verbose output
-h displays this text
-r forces a rescan
-R forces a rebuild
-L do not create playlists
-S changes behaviour for systemd
-V print the version number

We don't need the parameter "-f" (the config file) as this parameter is automatically used by the script in "/opt/etc/init.d" subfolder (the default config file is "/opt/etc/minidlna.conf").
Instead we need the "-r" (forces a rescan) whenever we need to rescan all the multimedia files and to recreate the database file.
The most important file of the "minidlna" package is the config file, placed in "/opt/etc" subfolder.
This is a sample config file:

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

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

# specify the user account name or uid to run as
#user=jmaggard

# set this to the directory you want scanned.
# * if you want multiple directories, you can have multiple media_dir= lines
# * if you want to restrict a media_dir to specific content types, you
# can prepend the types, 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)
# + "PV" for pictures and video (eg. media_dir=PV,/home/jmaggard/digital_camera)
media_dir=/opt/media

# set this to merge all media_dir base contents into the root container
# note: the default is no
#merge_media_dirs=no

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

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

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

# 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=warn

# 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=900

# 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=/opt/var/minidlna/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"
# + Or, you can specify the ObjectID of your desired root container (eg. 1$F for Music/Playlists)
# if you specify "B" and client device is audio-only then "Music/Folders" will be used as root
#root_container=.

# always force SortCriteria to this value, regardless of the SortCriteria passed by the client
#force_sort_criteria=+upnp:class,+upnp:originalTrackNumber,+dc:title

# maximum number of simultaneous connections
# note: many clients open several simultaneous connections while streaming
#max_connections=50

# PNG image to use for an icon, optionally followed by a hex background
# color
#icon=myicon.png,7f7f7f

# Background color (hex rgb triplet) for PNG images converted to jpeg. Two
# colors indicate that a checkerboard background, in those colors, should
# be used.
#bgcolor=666666,999999

# Suport to Movie Thumbnail generation. To use this option, thumbnail generation must be enable at compile time.
enable_thumbnail=yes

# The width of the thumbnail image. Large images takes more time to generate. To use this option, thumbnail generation must be enable at compile time.
thumbnail_width=160

# Thumbnail Image quality. To use this option, thumbnail generation must be enable at compile time.
thumbnail_quality=8

# Should the thumbnail have a film strip? To use this option, thumbnail generation must be enable at compile time.
enable_thumbnail_filmstrip=yes

# For owners of LG TVs who suffer from 100% CPU utilization on the server
# If you have a large collection of movies, set this value to define
# how many objects will be sent by the server at once (0-100)
# The downside of using this option is being unable to
# "see" all images and/or pictures at once, the workaround is to use
# the "Browse Folders" mode
# search_limit=0

I suggest to change the following lines inside "minidlna.conf" file:

Remember that "minidlna" server may show a presentation page, usually it is at address "http://[router address]:[port]", where "port" is the port included in the config file inside line "port=" (default value is 8200). The presentation page includes a summary of all scanned files (classified into "Audio files", "Video files" and "Image files"), and a summary of all connected clients.
Unfortunately the presentation page doesn't include any active button that execute an action on the minidlna server, for example it does not allow to rescan the folders or to rebuild the database. These actions must be done manually, using the script to stop the server and then manually starting the server with the proper parameters.