Thursday, June 7, 2012

HowTo: Install and setup MiniDLNA on FreeBSD

MiniDLNA is a server software with the aim of being fully compliant with DLNA/UPnP-AV clients. MiniDLNA is used to serve multimedia files such as music, videos and picture to clients on a given network.

MiniDLNA employs Universal Plug and Play (UPnP) thus you can have clients such as TVs, consoles and smartphones.

In this post I'll describe the steps needed to install and configure it to run on FreeBSD, though the steps were performed on 7.4-RELEASE they'll work on more recent FreeBSD branches such as 8.x and 9.x.

Let's start by installing the net/minidlna port:
  1. # cd /usr/ports/net/minidlna
  2. # make config-recursive
  3. # make install clean

Having installed the port, it's time to edit the configuration file. As an example, I'll leave my own as reference. Make sure that you edit network_interface, media_dir and friendly_name.
  1. # vim /usr/local/etc/minidlna.conf

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

    # network interfaces to serve, comma delimited
    network_interface=re0

    # 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/samba/public/movies
    media_dir=V,/mnt/1/tv
    media_dir=V,/mnt/2/anime
    media_dir=A,/mnt/1/music
    media_dir=P,/mnt/1/photos

    # set this if you want to customize the name that shows up on your clients
    friendly_name=FreeBSD 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=/var/db/minidlna

    # set this if you would like to specify the directory where you want MiniDLNA to store its log file
    log_dir=/var/db/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=1337
    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=.

To have MiniDLNA working properly the dlna user must be made owner of the /var/db/minidlna directory:
  1. # mkdir -p /var/db/minidlna
  2. # chown dlna:dlna /var/db/minidlna

To start using MiniDLNA immediately issue the following command:
  1. # /usr/local/etc/rc.d/minidlna onestart

If you want to have it start up automatically whenever FreeBSD boots, add it to /etc/rc.conf like so:
  1. # echo 'minidlna_enable="YES"' >> /etc/rc.conf

Finally MiniDLNA's log file can be monitored for errors:
  1. # tail -f /var/db/minidlna/minidlna.log

MiniDLNA it's quite simple and lightweight however it is missing features that can be found in more complete UPnP servers. Those operating on old hardware might find it very useful.

Be advised that if you're planning on sharing multimedia files over a local network composed mainly of desktops and laptops, NFS and Samba are more flexible filesharing alternatives. On the other hand, if you want to stream to a TV, console or smartphone then by all means go for an UPnP server like MiniDLNA or MediaTomb.

If you're using an Android smartphone have a look at the MediaHouse app. From my experience it works just fine with MiniDLNA.

9 comments:

dualcells said...

Thanks for the tips! This was exactly what I was looking for to pair with the Samba 3.6.7 server I installed recently.

Whatever video I encode with DivX Pro is dropped onto my server via a Samba share then served upto my PS3.

Anonymous said...

Please, suggest me the settings for samba and the rights to the folder:
media_dir=V,/home/samba/public/movies

thx

tangram said...

Hi,

That line was meant has an example of the type of media_dir argument.

If you're seeking help setting up Samba shares that's outside the scope of this HowTo.

Regards,
tangram.

tangram said...

No problem. Glad to help.

skiesis said...

Thank you!!

Unknown said...

Just used your tutorial to set up a DLNA server on FreeBSD 10. Works great. Thanks for taking the time to write this up.

Unknown said...

Thanks for taking the time to write up this tutorial. I just used it to set up a DLNA server on FreeBSD 10. Worked great.

Bruce Walker said...

Thought you'd like to know that your post helped me to get this installed under FreeBSD 13.1 serving FLAC files to a WiiM Pro streamer/DAC. I'm new to the media streaming world and your info was a great help. Cheers!

tangram said...

Glad it's still helpful after all these years :D