Linux

Using the Creative Zen X-Fi with Linux

This is a pretty technical post, so please, feel free to ignore it. I post this here mostly as a reminder to myself as to how to make the features work and also as a resource to anyone else who might be trying to same task.

Changelog

  • 27 April 2009: Added notes about Amarok2 and about using mtp-connect to send video and picture files to the device.

Introduction.

I recently purchased a Creative Zen X-Fi media player (32 GB) to replace my aging Zen Nomad Xtra which had begun rebooting itself at random. I chose this product for several reasons: first, it was a Creative player and I’ve always had good luck with Creative products and because my research indicated that it did a good job of talking to Linux. Second, while 32 GB may seem like a lot, I do like my music and my videos, so I wanted a lot of space. Third, the idea of having a wireless card in my media player appealed to me, just because it meant I could theoretically get it talking to the media collection on my own computer.

Since I had to search for hours to find out how to get it all working (my Google-fu is mighty), I figured other users might appreciate having all the steps in one place.

If you’re looking for notes on using your X-Fi with Amarok2, please see the end of this article.

Computer Setup.

I use Kubuntu 9.04 with KDE 4.2. These tips should work just fine with other distributions and desktop managers. For my media player I use Amarok 1.4 because I’m used to it, I like the interface, and because it integrates well with KDE. Your mileage may vary. I haven’t used other media players, so you’re on your own with those, though if you want to send me your tips on doing so, I’ll do my best to incorporate them.

Connecting the Creative Zen X-Fi to your computer.

First, the Creative Zen X-Fi media player uses Microsoft’s Media Transfer Protocol which is, at this point, pretty well supported in Linux. You will need to install the latest versions of the MTP software on your computer:

$ sudo apt-get install libmtp7 mtp-tools

You will also need the NJB tools:

$ sudo apt-get install libnjb5

Note: I’m not entirely positive that this is necessary. It was installed on my system because it was required for connecting to my Zen Nomad, and I haven’t tried connection to my Zen X-Fi without it. That will require someone with more spare time and patience than I have.

Also make sure you have the tools necessary to ensure your computer does USB. These tools are usually installed out of the box with Ubuntu systems, so I’m not going to detail them here.

Next, edit the file: /etc/udev/rules.d/45-libmtp7.rules. There are two sections in this file. In the first section, which has the label “LABEL=”libmtp_usb_rules”, add the following:

# Creative Zen X-fi
ATTR{idVendor}=="041e", ATTR{idProduct}=="4162", SYMLINK+="libmtp-%k", MODE="660", GROUP="audio"

In the second section, labeled LABEL=”lib_usb_device_rules”, add the following:

# Creative Zen X-fi
ATTRS{idVendor}=="041e", ATTR{idProduct}=="4162", SYMLINK+="libmtp-%k", MODE="660", GROUP="audio"

These two lines are nearly identical, except for the very first parameter. In the first, it’s ATTR, and in the second it’s ATTRS.

Next, edit the file: /etc/udev/rules.d/45-libnjb.rules and add the following:

# Creative Zen X-fi
SYSFS{idVendor}=="041e", SYSFS{idProduct}=="4162", GROUP="plugdev", MODE="0660"

You should reboot your system at this point to make sure these rules are applied.

At this point, your computer should be ready to talk to your Creative Zen X-Fi.

Transferring Music Files.

I use Amarok to transfer music file. To connect Amarok to your Creative Zen X-Fi, do the following:

1. Go to Settings -> Configure Amarok -> Media Devices

2. Select the “MTP Media Device” plugin.

3. Click the “Apply” or “Okay” button.

Then, in the tab bar on the left of Amarok, click Devices, and then Connect. Amarok should connect pretty easily. To transfer music files, right-click any files in your collection and select “Transfer to Media Device”. Then click back to the Devices tab, and then click “Transfer”.

