'[FAQ] Twonky DLNA Media Server Setup & Use

Optimising Operation of the Media Server

Q. How does the Twonky service work on the MyCloud?
A: [Twonky is installed as a Linux service. Like other such services, there is a service control file in the /etc/init.d directory]:

/etc/init.d/twonky

This is called when the twonky service is invoked, and there are a number of options for the control of Twonky using an SSH root login:

service twonky start service twonky stop service twonky restart service twonky status

If you execute the start or stop commands with Media Streaming turned on in the Dashboard, you are likely to confuse the Dashboard; you may get an Error 400162.

start’ calls writeTwonkyContentDir.sh, which, as we’ll see later (Q: How do I stop MyCloud breaking the Twonky Server?), reads the /etc/contentdir file and modifies the twonkyserver.ini file to set the media search paths and types, and then starts the Twonky server.

[It is assumed that the MyCloud Dashboard uses these Twonky service calls to start and stop the Twonky server].

Q. Where is the Twonky database stored?
A: Since Twonky is a service running on MyCloud, it is not visible in the shared space, so you have to log in via SSH, and navigate around the MyCloud’s Linux file system.
Once you have logged in, use the cd command to change directory to Twonky’s area:

cd /CacheVolume/twonkymedia

Now see what’s there with a directory list:

ls -l

Q. Where are the Twonky settings stored?
A: One of the files listed above is the Twonky configuration file:

twonkyserver.ini

This file contains all the settings that control how Twonky works.
Now, this is where some of the fighting occurs, because both MyCloud and Twonky can modify this file…
When you are happy that Twonky is working correctly, I’d recommend making a copy of the file in your Public area, where it won’t be mangled by MyCloud firmware upgrades or restarts. For instance:

cp /CacheVolume/twonkymedia/twonkyserver.ini /shares/Public/twonkyserver.ini

If things go wrong, you can reinstate this file by swapping the source and destination.

Q. What do all the settings in Twonky’s configuration file do?
A: [Most of them are provided with comments that explain their purpose].
[There are some ‘magic numbers’ embedded in the configuration file that seem to cause problems, and I don’t know what changes those; I suspect that a firmware upgrade does it. If anyone can monitor these values before and after a MyCloud firmware upgrade and report any changes, I’d be obliged:

# UserID Please Do NOT change it manually
userid=<redacted>
# twonky info for Media Feeds Please Do NOT change it manually
twonkyinfo=<redacted>]

Q. How do I clear Twonky’s database and start again?
A: If Twonky doesn’t seem to be behaving correctly (not finding media correctly, or partially, or finding unwanted media), then it may be useful to clean up the database.

There are a number of escalating actions you can take. Starting with the mildest, and increasing in severity, these are as follows:

1. Initiate a library rescan, using either:
Settings|Media|DLNA Database|Rescan in the Dashboard, or
Settings|Advanced|Server Maintenance|Rescan Content Folders in the Twonky UI.

2. Initiate a library rebuild, using either:
Settings|Media|DLNA Database|Rebuild in the Dashboard, or
Settings|Advanced|Server Maintenance|Restart Server in the Twonky UI.

3. Finally, you can completely clear out Twonky’s working area. [This can be useful if you notice the [Error] - LOG_SYSTEM: Error: 2 No such file or directory report in the Twonky logfile. I don’t know what causes this error, or whether it has serious consquences, but I have found it to be associated with periods of diffcult behaviour.]

Turn Twonky off using the Settings|Media|DLNA Media Server|Media Streaming control in the Dashboard. Then SSH root login, and hide the entire Twonky working area:

cd /CacheVolume
mv twonkymedia twonkymedia_bak

Restart the Twonky Server using the Dashboard; it will re-create Twonky’s working area with a clean version with default settings. You can then use the Twonky UI to put your settings back in place. You might try doing this one-by-one, saving the settings and restarting the Twonky server from the Twonky UI each time, then checking the logfile after the Twonky UI has re-appeared.

Once you’re happy with the operation of the clean startup, you can delete the old Twonky working area:

