Home Streaming Server

Jarret B

Well-Known Member
Staff member
Joined
May 22, 2017
Messages
372
Reaction score
432
Credits
13,798
I am making a DLNA Server to be able to stream audio, video and pictures within my house. This article will go over the details of what I have done for my system. I hope some of you can duplicate this if you need to, as well as comment on improving the server.

There are quite a few concepts in this article, so certain sections can be used on their own. For example, I will add SSH to the DLNA server so I can manage it from other systems. Samba will be installed so files can be moved from other systems on the network.

Hardware

For a DLNA server, you do not need much, unless you plan on streaming to quite a few devices at once. I plan on streaming to maybe only two televisions at the same time, but there could be more.

I found a Lenovo Thinkcentre M73 tiny business desktop. It has the following pertinent specs:
  • Intel Core i3 (2.9GHz)
  • 4 GB DDR3 RAM (I will upgrade to 10 GB)
  • 500 GB HDD
  • USB 3.0
  • Gigabit Ethernet
Within the BIOS, I can enable the device to work without a keyboard. I also enabled the device to power on after a power failure, so if the power goes out, I do not need to turn it back on manually. I installed Lubuntu to use fewer resources, so more can be available for streaming content.

I definitely like the Core i3 as a starting point for the server. I did not feel comfortable using a Pentium or Celeron. A slower processor may work fine, but I would prefer to have fast, non-buffering streaming.

Since the system only came with 2-2 GB RAM chips, I replaced one with an 8 GB memory chip to upgrade it. Since the system is DDR3, an 8 GB SIMM is only about $35.

I liked the USB 3.0 port so an external USB HDD can get fast access.

The external hard drive is a bit of different beast. I found an 8TB external drive on clearance at Walmart that is an Xbox Game Hub drive. The speed on the drive is about 160 MB/s using USB 3.0. This should be adequate for streaming, since HD only requires about 1.5 Mb/s. I’m looking for higher speed to move files from other systems quickly.

Cost wise, the refurbished Lenovo system and came with a one-year warranty for $125 from Amazon. The RAM chip was $35. The external HDD was $89. That makes $249 for my DLNA server.

Lubuntu

From ‘Lubuntu.me’, I downloaded Lubuntu 20.04 64-bit for the Operating System (OS). I installed it on the internal drive as normal, overwriting Windows 10 Pro. Of course, I made an ISO file and wrote down the Product Key if I need to install it elsewhere.

I enabled the automatic login when I set up my user and password. This way, when the system reboots for any reason, it will restart everything and log in and be ready to go. I formatted the internal and external drive as EXT4 for a little more speed performance.

The only bad thing about the system is that it has no HDMI port, only a DisplayPort. I plan on not hooking it up to a monitor of any type, or keyboard or mouse, once everything is completely installed. Once I have everything set up, I should not need a monitor.

Once installed and rebooted, I performed a system update:

sudo apt update && sudo apt upgrade -y

Within the Operating System, disable power management. It would not be good to have the system shut down when not being used. Disable the Screen Saver, so resources aren’t wasted for it. No need for a screen saver when you aren’t using a monitor. You may need to install GParted to manage external drive partitions and formatting. Disable Wi-Fi, unless you plan on using Wi-Fi instead of a direct connect set up. Install VLC if needed to include codecs which could be helpful, Lubuntu 20.04 comes with VLC installed. We can install extra codecs with:

sudo apt install ubuntu-restricted-extras -y

When you install the extra codecs, you are asked to accept the EULA and license agreement.

If you wanted, you could uninstall unneeded applications to free up space on the internal drive.

NOTE: If you wanted, you could set the IP4 Address manually, so it does not change. If the IP Address would change, it would not affect the DLNA service from a client’s viewpoint. The Samba and SSH servers need a known IP Address from the clients.

This is a basic setup for the Operating System. Now we can move on to setting up an external drive.

External Shared Drive

Using an external drive is not as simple as plugging it in and moving on. It must be mounted or the permissions will fail.

NOTE: This is a very important step. If the drive that you are sharing and using to store streaming files, make sure it is mounted. There are many ways to accomplish this task, but the way I will do it is an easy GUI based way.

