On this instructable, I'm going to show how to configure a Raspi to run a UPNP/DLNA server and renderer.
My main goal is to use it on my car as a media server.
As I still haven't got a wifi usb drive, I'll be setting this 'able as a home server/renderer, using MediaHouse on my Android phone for streaming.
Step 1: MiniDLNA
- First, we need to get our system updated and install MiniDLNA. I usually enter sudo su, so I don't have to enter sudo before each command.
Via terminal, type:
# sudo su
# apt-get update # apt-get upgrade
# apt-get install minidlna
After installation, we are going to configure minidlna:
# nano /etc/minidlna.conf
- Remove the comment (#) from these lines and add next to # media_dir to mount 3 USB drives:
media_dir=/mnt/usb0 media_dir=/mnt/usb1 media_dir=/mnt/usb2 # media_dir=A,/mnt/ext/Music # media_dir=P,/mnt/ext/Pictures # media_dir=V,/mnt/ext/Videos friendly_name=MyPi (change per your liking) inotify=yes
exit and save (Ctl+x, Y, Enter)
- I want my database to be rebuilt at each boot as it doesn't take too long, and keeps all files fresh and updated. The best way I found was to run a script at boot to launch MiniDLNA and have it rebuild the database.
# nano /etc/init.d/dlnascan
Paste the following:
#!/bin/bash ### BEGIN INIT INFO # Provides: dlnascan # Required-Start: $local_fs $network # Required-Stop: $local_fs # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: dlnascan # Description: Rebuilds MiniDLNA database on boot ### END INIT INFO service minidlna force-reload
Save the script and make it executable:
# chmod 755 /etc/init.d/dlnascan
Then, load it for startup:
# update-rc.d dlnascan defaults
Step 2: Renderer
Follow this excelent guide to install gstreamer (move down to the gstreamer section):
Step 3: Testing, 1, 2, 3...
Reboot the Pi with no media attached and load House Media or your preferred DLNA/UPNP app.
Scan the Pi's DLNA for files; there shouldn't be any. Attach a drive and reboot.
Wait for the database to build up (use a pen drive with a couple of files for testing) and restart your DLAN app. You should now see the new files.
Give yourself a tap on the back and start streaming!
Step 4: Update 1
- Looking back to step 1, and as we are controlling the Raspi through a smartphone app, I found the neat "Raspi SSH" app.
- This app lets us have preset SSH commands with a simple icon button press.
- Download the app and add 3 SSH commands - at least these are the ones I find most usefull:
- Button 1:
Name: Reboot Command: sudo reboot
- Button 2:
Name: Shutdown Command: sudo shutdown -h now
- Button 3:
Name: DLNAdbUpdate Command: sudo service minidlna force-reload
- Now, going back to step 1, the is no need for the boot script. Instead, we'll simply execute this command on terminal instead.
- Removing the script (if you had already configured the Raspi that way):
# sudo update-rc.d dlnascan remove
# sudo update-rc.d minidlna defaults