rm -f -R /CacheVolume/twonkymedia_bak

The -f -R flags mean ‘delete EVERYTHING from here down… yes, I mean it’. nb. it will only delete the Twonky database; it won’t delete any of your media. But do be careful that you type the command in correctly; rm -f -R is a powerful command (-f means force, -R means recursive), and could do a lot of damage if you get it wrong…

Q. Where can I find debug log files for Twonky?
A: You can enable activity logging using the Settings|Advanced|Logging control in the Twonky UI. You can also open the logfile from there.
Alternatively, the logfile is stored in Twonky’s area:
/CacheVolume/twonkymedia/twonkymedia-log.txt

There’s also a MyCloud system logfile that records actions on the Twonky server, such as start and stop:
/CacheVolume/update.log

Q. How do I stop MyCloud breaking the Twonky Server?
A: Firstly, go to the Settings|Firmware page in the Dashboard, and disable Auto Update: firmware upgrades completely destroy the /CacheVolume/twonkymedia area, and replace it with new, default version, so you’ll be back to square one.

Secondly, don’t use the Dashboard to change the Media Serving settings on any Shares; if you do this, it will overwrite any changes you make via the Twonky UI, setting any enabled shares back to ‘All Content Types’.

Thirdly, we can stop the problem of Media Streaming restarts overwriting the Twonky UI settings. Using an SSH root login, enter the following commands:

cd /usr/local/sbin
mv writeTwonkyContentDir.sh writeTwonkyContentDir.sh.old

This disables the script that MyCloud calls when it starts Twonky, which overwrites your settings.

Another way of fixing the settings is to leave this script alone, but change the file it uses as the source of the settings. Admittedly, this will still override any changes made via the Twonky UI. The file is found here:

/etc/contentdir

Replace this with a single control line, with no line terminator, e.g.

+M|/Media/Music,+P|/Media/Pictures,+V|/Media/Videos

This will select my earlier settings.

The format is a comma-separated list of shares and media search and aggregation control flags:

+ enable media searching on the share
- disable media searching on the share
A look for all media types
M look for music
P look for pictures
V look for videos

lower case letters enable aggregation of these media types.
The | terminates the media type string [you can search for multiple types in a share].

It is possible to modify the MyCloud’s user startup script to perform a number of useful tasks every time it reboots, such as stopping the indexing and thumbnailing services, and restoring the /etc/contentdir and twonkyserver.ini files from a location in User space. Here’s an example of the /CacheVolume/user-start file:

Finally, NEVER USE THE ‘SHARE FILE’ FUNCTION. It will destroy the settings, reverting back to ‘All Content Types’ in the root of any share that has media sharing enabled. For absolutely no good reason, since remote file sharing and local media server are completely unrelated functions; the media server cannot be accessed outside the network. Sadly, once again, WD deny all responsibility for destroying your carefully-honed media server settings, with the pathetic excuse “Twonky may be part of our product, but it is a 3rd party software. We don’t provide support for third party products or software.”

Q: How can I change the location of the ‘Shared Media’ folders?
A: This brings us deep into the guts of the twonkyserver.ini file… There are a number of settings that control where Twonky stores uploaded files and ‘servermanaged’ media, [which are used for aggregation], and there is no control setting for them in the Twonky UI. To change the location of the folders we have to do an SSH root login and edit the twonkyserver.ini file. The lines in question are as follows:

uploadmusicdir=/shares/Public/Shared Music
uploadpicturedir=/shares/Public/Shared Pictures
uploadvideodir=/shares/Public/Shared Videos
servermanagedmusicdir=/shares/Public/Shared Music
servermanagedpicturedir=/shares/Public/Shared Pictures
servermanagedvideodir=/shares/Public/Shared Videos

You can change these locations to suit your desired file system. For instance, you could create a single ‘Shared’ folder in the your media share, with sub folders for the different media types, e.g. I use:

uploadmusicdir=/shares/Media/Shared/Music etc.

Or you could create a Shared sub folder within each of your main media folders, e.g.

uploadmusicdir=/shares/Media/Music/Shared

