I have a QNAP NAS at home. I don’t really use it in my home lab for hosting VMs. I prefer to use EMC’s VSA for that. I do use it to store templates, ISO files and other software along with all of my digital media and documents etc.
One of the features that comes built in with most QNAP devices is a UPNP Media Server, which is actually a repackaged version of Twonky. When enabled it allows me to stream video content from the QNAP to my blu-ray player and watch it on a decent sized screen. It works well with DivX AVI files but it wasn’t happy with several other formats. I put it down to a lack of support from my blu-ray player but then I came up with a reason to dig deeper.
I received a video of a family event the other week and the file was in an MKV format (or container). Although it showed up when I pointed the blu-ray player at it, when I tried to play the file not a lot happened. At least not at first. After about 30 seconds a 2 second clip of the video played before pausing for another 30 seconds. This probably would have carried on the for the entire duration if I’d let it.
A few minutes later I became aware that the fan in the QNAP had started to run at its maximum speed. After a quick SSH connection was established I could see that the process “ffmpeg” was pegging the CPU of the NAS.
So, what was happening was that the Twonky Media server was trying to transcode on-the-fly into a format that it felt comfortable serving to my blu-ray player. The CPU in the NAS is just not up to that job!
That left me with two options. The first was to manually transcode the file on another computer into a format that would work. This would certainly do the job but would also mean a loss in quality and, in the event that I get lots more MKV files, be a pain to have to do over and over again.
The second option, the one I chose, the harder one, was to sort the problem out. This is what I did with my afternoon off on Tuesday!
First things first. Sony’s documentation for my blu-ray player (a BDP-S370).
There seems to be some fairly broad support for different video file formats. The important thing is that MKV is a container and not a codec. As long as the blu-ray player is capable of playing the contained video, it shouldn’t be too difficult working with the container format. However, DivXHD is apparently not supported using DLNA. I won’t let that stop me though. It plays normal DivX files perfectly well.
Next up, looking at the media server. There’s plenty of people who have bemoaned the lack of support for MKV files in Twonky it would seem. And while it’s easy enough to turn it off, I’d need to replace it with something.
I looked at MediaTomb and a couple of other efforts but there seemed to be a lot of compiling required for some of them and I didn’t want to clutter my NAS up with lots of compilers and libraries. It’s there to server files primarily, the rest is a bonus. It’s certainly not supposed to be a development platform.
Finally I discovered that a later version of Twonky (6.x) could be installed instead of the bundled version (5.x). Looking into this it was quite straight forward.
QNAPs have a plugin system called QPKG that allows some extra functionality to be added to the NAS. A selection of packages can be installed very simply using the web-based admin utility.
Simply navigate to “Application Servers > OPKG Plugins” in the QNAP admin GUI and click the “GET QPKG” button to be shown the list of available plugins.
After selecting, downloading and installing the correct package it can then simply be enabled. Doing so even automatically disables the built-in version of Twonky.
Sadly this didn’t fix things. You could even say that it made them worse. Before the MKV file had at least shown up, now it was nowhere to be seen by the blu-ray player.
A bit more googling found a solution for me though. It seems that if we change the MIME type of MKV files as far as Twonky is concerned, the blu-ray player will find the file and should be able to play it.
The first step in doing this is determining what user agent Twonky detects the blu-ray player as being. As you might have noticed, Twonky has a config GUI that runs on port 9000 by default. One of the views available shows connected Media Receivers.
Via an SSH connection to the NAS, the configuration for the profile can be changed. To do this you need to edit the file /share/MD0_DATA/.qpkg/TwonkyMedia/resources/clients.db with vi or your favourite text editor.
Searching through the file I found the profile that matched the name above:
>> NA:Sony Blu-Ray Player HH:Blu-ray Disc Player XM:DLNA15 TR:JPEGORG,JPEG160x160,JPEG640x480,JPEG1024x768,JPEG1920x1080 DB:AUTO
To change the MIME type of MKV files simply add the following line to the end:
You should now have something like this:
>> NA:Sony Blu-Ray Player HH:Blu-ray Disc Player XM:DLNA15 TR:JPEGORG,JPEG160x160,JPEG640x480,JPEG1024x768,JPEG1920x1080 DB:AUTO MT:mkv video/divx >>
Save the changed file and restart Twonky by issuing the command:
Just like that my blu-ray player could play MKV files. It’s not perfect. Playback is smooth but seeking (fast forward or reverse playback) doesn’t work very well. It’ll do for my purposes though.
Michael is a Senior Consultant for Xtravirt. If it's got buttons or flashy lights on it then it'll probably be on his radar. When not "mending computers" (it's sometimes easier than explaining "cloud" to relatives), Michael provides essential education, entertainment and trampoline services to his two children.