Note that my installation of Amarok had already been configured to connect to media devices, and I had that set up for months. I recall that it was easy to do this but, again, your mileage my vary.

Transferring Video Files.

There are two ways of copying movie files from your computer to your device. One is good; the other runs the risk of corrupting your files, requiring a hard reset on your device; done enough times, you may end up finding that simply reformatting your device and replacing all your music files is a better option.

The first, superior method, is to use mtp-connect. This program is part of the mtp-tools suite. I have not found comprehensive documentation of mtp-tools (I’m considering writing up my own). This program does not have a functioning GUI that I’ve found, so you have to use the command line.

Assuming you’ve formatted your video per the instructions below, execute the following command to transfer your video:

$ mtp-connect –sendfile <filename.avi>

e.g.,

$ mtp-connect –sendfile bendersgame.avi

Because there are standards behind how MTP works, this command will place your video in the proper directory on your device, and you can find it easily when you browse to videos on your device.

The second method for transferring videos is more complicated, requires more steps, and runs risks of corrupting data. I’m including it here primarily because it’s how I first started doing this, and some people just like getting their hands dirty. This method essentially involves mounting your device like a filesystem and moving the files over with simple command line copy and move functions.

Warning: I’ve found that sometimes mounting my Creative Zen X-Fi in this manner will cause corruption of my music library files on the device, requiring a hard reset ((To perform a hard reset, switch the power slider to OFF while simultaneously pressing down on the Play button. Release the power switch and then release the Play button when the Reboot menu appears)), which will reset many of your settings.

To mount your device as a file system, execute the following command:

$ sudo mtpfs -o allow_other /media/MyZen/

I usually create a symlink in my home directory to lead up to this mountpoint, but that’s just my personal taste.

Next, maneuver into the Video directory within the /media/MyZen mountpoint:

$ cd /media/MyZen/Video

This is where your player’s video files are kept.

Ideally, you should be able to drag and drop video files to this directory within KDE itself, but I experienced errors when doing this, so I just use the cp command.

Converting Video Files

The Creative Zen X-Fi is so picky about what video formats it will support. The Windows software that ships with the device includes a utility for converting most video formats to something that the X-Fi will read, but we Linux users have to go a different route; you’ll have to convert the video format before you transfer it. For this, I use the mencoder command line software, which you will have to install:

$ sudo apt-get install mencoder

The command I found works the best for converting videos to something the Creative Zen X-Fi will play is this (assuming your video file is an .avi file):

$ mencoder input.avi -o output.avi -vf scale=320:240 -oac mp3lame -ovc xvid -xvidencopts bitrate=800

where input.avi is the input file to convert and output.avi is the name of the converted file.

Note: I have found that mencoder just a much better job of encoding the video files for playing on the Creative Zen X-Fi than ffmpeg. And yes, I know that mencoder is simply a wrapper for ffmpeg.

This command assumes that the aspect ratio of your video is 4:3. If you have a different aspect ratio, such as 16:9 (the format of most widescreen videos) you will need to know the horizontal and vertical resolution of the input video. For one recent conversion I did, I found that the input video’s horizontal resolution was 720 pixels, while the vertical resolution was 416. I converted this to 320×196 ((To make this conversion, divide 320 by the original video’s horizontal resolution to get a percentage value; then multiply that by the vertical resolution.)), then used the following switch to the command to ensure that letterbox format would be properly applied:

-vf-add expand=:240

to bring the video’s resolution up to 320×240. Remember that the Creative Zen X-Fi is horrendously picky about what video formats and resolutions it will play, so this step is necessary.

Copy the video file to /media/MyZen/Video using cp.

Once the video is copied, unmount the device:

$ sudo umount /media/MyZen

If you get an error saying “Device is Busy”, wait a few moments and try again. This usually indicates that the file is still being copied over, even though the cp command may have already exited in your terminal. (Note that you will also get this error if you are still in the /media/MyZen directory or any of its subdirectories; that’s caught me a few times.)