However, if you choose that option, you will need to stop Twonky searching there, by adding Shared to the list of ignored directories discussed above.

Q. Why does setting a Twonky access control password prevent the MyCloud from sleeping?
A: It has been reported that if a username and password are set using the Settings|Advanced|Secured Server Settings control in the Twonky UI, that the MyCloud then never sleeps. [It appears that the MyCloud continues to interrogate the drive in some way, hoping to get status of the Media Server from Twonky, but Twonky won’t talk to it because it doesn’t have the required permission.].

I don’t think this is very important, since the MyCloud is mainly intended for home use, and the Twonky control UI isn’t visible external to your local network, and all users on your local network must be trusted*, since you’ve given them the network access code, [and they have access to the Public area, and could wreak havoc there…]

If you need to make your music library available to visitors who cannot be trusted, create a private share and put all your media under that, then enable media serving on that share, and get Twonky to search for media in that private share. DLNA ignores access control, so DLNA clients will be able to see the media on your private share, but visitors will not have access to your private share via network file access.

[However, if you feel that secured access to the Twonky UI is necessary, then I would suggest that you disable the Twonky server using the Settings|Media|Media Streaming control, then SSH login as root, and start Twonky using the command:

service twonky start

You won’t get the media scan status in the Dashboard, but the Twonky Server and UI will be running.]

* Breaches of this trust should be punished in an appropriate manner…

Q. Can I replace Twonky with another Media Server?
A: Yes; forum users hvalentim and Nazar78 have posted good threads about this:

MiniDLNA for V3 firmware

MiniDLNA for V4 firmware

Kudos to them :slight_smile:

It may also be possible to upgrade to the latest version of Twonky, by downloading the appropriate WDMyCloud zip file from

http://www.twonkyforum.com/downloads/

I haven’t tried this, and can’t give advice on how to install the newer version. You’re welcome to try it, and report back here… This thread might give some clues:

Note that you’ll have to buy a licence to allow this to run after a 30-day trial period. It’s currently about €15.

4 Likes

Optimising Behaviour for Media Clients

Q. Why does my media player not show the right track information?
A: A media server looks at the metadata stored in the file, as well as the path and filename. There can be all sorts of metadata tags within a file (Artist, Album Artist, Album, Track Title, Publish Date, Composer, etc, etc), and a media server will fetch these and provide some or all of them to media client applications.

If a file does not contain metadata, a media server cannot provide it to clients, and the only way clients can then select media is using the ‘By Folder’ view. If you have ripped CDs without manually entering metadata, or downloading metadata (e.g. from freedb.org), or using a media library tool to infer metadata from the filename, your files will not contain metadata.

Correct metadata is the bane of a digital music collector’s life. Metadata downloaded from sites like freedb.org is frequently in error, or in a format that you don’t like (if you you have obsessive-compulsive tendencies). However, it is essential if you want to use a media server. In which case, if metadata is missing from your media files, you’ll need to add it with a media library tool (such as WinAmp, MediaMonkey, or even Windows MediaPlayer), or a dedicated metadata tagger such as MP3Tag.

Twonky offers a number of different options for the metadata that is offered to clients. This is controlled using the Settings|Sharing|Media Receivers control in the Twonky UI; use the ‘Navigation Type’ column drop-down menu to select what is offered to each device that is connected to Twonky.

Media clients also have different ways of sorting file lists; some allow the sort order to be controlled, and some use different sort orders with different metadata views, as discussed here:

http://community.wd.com/t5/WD-My-Cloud/Twonky-sorts-tracks-by-track-name-tag-not-filename-or-track/m-p/843098

Q: Why does my media player not see certain types of media?
A: When your media player first connects to the Twonky server, it should tell Twonky what it is, and what media it will support, using a ‘profile’. Twonky will only reveal media in its database that the media client says it is able to handle.
Sometimes, the media client will present an incorrect profile. The profile that Twonky has found for a client can be found in the Settings|Sharing|Media Receivers settings. You can select a different profile if the one automatically selected is not correct, or is unsuitable. See the next Q for discussion on how to edit or create profiles.

