Martin Cooper's Linux Blog

All things Linux …

Media Server for the Sony Bravia

I wanted a DLNA/UPnP server to allow me to view photos, listen to music and watch videos and PC recorded TV on my TV. The media is currently stored on my Linux server. I tried various options before finding miniDLNA here http://minidlna.sourceforge.net/ . The MiniDLNA server was extremely easy to set-up and worked out of the box and coped with my Sony Bravia KDL-40W5500 40in LCD which other servers software did not. The TV is connected to my local network via a network cable to a Home Plug.

The Home Plug is a DEVOLO dLAN 200 AVmini Starter Kit 2x Home Plug AV Adapters £79.99 from PC World in the UK

This TV supports images as .jpg, music as .mp3 and video as .mpg or .m2t/m2ts, I’ll blog post how to get the correct settings for the video files later. [ Edit see here tsmuxer-video-conversion-for-sony-bravia/ ]

First I downloaded both the static and src tar files from here http://sourceforge.net/projects/minidlna/files/minidlna/ [go for the latest currently 1.0.22] I wanted the pre-build version as there are a lot of unmet dependencies when I tried building it on Debian Squeeze and a frankly gave up. Download the 2 files [currently minidlna_1.0.22_src.tar.gz and minidlna_1.0.22_static.tar.gz]. Open the static version in your favourite archiver and extract the file minidlna located in /usr/sbin directory within the archive and minidnla.conf located in etc/ directory within the archive to your home directory. Now using your archiver program again to open the src version and extract the minidlna.init.d.script from the /linux/ directory within the archive to your home folder.

you should now have 3 files;

minidnla
minidnla.conf
minidlna.init.d.script

in your home directory

now open the minidlna.conf in your favourite text editor and change the following highlighted text to match the paths to your media, server name and paths to store the database & log files.

***** file extract *****

# 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=A,/home/martin/Musics
media_dir=V,/home/martin/Videos
media_dir=P,/home/martin/Photos

# set this if you want to customize the name that shows up on your clients
friendly_name=Angel

# set this if you would like to specify the directory where you want MiniDLNA to store its database and album art cache
db_dir=/home/martin/.minidlna

# set this if you would like to specify the directory where you want MiniDLNA to store its log file
log_dir=/home/martin/Logs

***** End file extract *****

I left the rest of the config as it was.

Now we need to sore the config and program file and test they work so in a Terminal;

$ mv ~/minidnla.conf ~./minidnla.conf

this moves the file into your home directory as a hidden file by adding the dot at the from of it. I have a seperate partition for the system directory /opt so that I can store user added programs which I don’t want to get removed when I do an upgrade so I’m going to store the minidnla program there in it’s own directory

$ sudo mkdir /opt/minidnla

create the directory

$ sudo mv ~/minidnla /opt/minidnla/minidnla

move the program file into it.

$ sudo chmod +x /opt/minidnla/minidlna

make it executable

You could leave the program in your own home directory or move it into /usr/bin in which case amend the paths in the commands above.

Now we can run the program to see if it works with in my case;

$ /opt/minidlna/minidlna -f /home/martin/.minidlna.conf

so this is the path to the program, followed by -f telling it to look for a file then the path to your config file.

This should now start minidnla building it’s database and then serving up the results, depending on the number of files this may take a while but you can check out the log file for errors on progress.

The only problem I had was that one of the music directories had root permissions on it not my own so if you get error that’s the first thing to check. If all has gone well you should be able to see the results on the TV. If your TV does not see the server which on mine shows up under the name of the server I added in the minidnla.cof and has a Tux penguin icon then check out your Firewall on the PC server.

Next we want to be able to autostart the server if we ever restart our server and be able to start, stop or restart it with easy options. So now open the minidlna.init.d.script in your favorite text editor and amend the highlighted text shown below. Just 2 lines to amend the path to your minidnla program and the path to the monidnla.conf file.

***** file extract *****

# Short-Description: DLNA/UPnP-AV media server
### END INIT INFO

MINIDLNA=/opt/minidlna/minidlna
ARGS=’-f /home/martin/.minidlna.conf’

test -f $MINIDLNA || exit 0

. /lib/lsb/init-functions

case “$1” in

***** End file extract *****

now move it to /etc/init.d/ with

$ sudo cp /home/martin/minidlna.init.d.script /etc/init.d/minidlna

this changes it’s name to just minidnla and

$ sudo chmod +x /etc/init.d/minidlna

make it executable, now reboot the PC and the server should auto start.

$ sudo update-rc.d minidlna defaults

And update, now you can the use the following commands from a Terminal to control the server.

$ sudo /etc/init.d/minidlna stop

$ sudo /etc/init.d/minidlna start

$ sudo /etc/init.d/minidlna restart

Advertisements

3 responses to “Media Server for the Sony Bravia

  1. Pingback: HAUPPAUGE WinTV Nova-T Digital Terrestrial TV Stick « Martin Cooper's Linux Blog

  2. Toby Reme January 19, 2012 at 5:42 pm

    An alternative DLNA server is Serviio (www.servio.org). Once I fgured out that the rendering device’s exact “Device Name” (which can be got under Network Setup/Renderer on the TV ) had to be entered identically into the Serviio setup “Device Name” box ( BRAVIA KDL-32V550 in my case), and that I had to open ports 8895/TCP and 1900/UDP on my Ubuntu PC’s ufw firewall, then everything flew.

  3. tracomart July 13, 2012 at 2:22 pm

    Thanks for this post. I have used it to set up Minidlna on Squeeze to make media files available to a Sony Network Media Player (which connects the Sony Bravia to the internet) with great success. I think a new name for Minidlna is in order, though, as I managed to type Minidnla quite a few times without realising it should be Minidlna – independently of your similar mistyping a few times in the post. Thanks again.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: