Update – Monday 26th December 2011.
Being a long term Logitech Squeezebox owner, I’m pleased to see that they have now incorperated a DNLA Server into their software and renamed it “Logitech Media Server“. I now no longer use Twonkyserver as the above software now serves my needs.
However, I’m keeping the instructions below so that other people can configure Twonkyserver on Linux.
Before we begin.
This is a commercial product, you will have to buy a license, however IMHO, it’s well worth the asking price, as it vastly outperforms the opensource products like Fuppes and MediaTomb with much better stability, and much lower runtime resources. There is a free trial, so you can evaluate it’s performance before you buy.
First thing you need to do is download twonkyserver to your machine.
Next we have to install it as root
chmod 744 twonkymedia-i386-glibc-2.2.5-6.0.23.sh
Set up the appropopriate multicast address to broadcast your files on your network.
sudo route add -net 220.127.116.11 netmask 240.0.0.0 dev eth0
Of course, the above will only be in your routing table until the next time you reboot your server. So a better solution is to append the following file.
sudo nano /etc/network/interfaces
Add the following to the bottom of the file (append to the bottom of your network settings, usually eth0 if you only have one network card.
# Adding a multicast static route for Twonkymedia Server up route add -net 18.104.22.168 netmask 240.0.0.0 dev eth0 down route del -net 22.214.171.124 netmask 240.0.0.0 dev eth0
Starting Twonkyserver at boot using upstart or Debian runlevels
We need to start twonkyserver on the default runlevels. I’m including two ways of doing this. One specifically for Ubuntu 10.04 onwards using upstart and another for a default Debian install.
Ubuntu 10.04 runlevels using Upstart
Stop tonkyserver running.
sudo /etc/init.d/twonkyserver stop
Delete the installed twonkyserver startup script.
sudo rm /etc/init.d/twonkyserver
Create an upstart startup file called twonkyserver.conf in directory /etc/init/
sudo nano /etc/init/twonkyserver.conf
Copy and paste the following code snippet.
# Mostly Raymond Day's work, thanks for the suggestion. # If your going to run Twonkyserver as a daemon, # append the -D to the command line at the bottom. # Not currently running as a daemon to support # transcoding. The default is with a -D so feel # free to add it if you don't intend to use # transcoding. description "TonkyMedia UPnP Server" start on (local-filesystems and net-device-up IFACE!=lo) stop on runlevel [!2345] exec /usr/local/twonkymedia/twonkymediaserver
Create a symbolic link in the init.d directory to start the upstart job on reboot.
sudo ln -s /lib/init/upstart-job /etc/init.d/twonkyserver
Now to Test.
Start twonkyserver from the command line.
sudo start twonkyserver
You should get a message similar to the following.
twonkyserver start/running, process 1258
If you need to stop twonkyserver, you type the following.
sudo stop twonkyserver
At this point, it may be worth rebooting your linux server to ensure that twonkyserver comes up correctly. After you’ve done so, you can check to make sure that twonkyserver is running by typing the following.
sudo status twonkyserver
If all is well, it should come back with the message
twonkyserver start/running, process 1699
All done, you of course will most likely have a different process id
Debian default runlevels
sudo update-rc.d twonkyserver defaults 99 20
Setting up Transcoding
Info: If you are running Ubuntu 10.04 or later, and have created an upstart script using the instructions above. In the instructions below, you will ask to restart twonkyserver a couple of time. To do this using the upstart script type.
sudo restart twonkyserver
This isn’t really needed if you only have mp3′s and a media player that supports mpeg4 (the new PS3 slim for example), if however, you have flac music files and mvk video files for instance, then you will need to transcode (change there format) on the fly.
The default install of twonkymedia only supports transcoding of the jpeg photo format by default (see screen shot below).
Enabling Video Transcoding
sudo apt-get install libavcodec-unstripped-52 \ libavdevice-unstripped-52 libavformat-unstripped-52 \ libavutil-unstripped-49 libpostproc-unstripped-51 \ libswscale-unstripped-0 ffmpeg
Note: Installing the unstripped libraries as in the above step insures that MKVs will transcode, otherwise the transcode will fail because mpeg2video will be missing. If while running that last command the install fails because of a missing package, do an apt-cache search libavcodec (replace libavcodec with whatever package it says is missing – this way you can see if perhaps you need *-unstripped-52 rather that 51, etc).
Open /usr/local/twonkymedia/cgi-bin/ffmpeg.location in your editor and replace c:/ffmpeg with /usr/bin
sudo nano /usr/local/twonkymedia/cgi-bin/ffmpeg.location
It is necessary to run the mediaserver in the foreground for transcoding to work properly. If you are using the supplied Twonky startup script, you need to remove the -D from the line around line 91 that reads “$TWONKYSRV -D”
Edit the startup script:
sudo nano /etc/init.d/twonkyserver
sudo /etc/init.d/twonkyserver restart
Now when you go to the transcoding page of your twonkyserver, you should see the following.
More on MKV Files
For MKVs to transcode, you need to place a .desc file in twonkymedia’s cgi-bin folder.
Create the file /usr/local/twonkymedia/cgi-bin/ffmpeg-mkv-mpeg.desc
sudo touch /usr/local/twonkymedia/cgi-bin/ffmpeg-mkv-mpeg.desc
Set the new file’s permissions to 644.
chmod 644 /usr/local/twonkymedia/cgi-bin/ffmpeg-mkv-mpeg.desc
Inside the file, paste the following:
exec: ffmpeg -threads 2 -i $infile -vcodec mpeg2video -sameq -acodec copy -f vob -copyts -y $outfile # capabilities from=video/x-matroska to=video/mpeg synchronous priority=idle
On the transcoding page in the web interface, make sure mpeg2 is checked.
Restart the twonkyserver
sudo /etc/init.d/twonkyserver restart