You should be able to play the video just fine at this point.

UPDATE December 12, 2008: Jochen Hörmann, below, also recommends using Gnomad2 to transfer video and music files. Gnomad2 is easily installed:

$ sudo apt-get install gnomad2

As I mentioned, I prefer to use Amarok to transfer music files because I have more control over creating playlists that way. However, Gnomad2 seems to transfer videos much faster and with fewer issues with file corruption than mounting the device and transferring the files manually. Thanks, Jochen, for the tip.

Transferring Picture Files.

This is pretty straightforward, since the Creative Zen X-Fi can display most picture formats (JPEG, BMP, GIF, PNG and TIFF). Just as with video files, you can transfer photographs and images using mtp-connect:

$ mtp-connect –sendfile <picture>

e.g.,

$ mtp-connect –sendfile bendersshinymetalass.jpg

You can also mount the device as per the mtpfs command above, and copy the picture files to /media/MyZen/Picture. There are subdirectories in that directory, but I haven’t bothered dealing with those. Again, I was unable to transfer the picture files using KDE, so I used the copy command. I don’t recommend this method.

I have been unable so far to get the slideshow feature to work, because the slideshows have to be set up in the device’s desktop software which, as has been noted, is only available for Windows.

Using the Creative Zen X-Fi’s Wireless Features.

The Creative Zen X-Fi includes a wireless card, which is pretty spiffy. While it also includes a number of online features (such as chatting with other users and with various IM protocols), I haven’t bothered with these, because in my experience I’ve never found a compelling use for them. Your mileage may vary, as always, though I suspect that the tedious method of entering text into the X-Fi would make the feature pretty useless anyway.

However, if you have a wireless connection at home, you can set up your computer as a media player so that you can play music or videos from your computer even if you don’t have the music on your player. You have to install media server software on your computer to enable this feature. I chose to use MediaTomb, which is available in Ubuntu’s software repositories and can thus be easily installed:

$ sudo apt-get install mediatomb

When you launch MediaTomb through System -> Multimedia -> MediaTomb, it will open a browser window, since MediaTomb’s interface is browser-based. The interface is, I think, pretty self-explanatory. Note that MediaTomb can also enable your computer to talk to any other media player you may have in your home, such as… Well, I think the X-Box 360 and some others, though I don’t own any of these so I don’t know if any special configuration is needed. I suspect not.

The instruction manual which comes included with your Creative Zen X-Fi will explain how to connect your device to your wireless network and to the media server itself, so I won’t elaborate here.

Conclusion.

The Creative Zen X-Fi is a great media player which, despite its claims to only work with Windows, works just dandy with Linux as well with just a few minor hacks. I hope this guide has been useful. Please feel free to contact me with any comments or questions; I will do my best to respond.

Note on Amarok2:

I recently upgraded my computer to Kubuntu 9.04, Jaunty Jackalope. I’m pretty disappointed with KDE 4.2, and I was very disappointed with Amarok2. When you connect your X-Fi to your computer, it docks immediately to Amarok2 if it is running, which I don’t like. Your X-Fi’s music will show up as an additional collection along with your regular collection in the left panel. You move tracks around by right-clicking on the track, and then clicking “Copy to collection…” and selecting your media device.

A very serious flaw with Amarok2, in my opinion, is its complete inability to import playlists from Amarok 1.4. I have encountered a few suggestion solutions to this problem, and none of them have worked. If you find one, let me know. Because I have a number of playlists which I’ve created over the years, this shortcoming was a dealbreaker for me, and I began to hunt for a way to replace my Amarok2 installation with the more stable and better looking Amarok 1.4. I found instructions to install Amarok 1.4 on Jaunty Jackalope here. Before you install 1.4, you have to make sure you have uninstalled 2. And I ended up installing from the command line, since Adept didn’t see the Amarok 1.4 files.