Open a Terminal and install the Gnome Disk Utilities with ‘sudo apt install gnome-disk-ultility -y’. Once the app is installed, start the disk utility program with the command ‘sudo gnome-disks’.

Once the app starts, select your external drive in the left pane. Click on the icon with the two gears just below the graphical template of the selected drive. Choose ‘Edit Mount Options’ from the drop-down list. In the next window, shown in Figure 1, turn on the option to mount the drive. Set the options to be like that in Figure 1. Make note of the line ‘Identify As’. Set the value to ‘by-label’ to use the label name you gave your drive. Once everything is set, select the ‘OK’ button to make the changes.

Figure01.jpg

Figure 1

Reboot for the settings to take effect.

Now that the external drive is properly mounted, we can install the Samba Server to be able to change the shared files remotely on the network.

Samba Server

Keep in mind that Samba is only being used to set up a network share for the external drive. The share will allow me to manage the shared files to stream. I can add, remove or change the files on the shared drive. Of course, these files are the ones being streamed.

From a terminal, you should have already updated the system. We can now install ‘tasksel’ to use to install Samba. Execute the following commands:

sudo apt install tasksel
sudo tasksel install samba-server


Next, you need to create, or use, an existing account. If you create a new account for Samba, it must also exist in the OS ‘passwd’ file. If you want to create a new account, use the ‘useradd’ command. I suggest just using the account that you normally use.

To add a user to Samba, perform the command:

sudo smbpasswd -a <username>

You will be prompted for a password, may as well use your regular password, and then you’re prompted to confirm it.

If you have a firewall enabled, you need to open a port for Samba with the command:

sudo ufw allow samba

We now need to add the share to the Samba configuration file. My external drive is ‘/mnt/Theatre/DLNA’. My drive name is ‘Theatre’ with a root folder called ‘DLNA’. The ‘DLNA’ folder is being shared for access by other users on the network. Within the ‘DLNA’ folder are the three folders that will be used for streaming: ‘Movies’, ‘Audio’ and ‘Pics’.

NOTE: Remember that the folder names are case-sensitive throughout this section.

Create a folder that will be shared and then you’ll need to modify the permissions with:

sudo chmod 777 /mnt/Theatre/DLNA

We need to modify the configuration file for Samba. Open the file ‘/etc/samba/smb.conf’ with your favorite text editor and add the following to the bottom:

[DLNA]
path = /mnt/Theatre/DLNA
browsable = yes
create mask = 0660
directory mask = 0771
writable = yes
guest ok = yes


The Share name is placed in brackets, in my case [DLNA]. You can change this as you need for your system. The ‘path’ should also be changed to match your folder share.

In a terminal, run the command ‘sudo systemctl restart smbd’ to restart the service. You can use the command ‘sudo systemctl enable smbd’ to make sure the service automatically restarts at boot up.

You may need to restart the system just to make sure everything takes effect.

From a Windows system, you need to right-click on ‘This PC’ and select ‘Map Network Drive’. Select a Drive letter to map the share to over the network. Under ‘Folder’ type in ‘\\192.168.1.45\DLNA’. It is best to use the IP Address of the Samba Server and then the share name. You can choose to ‘Reconnect at sign-in’ if you want. Definitely check the box for ‘Connect using different credentials’, otherwise it uses your Windows name and password for the Samba share.

From a Linux system, open the File Manager and select ‘Network’. The Samba Server should appear. Double-click the Samba Server. Double-click on the share you want to open (DLNA in my case). You will be prompted for authentication information. Select to connect as a ‘Registered User’. Enter your username and password that was added to Samba. Select one of the options ‘Forget password immediately’, Remember password until you logout’ or ‘Remember forever’. As long as you got the username and password correct, you should connect just fine.

MiniDLNA

We now need to set up the streaming service. The procedure is not as involved as Samba, but there are configuration settings that can be a little tricky.

The MiniDLNA Server manages sending a file list to DLNA clients. Most smart TVs are DLNA compatible. If not, ROKU definitely is compatible. Within ROKU is an app call ‘ROKU Media Player’. If you do not have the app on your menu, then you need to install it. For Firestick users, you can use the VLC or Nova Video Player. Each device has other apps that work, but these I know do work.

To start installation, run the command:

sudo apt install minidlna

Once installed, we can configure the various folders. Remember my three folders within DLNA: ‘Movies’, ‘Audio’ and ‘Pics’. We will set up these three streaming folders for network devices.

You will need to edit the file ‘/etc/minidlna.conf’. For each streaming folder, you need to add a line. Each line has three designations:

  1. A – audio
  2. V – video
  3. P – pictures
You can use ‘PV’ for a folder with both pictures and video, but not often used.

The three lines I would add to my configuration file are:

media_dir=A,/mnt/Theatre/DLNA/Audio
media_dir=V,/mnt/Theatre/DLNA/Movies
media_dir=P,/mnt/Theatre/DLNA/Pics


Within the configuration file, make sure there is a line for ‘inotify=yes’. Remove the comment (#) from the line ‘# db_dir=/var/cache/minidlna’ to enable the database file to be on the internal drive. It would be good to remove the comment for the line ‘#log_dir=/var/log’. To specify a friendly name for the DLNA Server, remove the comment for ‘# friendly_name= ’ and add a name with no spaces. You can also change the line ‘# max_connections=50’ to be 250 or more and remove the comment (#).

NOTE: The ‘inotify=yes’ allows the DLNA database to be automatically updated when files are added to the specified folders.

You will need to add your user account to the group ‘minidlna’. Also, for Samba, add the ‘minidlna’ group to the ‘sambashare’ group.

We will also need to increase the ‘inotify.max_user_watches’ from around 35,000 to 100,000. To do this, edit the file ‘/etc/sysctl.d/90-inotify.conf’, with ‘sudo’ privileges, and add the line:

fs.inotify.max_user_watches = 100000

Save and close the file. The file will handle changing the value when the system is rebooted. You can make a change to the system without rebooting with the command:

sysctl fs.inotify.max_user_watches=100000

We can set the ‘minidlna’ service to autostart with the OS by enabling the service:

sudo systemctl enable minidlna

Once you have moved files into their proper folders you can refresh the database with the command ‘minidnlad -r’ From a client system that is accessing the files, the updated database is not available until you exit and reload the application you are using to stream.

NOTE: If a device gives an error that no files are found, then you need to check the owner of the files and change them to ‘minidlna’. You can also open ‘/etc/minidlna.conf’ and add a line ‘user=<username>’. Make the ‘<username>’ match the files. It’s supposed to default to ‘root’ if the line is commmented or doesn’t exist, but it doesn’t always work.

If there is a firewall enabled, you need to open port 8200 for streaming.

SSH

We can copy files to the server using samba and stream the files using minidlna, but we need to be able to run programs on the server. Such as updating the software or updating the minidlna database. This is where SSH comes into play.

We could use RDP, but there isn’t a need to be able to manage the server graphically.

Make sure you have your system up-to-date before proceeding. To install SSH, perform the following command:

sudo apt install openssh-server -y

SSH is now installed and should be running. Execute the command ‘sudo systemctl status ssh’ and it should show it is ‘running’ and ‘active’.

Next, you need to enable the service to start automatically when the system starts with the command: ‘sudo systemctl enable ssh’.

A firewall on the Linux OS can block SSH so we need to open that port. Use the command ‘sudo ufw allow ssh’.

At this point, I can SSH into my DLNA-Server from an SSH Client.

From a Linux system, install the SSH Client with the command: ‘sudo apt install openssh-client’. From Windows 10, there should be a client already.

From a Terminal, or Command Line, use the command ‘ssh user@IP-Address’. In my case it is ‘ssh [email protected]’. After executing the command for the first time, you should be prompted that you need to authenticate the server and client. Type ‘yes’ and press ENTER. You should then be prompted to enter the password for the user you specified and see a prompt that is from the DLNA-Server. You can issue commands to the server, such as ‘minidlnad -r’ to update the database of files. Once your server is running properly, be aware that some system updates may cause the DLNA service to stop until you perform a reboot. A reboot causes the database to be reconstructed from scratch. I suggest to not perform systems updates unless it is necessary.

Type ‘exit’ to close the SSH connection.

Folder Art

Within each folder, you can place a JPG file and name it ‘cover.jpg’ or ‘Cover.jpg’. Some systems, like Roku Media Player, will replace the simple folder icon with the image you placed in the folder. Sub-folders can also have their own image as well.

The DLNA system will automatically find new files and folders, but image files are another story. To fully update the whole database, you need to clean it all out and have it generate a new database. The following script is what I use. I called it ‘refresh.sh’:

#!/bin/sh
# Stop MINIDLNA
systemctl stop minidlna #/etc/init.d/minidlna.init stop
# Delete /tmp/ database files(Database and Art)
rm -rvf /tmp/minidlna/*
# Start Service and Rebuild MINIDNA database
minidlnad -R
# Start and Show MINIDLNA status
systemctl start minidlna
systemctl status minidlna
#Force the rebuild just in case
minidlnad -r


Make sure to perform the command ‘chmod +x refresh.sh’ to make the file executable. To run the script, you can SSH into the DLNA server and type ‘sudo ./refresh.sh’. I placed the file in the user’s Home folder that I use to SSH into the server.

Troubleshooting

There is a lot that can go wrong with the minidlna service. Keep an eye on the log file at ‘/var/log/minidlna.log’. If you see an error writing to the database, you can delete the database file at ‘/var/cache/minidlna/files.db’. If this does not fix the problem, then also delete the ‘/tmp/minidlna’ folder contents with the command ‘rm -rvf /tmp/minidlna*’. The command will delete all files and folders within the ‘/tmp/minidlna’ folder. Once the databases are deleted, it should automatically generate a new one. It may be best just to use the script mentioned above.

Check the log often. When the database is generated and corrupted video files are found, a list is generated in the log file. You will need to delete the corrupted files or fix them, if you can.

Again, do not perform system updates. If you do, reboot and let the database be recreated. Depending on the number of files you have, the recreation process could take a few minutes.

Conclusion

At this point, your DLNA Server should be set up and ready to go once you have placed files in the necessary folders and rebuilt the database.

Having a DLNA Server can make it very nice and handy for a streaming theater experience in your home.

Please do comment if you have any suggestions to make the server better.

NOTE: I thought about KODI and others that present a nice background image and such, but those get way too involved. They require a special naming convention for files. I am trying to make this easy and painless for long-term use. Also, be aware that some of the ‘better’ DLNA Server software is requiring payment for some services.
 


I have a similar setup for our KODI media server, except I made SAMBA shares read-only (so if some of the family happen to ever get crypto-lockered the shares don't get written to). I transcode my media on my workstation, which is more powerful than our media centre, then transfer them over via SSH/Filezilla.
 
i use Plex and have not really set anything up since I only use DVD/BR/4K I own and I rip them on the same PC as plex is on.
 
Isn't it just easier to use Jellyfin, Emby or Plex, I currently use Plex (because I have found that it's the most mature of the three) and have my library mounted as nfs share which is shared from another system.
 
I wanted to keep it simple as well as make it so users can make a simple file-sharing system on their network. Using SSH is a lso a plus to learn.
 
First of all thanks for sharing, I just thought I would share my thoughts since the topic is mediastreaming. I ssh into my Plexmedia server as well since it doesn't have a gui. I find the advantage of something like Plex is that the Plex client is available on many different devices. That way you can just install the Plex client app on your smart TV and then stream it through your wifi, that way you can stick Streaming server in a closet somewhere and won't need to hook it up to your TV with an hdmi cable. If you don't have a smart TV, you can always buy something like a Roku, Apple TV or an Nvidia Shield where you can then install the Plex client.
 
First of all thanks for sharing, I just thought I would share my thoughts since the topic is mediastreaming. I ssh into my Plexmedia server as well since it doesn't have a gui. I find the advantage of something like Plex is that the Plex client is available on many different devices. That way you can just install the Plex client app on your smart TV and then stream it through your wifi, that way you can stick Streaming server in a closet somewhere and won't need to hook it up to your TV with an hdmi cable. If you don't have a smart TV, you can always buy something like a Roku, Apple TV or an Nvidia Shield where you can then install the Plex client.

Yes and no, the good about plex is that it is easy to set up and make a plex server. It is easy to make a FreeNAS or get a NAS server with the Plex app or use your win PC and just install the Plex server and done. Still, the biggest problem I have is if you don't have a Conversion of every device using or don't use the Plex App to win, then it will convert the video on the fly, which is okay if you have a GPU that can handle the Rendering and if you more then one user then you need a Quadro card or a card that have to unlock renderings, so it does not lock on 1-2 Rendering as typically GPU is also it can make you movie keep buffing depending on the format, size and network speed and so on. But of all the home theater Video Servers i, tired like Plex the most because of its easiness and that you can watch it outside your home. If it were not because of how hard it is to set up on every PC in the house, then I would have loved Kodi better since it won't have that problem, but i just find it a pain in the bump to setup.
 
Still, the biggest problem I have is if you don't have a Conversion of every device using or don't use the Plex App to win, then it will convert the video on the fly, which is okay if you have a GPU that can handle the Rendering and if you more then one user then you need a Quadro card or a card that have to unlock renderings
This article was talking about local streaming not remote streaming. As for local streaming most devices now days support the most popular used video and audio formats, for example my 4K LG TV supports can play all of my 1080p content without having to trans-code, however when it comes to 4K content there are still video and audio formats that my TV does not seem to support. That being the reason why I actually have an Nvidia Shield because it seems to be the best media player around. For example when I'm connected to my WLAN with my phone my phone directs play everything but when I am connected through my phone through 4G the files are trans-coded but I am still able to view it without running into issues unless I am in an area where the 4g has a bad signal.

As for my users they are located over different time-zones and they usually never stream all at the same time, some direct stream and others cause Plex to trans-code. I don't have a dedicated gpu for trans-coding and I run Plex on a vm and my host has a ryzen cpu. The thing is I only share 1080p content with my users not 4k content. So when Plex doesn't need to trans-code what a specific users is streaming it's not a big deal because it doesn't take a lot of cpu power. I haven't had any complaints about my users having stutters and I usually explain to them where to configure it so that their Plex clients are configured to use "Original Quality" because by default Plex clients seem to not be configured for that. I'm not one of those people on r/Plex who make it a competition of how many concurrent users they have streaming 4k content that is trans-coding and I don't have a lot users. I do it for family and friends so no need to buy an expensive gpu when the trans-coding is kept to a minimal, as well as my opinion is if you do it right most content is direct played and when it is trans-coded it is kept to to a minimum by only sharing 1080p content with your users.

As for Kodi, I used to have a setup running a Linux media-center which mounted the same nfs share from my server. The problem with that was after I got a 4K TV with HDR support is that it seems Linux doesn't support HDR. So that being the reason why I then switched over to Streaming trying Jellyfin, Emby and Plex, then finally sticking with Plex because it seems the most mature one out of the three and the most used one.
 
Last edited:
i don't have a 4k smart tv so I can't say. I normally use Chromecast, Laptop/mobile, or web browser. and I can tell you those will most of the time convert your movie if they are not compact in an MP4 format like H263/4 even on LAN I normally have all my movies in a passthrough mkv to keep it the same quality as on the disk which is just a like a zip file for Video so I can have all the Dub and Sub that is on the Disk in the MKV file but using the Plex media Center don't convert them no matter file type I tried so far I have not tried them all of cause.
 
I have seen Chromecast and Roku cause trans-codes but most likely that the person wasn't following up on my advice on enabling "Original Quality" under video on the client. I will still have to check when I have visit them sometime :) As mentioned before the trans-codes from 1080p to 720p or from x265 to x264 aren't that extreme in cpu load, it's only when converting 4k to 1080p or 720p that I have seen very high cpu loads that's why I don't share 4k content. As for this article, I would think that it also goes for the streaming described in this article that if a device doesn't support a certain format that the streaming side has to do some kind of trans-coding.
2022-03-27_13_24_08.png
2022-03-27_13_24_46.png
 
Last edited:


Latest posts

Top