Serviio

The OpenBSD Way

About

Serviio is a simple, easy to use DLNA media server that does on-the-fly media transcoding and remuxing to enable a hassle free DLNA experience. It also has an integrated HTML5 media server for on-the-go use on mobile or in your browser.

I've adapted these install instructions from the official install guide on the Serviio Wiki. I decided to make my own install instructions for OpenBSD that don't start Serviio as root and that put the installed files in a better location.

How To

• Create a new user for Serviio

 # adduser _serviio 


• Add necessary packages:
Note: (dcraw is only needed for RAW image support)
 # pkg_add jre ffmpeg dcraw 
• Download and Install Serviio:
Note: As of August 2018, 1.9.2 is the latest Serviio release. Always check the offical release page for the latest version.

	
	$ cd /tmp
	$ ftp http://download.serviio.org/releases/serviio-1.9.2-linux.tar.gz 
	$ cd /usr/local/ 
        # mv /tmp/serviio-1.9.2-linux.tar.gz .
        # tar -xvzf serviio-1.9.2-linux.tar.gz
        # mv serviio-1.9.2 serviio
        # rm /usr/local/serviio-1.9.2-linux.tar.gz
	# chown -R _serviio:_serviio serviio
      


• Open serviio.sh and add the following line directly below the PROGNAME variable declaration.

	# vi /usr/local/serviio/bin/serviio.sh
          JAVA_HOME="/usr/local/jre-1.8.0"
      
• Taken mostly verbatim from the install guide:

On OpenBSD it can take a while for the server to appear in the list of DLNA clients. This appears to be due to the beaconing interval default used within the Serviio code. In order to overcome this problem we need to add the following to the JAVA_OPTS string within the serviio.sh script:

	-Dserviio.advertisementDuration=60
	

The new launch command will look as follows:


	# Setup Serviio specific properties
JAVA_OPTS="-Djava.net.preferIPv4Stack=true -Djava.awt.headless=true -Dorg.restlet.engine.loggerFacadeClass=org.restlet.ext.slf4j.Slf4jLoggerFacade -Dderby.system.home=$SERVIIO_HOME/library -Dserviio.home=$SERVIIO_HOME -Dffmpeg.location=ffmpeg -Ddcraw.location=dcraw -Dserviio.advertisementDuration=60"
    


• Note: You will need to increase your limits in /etc/login.conf to allow at least 1.5G of memory usage An example login.conf section with the default limits raised looks something like this:

	default:\
        :path=/usr/bin /bin /usr/sbin /sbin /usr/X11R6/bin /usr/local/bin /usr/local/sbin:\
        :umask=022:\
        :datasize-max=2048M:\
        :datasize-cur=2048M:\
        :maxproc-max=256:\
        :maxproc-cur=128:\
        :openfiles-max=1024:\
        :openfiles-cur=512:\
        :stacksize-cur=4M:\
        :localcipher=blowfish,a:\
        :tc=auth-defaults:\
        :tc=auth-ftp-defaults:
	


• Confirm that Serviio Starts Correctly:

	# su _serviio
	$ /usr/local/serviio/bin/serviio.sh &
	
• You should now have your Serviio console listening on port 23423. For example http://$serviio_pc_ip_address:23423/console/ should bring it up.

• Your Serviio instance is now ready for prime time. We just need to set up cron jobs to start Serviio at boot:

      # crontab -u _serviio -e 
      @reboot			/bin/sh	/usr/local/serviio/bin/serviio.sh 
     


• To access the HTML5 media player put http://$serviio_pc_ip_address:23424/mediabrowser into your browser.

• If you are accessing the media browser over the internet, you should probably pipe your connection over an SSH tunnel for the best security. Otherwise you can put httpd in front of it to handle SSL.

• To change the DLNA server "friendly" name:

	  # vi /usr/local/serviio/config/profiles.xml
	  <FriendlyName>OpenBSD Media Server</FriendlyName>
	


• You may want to set the temp transcoding directory to the "_serviio" users home folder. This can be done in the Serviio console, under the Delivery/Transcoding menu options. This should ensure there is enough space to hold a full transcoded movie. At least 5GB scratch space should be made available for Serviio to store temporary video transcodes.

• When you select your media library folder, make sure to select "Use the poller mechanism for monitoring this folder" checkbox so that your media library stays properly updated.

• Additionally, you may want to isolate Serviio in a vmm(4) virtual machine with read only NFS access to your media library. Serviio is proprietary software; I myself am uncomfortable giving any proprietary program the ability to read/write arbitrary files on my machine, thus why I run it inside a dedicated virtual machine. If you do opt to go that route, you must set up your VM networking via a virtual switch so as to enable the VM to pull an address on the same subnet as as the DLNA client devices you intend to serve content to. The virtual switch is essential to allowing the unicast/multicast broadcast and other DLNA protocol traffic to pass freely between the DLNA server and client. Explaining vmm setup and networking is beyond the scope of this write up, so I will leave that as an exercise for the reader.