Q. How can I get Twonky to provide full size artwork to media-playing clients?
A: The resolution of album artwork presented to clients depends on the client type. This can be set using the Settings|Sharing|Media Receivers control in the Twonky UI. Find your client in the list, and use the ‘Media Receiver Type’ drop-down menu to select an appropriate type.

There’s a useful thread on this issue on the Twonky user forum:

http://twonkyforum.com/viewtopic.php?f=2&t=11743

The profiles of the clients are held as xml files, and can be found here:

/usr/local/twonkymedia-7/resources/devicedb

[If you create new profiles, or edit existing ones, it’s probably a good idea to store them somewhere safe, as I suspect they’ll get overwritten by a firmware upgrade.]

Music artwork appears to need to be called ‘folder.jpg’ to be found by Twonky [actually, I’ve recently found it picking up other artwork; it might be simple alphabetical selection]. Video artwork must have exactly the same filename as the video file, apart from the extension.

Q. How can I change the media ‘views’ I see in my DLNA client?
A. Twonky uses some XML files to define the the behaviour of each view, and which views are presented for each ‘navigation type’. These XML files are found here:

/usr/local/twonkymedia-7/resources/views

The file that defines the behaviour of the views is view-definitions.xml. This creates structured views, using database properties that can be found in this document:

www.mikrocontroller.net/attachment/134243/TMS-5-1-View_Configuration.doc

These view definitions can be edited, or copied to create new views to suit your needs. It looks a bit hairy if you’re not familiar with XML, but it’s nicely structured with indentation that should help you copy the stuff you need.

Each ‘navigation type’ has an associated file that defines which views are presented. For the ‘Advanced Navigation’, this is advanced.view.xml. This is simpler than the view definition file, since it is essentially just a list of the defined views.

My initial experiments are discussed here:

http://community.wd.com/t5/WD-My-Cloud/DLNA-not-serving-up-correctly/td-p/879866

It may also be possible to get more recent device definitions from the more recent releases of Twonky at the twonkyforum downloads area:

http://www.twonkyforum.com/downloads/

You would download the latest zip file, and then extract the device definitions from resources/devicedb/ and copy them into the matching folder on the MyCloud.

Note that I haven’t tried doing this. I’d recommend backing up the devices folder before you try it.

Q. Can I add my own category to the Music/Photos/Videos categories?
A. There’s a useful-looking discussion thread by Phibertron on the twonkyforum:

http://www.twonkyforum.com/viewtopic.php?f=2&t=10627

I haven’t tried this, but it looks very promising. It uses modification of the view definition files discussed above.

1 Like

[edit: a word of caution is needed here, as I note that people are reading this FAQ as ‘gospel’: it certainly isn’t; it’s just a collection of my findings, and I may be wrong (as I made clear in my original post). I find that putting my media into Twonky’s ‘Shared Media’ folders causes me trouble. BUT, given that there must be tens or hundreds of thousands of MyCloud users, and we’re not seeing them all here, cursing Twonky, I suspect that most people have no problem following WD’s advice to use these folders. I’m sure my advice will not cause you problems, but, equally, WD’s advice may not cause you problems. It’s just one thing to try if you do have trouble.  If you have no trouble with the ‘Shared Media’ folders, or if you do, please share your experience, and we might be able to get to the bottom of the problem.]

[The purpose of the ‘Shared Media’ folders has finally dawned on me.  They’re not meant to be folders that Twonky creates for you to put your media in; they’re folders Twonky creates to store media it has copied from other media libraries it finds on the network, as part of its ‘aggregation’ function.]

[Of course, since Twonky starts up by default when you first turn on your MyCloud, it has already created these folders by the time you first see the Public share folder, and, with no explanation to the contrary, it seems that is where you’re supposed to put your media*.  YOU ARE NOT…  Don’t put anything in the ‘Shared Media’ folders; leave them for Twonky to use.]

I’ve added an FAQ on how to move these aggregation folders somewhere more tidy.

