I’m normally playing videos from a SAMBA share installed in a Ubuntu PC to play files from Kodi in Android TV box reviews, but sometimes when I use 10/100 Ethernet, or worse WiFi local “streaming” may not be as smooth as possible. SAMBA is convenient because of access control and read write operations, but if you want to get a bit more performance, you may switch to NFS instead, or like I’ve going to show you here to a DLNA / UPnP server to stream videos locally from Kodi 16.1.
There are several options, but MiniDLNA is lightweight compared to MediaTomb, so it will also run on lower end hardware like cheap ARM Linux development boards like Raspberry Pi, Orange Pi, or NanoPi NEO without taking too many resources.
Installation is very easy in Debian / Ubuntu distributions, and I supposed this should also work with Windows Subsystem for Linux in Windows 10:
1 |
sudo apt-get install minidlna |
MiniDLNA can be configured with the same settings for all users, or different settings for specific users. In both case you’ll need to edit /etc/minidlna.conf configuration file. In my case, I only changed or uncommented the following lines for global settings:
1 2 3 4 5 6 7 8 9 10 11 |
media_dir=/media/jaufranc/SEAGATE EXTENSION/Downloads/cnxsoft/Video_Samples media_dir=/home/jaufranc/Videos db_dir=/var/cache/minidlna log_dir=/var/log # Automatic discovery of new files in the media_dir directory. inotify=yes # Notify interval, in seconds. notify_interval=895 |
You can add as many media_dir lines as you want, and also add A, V or P letter to separate Audio, Video, and Photo media type. For example:
1 2 3 |
media_dir=A,/home/user/Music media_dir=P,/home/user/Pictures media_dir=V,/home/user/Videos |
Please note that minidlna daemon (minidlnad) will automatically scan subdirectories, so they don’t need to be specified.
Now that we have modifed the configuration, let’s restart it:
1 |
sudo service minidlna restart |
The Wiki on Ubuntu linked in the introduction also mentions to run the following command to rebuild the database:
1 |
sudo service minidlna force-reload |
However, while I could find my new UPnP server in Kodi, there were no files at all, and the log shows the same error message over and over:
1 2 3 |
[2016/08/16 11:05:49] upnphttp.c:1052: warn: HTTP Connection closed unexpectedly [2016/08/16 11:05:54] upnphttp.c:1052: warn: HTTP Connection closed unexpectedly [2016/08/16 11:05:59] upnphttp.c:1052: warn: HTTP Connection closed unexpectedly |
eventually the command:
1 |
sudo minidlnad -R |
fixed the issue. But that’s not exactly the right way to fix it as it assumes root is running the daemon.
A better way if you’re going to have a decidated server is probably to set the ownership of media files to minidlna with a command like:
1 |
sudo chown minidlna:minidlna media_dir -R |
So how do you play videos from your DLNA/UPnP server in Kodi 16.1? Go to Videos->Files, and select Add videos…
Kodi should like your UPnP / DLNA servers. In my case FX8350:root, which correspond to the hostname or friendly_name in the hostname, and to the user, normally minidlna. Select the server, than Browser Folder, or Videos, and click OK.
I’ve shot a short video showing how to setup UPnP devices in Kodi, and compare SAMBA and DLNA performance by playing the same video file in Kodi 16.1 Android through SAMBA and UPnP/DLNA.
You’ll notice the video played from the SAMBA server starts much faster, but buffers several time during playback, while the video played from MiniDLNA server on the same PC will buffer data longer at start, and always fill the buffer fast enough to avoid bufferring.
I took Conky screenshots for another video showing the traffic shape for both SAMBA with relatively constant speed (6600 KB/s to 7400 KB/s) and DLNA which shows very high bitrate (>10000 KB/s) to fill the buffer the first time, and then play consistently around 6400 to 6800 KB/s.
Of course switching from SAMBA to DLNA won’t do miracles, but if you notice a few buffering while playing videos in SAMBA, switching to DLNA/UPnP may resolve the issue. You can also keep the best of both world, for example using SAMBA to download/copy files, and DLNA to play them back.
Jean-Luc started CNX Software in 2010 as a part-time endeavor, before quitting his job as a software engineering manager, and starting to write daily news, and reviews full time later in 2011.
Support CNX Software! Donate via cryptocurrencies, become a Patron on Patreon, or purchase goods on Amazon or Aliexpress
My only complaint about using UPNP is that external subtitles are not loaded, something that with SMB share seems to work.
@MrT It will allow me to browse for the subtitle, but when I (manually) select it, it ends with an HTTP 404 error: User-Agent: Kodi/16.1 (Linux; Android 6.0.1; MXQ Plus Build/MHC19J) Android/6.0.1 Sys_CPU/armv8l App_Bitness/32 Version/16.1-Git:2016-07-05-7ac56f4-dirty Host: 192.168.0.104:8200 Accept: */* Accept-Charset: UTF-8,*;q=0.8 [2016/08/16 16:43:20] upnphttp.c:1838: warn: not found, responding ERROR 404 [2016/08/16 16:43:20] upnphttp.c:1216: debug: HTTP RESPONSE: HTTP/1.1 404 Not Found Content-Type: text/html Connection: close Content-Length: 134 Server: Ubuntu DLNADOC/1.50 UPnP/1.0 MiniDLNA/1.1.5 Date: Tue, 16 Aug 2016 09:43:20 GMT EXT: <HTML><HEAD><TITLE>404 Not Found</TITLE></HEAD><BODY><H1>Not Found</H1>The requested URL was not found on this server.</BODY></HTML> 12345678910111213141516 User-Agent: Kodi/16.1 (Linux; Android 6.0.1; MXQ Plus Build/MHC19J)… Read more »
@Jean-Luc Aufranc (CNXSoft)
What I can do is to play the video over UPnP, and load the subtitle file over SAMBA. This has to be done manually, so it’s not quite user-friendly.
I have seen that accessing my Synology NAS with Samba from Ubuntu is very slow.
You think DLNA is faster? This is an interesting idea, is there a benchmark program to test this?
@Martin
I don’t know storage benchmarks work with DLNA because AFAIK it’s sending HTTP packets.
You can easily test it by playing videos with different bitrates from SAMBA and DLNA, and see if buffering decrease.
As mentioned in the introduction, NFS is also another alternative to SAMBA, which should also be faster.
@Jean-Luc Aufranc (CNXSoft)
It’s not after some fiddling with all protocol’s samba is the best and the most compatible for all major OSes
It needs some fine tuning although but after that nothing beats it hands down!
@Jean-Luc Aufranc (CNXSoft)
I did the following:
samba: cp /mnt/diskstation/video/bigmovie.avi /dev/null ==> 33 seconds
dlna (djmount): cp /mnt/dlna/DiskStation/Video/bigmovie.avi /dev/null ==> 88 seconds
but maybe djmount is not good (it mounts DLNA as file system).
I have been using Plex for a while, using its DLNA server, and works like a charm. Even when my server was a ODROID-U2 🙂
Your most likely seeing that spike in speed because the file is already being cached in memory when you do the test. its pulling that data faster because it doesn’t have to buffer it into memory before the transfer..
Do you know if it is possible to make minidlna (or use another program) to put the files in folders?
Windows’s media player has a DLNA server built in and when I access it from somewhere else the files would appear as they are in their folders, but minidlna puts them all in a single folder and I can’t distinguish between files with different names.
Thanks a lot. Works pefectly for me.