* Oh, and the reason why it seems that you should put your media in the ‘Shared Media’ folders?

Because those are the names that Windows uses for its public access ‘All Users\Documents’ media folders…  And the User Manual repeatedly says this is where you should store your media.  All I know is that if I do put my media in the ‘Shared Media’ folders, Twonky doesn’t behave properly.

3 Likes

Hello,

Thank you for taking the time to post this.

4 Likes

I tried to get to the bottom of two Twonky mysteries; the 'magic numbers in the twonkyserver.ini file, and the ‘[Error] - LOG_SYSTEM: Error: 2 No such file or directory’ report in the log file.

Here’s the log of my investigation process, starting from a Twonky system that seems to be working, but reports the Error 2.

# turn off media streaming via Dashboard
# SSH in
# take a backup of the current configuration file
cd /CacheVolume
cp twonkymedia/twonkyserver.ini /shares/Public/twonkyserver.bak

# hide the existing Twonky working area
mv twonkymedia twonkymedia_bak

# restart media streaming via Dashboard
# take a copy of the 'clean' configuration file
cp twonkymedia/twonkyserver.ini /shares/Public/twonkyserver.clean

# compare the userid and twonkyinfo magic numbers in the configuration file
#	they're identical

# check the log file twonkymedia-log.txt
#	media shares are as per /etc/contentdir
#	but aggregation folders are back to 'Shared Media'
#	and, of course, friendlyname, ignore directories, compilation folders & rescan interval are now default
#	no Error 2

# so, what causes Error 2?

# Using Twonky UI
#	change friendly name & restart server
# no Error 2
#	change rescan interval to 1440 & restart server
# no Error 2
#	change compilation folder
# no Error 2
#	change ignore directories
# Using SSH
#	edit twonkyserver.ini to change aggregation folders to 'Shared/Media' & restart server (Twonky UI)
# no Error 2
#	edit twonkyserver.ini to set ignore_embedded_thumbnails=1 & restart server (Twonky UI)
# no Error 2

# take a copy of the modified 'clean' configuration file
cp twonkyserver.ini /shares/Public/twonkyserver.clean2

# use WinDiff to compare twonkyserver.bak and new twonkyserver.clean2
#	only differences are:
# logging verbosity setting v=4095 vs v=0
# ignore directory list (order only; I'd changed it)

So, I’m no nearer to understanding what the magic numbers are, or what changes them, and no nearer understanding what causes the ‘Error 2’ message.  I just don’t get that message any more.

Which has to be good, right…?

Oh, and, with the new configuration, twonky found the same number of media files, and took the same time to do it…

1 Like

Famous last words: the Error 2 is back. Maybe I just didn’t see it in the twonkymedia-log.txt file because I hadn’t enabled logging in the Twonky UI.

Oh well, Twonky is still working, despite the ‘Error 2’

I’m not alone, and neither is the MyCloud. Seems many people get this error:

https://www.google.co.uk/search?q=twonky+%22error+2%22

1 Like

I had a funny last night; my router lost internet connection for some reason, and I had to restart it.  Coincidentally, the loss of connection occurred whilst trying to edit a post on this forum…  Hmmmm…

Now, when a router loses connection, the MyCloud does a reset.  I’m not really sure why it feels it needs to do this, but it does.  Twonky appeared to come back up correctly; all the media counts were correct, and it took about the right time to do the scan.

But, browsing the Twonky library this evening, having updated the BubbleUPnP DLNA/UPnP client, I noticed that the Twonky media server had lost the first level of hierarchy; no Music/Pictures/Video folders appeared, just the music metadata views. Thinking it might be a Bubble funny, I checked on another tablet that I hadn’t updated, and that showed the same, as did Kinsky.  So the media type view had indeed vanished.

I used the Twonky UI to perform a Server Restart, and everything is now back to normal.  The restart and media scan took less than 15 minutes for 65k music tracks & 5500 pictures.  Good that the fix was simple, but bad that the thing didn’t startup correctly in the first place, and bad that MyCloud restarts whenever it loses connection to the router, for any reason.

Famous last words…

This morning, the video and photo folders have disappeared again.

*sigh*

[edit]

Think I’ve figured it out; it’s not an indexing problem, it’s to do with the media receiver type I set to enable high resolution artwork.  Setting it to be a Naim streamer seems to tell Twonky to only present audio, which is pretty fair if the media renderer can only handle audio.  Setting it to a generic media receiver presents all three types of media. i.e. I’d set the wrong Receiver Type profile, so it didn’t show me photos or videos.

If you think the integration of Twonky in MyCloud should be improved, vote for this idea:

http://community.wd.com/t5/Personal-Cloud-Ideas/Integrate-Twonky-properly-into-My-Cloud/idi-p/866577

2 Likes

So, 5000+ views later, and no-one has any comments or observations?

I’m sure there must be errors or misunderstandings in what I’ve said…

Hi, I got a question, does this work on different drives? I do not have a My Cloud, but I have an EX 2 and I would like to try some of this, but I’m not sure that the folder architecture are the same on both drive (while viewing through SSH).

Sorry, I don’t have an EX2, so I don’t even know if it has Twonky…

My limited understanding is that the EX family is an entirely separate family.

[edit]
It appears that the EX2 does have Twonky, and these instructions may be applicable:

Is there a way to add “media types” to the preconfigured ones (music, pictures, videos)? I’d like to separate tv recordings from private videos and change the configuration of the twonky media server who aggregats them in one category.

No, I don’t think you can add categories to those that are predefined (music, pictures & videos).

So I would suggest using metadata tags or folder structure to split your video library. Twonky provides the following metadata views for its video library:

Album

All videos (alphabetically grouped)

By date

By folder

Playlists

Title

The Album and By Folder views look most useful for you.

[edit: I have found a method, and added a new FAQ on this problem.]

Great work! Very helpful guide. I wish i had read it before I started using Twonky so i could have avoided learning much of it via trial and error. 

I have a MyBookLiveDuo onto which I installed Twonky. I’ve been updating it to the latest version now for a few years. 8.02 is fantastic. 

Wow man, thats one **bleep** of a post. 

I prefer to do it the easy way though.  You have 2 mac addresses for the WD MyCloud.  1 under the device itself and another for the other devices where the twonky server sits as an unknown device on windows 8.1.  Block the unknown device mac through the modem/router and when you double click on your WDMyCloud via windows explorer to access network shares, it will log you into the twonky GUI with a nice user friendly interface.

The ‘nice, friendly GUI interface’ can be accessed via port 9000 of your MyCloud’s IP, and yes, I discuss that, and assume that will be used for many settings. But that friendly GUI won’t let you control Twonky to do many of the thing I discuss, or stop the MyCloud breaking the setup…

Hope you find the FAQ useful.

Hi cpt_paranoi

Many thanks for going to the trouble of posting this, it very informative, well presented, and a massive help for new guys like me.

I have just purchased a WD EX2 NAS, and following initial setup a couple of weeks ago, it suddenly lost its Twonky setting, ie I couldnt access using port :9000, meaning I couldnt access my films on my smart TV etc.

I am pretty new to the world of Twonky and this was exactly what I was looking for - I now have a fully functional twonky service - if I’m allowed to say that - many thanks :slight_smile:

Hey guys,

great thread - lots of information.

1 thing I could not solve by now. My twonky is showing all music album covers under Photos - this makes no sense for me. I want my personal pictures under Photos - nothing else.

Is there a way to exclude certain folders from the scan for Photos?

The same problem could come up when I copy Audiobooks on the WD MyCloud - they should not be displayed under Music.

I created shares for

MusicLib

PictureLib

VideoLib

maybe I will ad AudiobookLib later.

Thank you.

Chris

When you use the Twonky UI to tell it where to look for media (in the ‘Sharing’ page), use the ‘media type’ selector to tell it what types of media to look for in each share.

See Q . Where should I put my media so Twonky finds it?

Then you will need to make the changes to stop MyCloud breaking your Twonky settings each time it reboots.