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.
Let me know how you find the X-Fi. I’m currently using a 2GB Zen Vplus, but got an email with the X-Fis and was very intrigued. First player I’ve looked at in a while where I’ve thought “You know, if I got this instead of an iPod for my next player, I don’t think I’d mind.”
I really like it. I’ve encountered a few glitches which I am pretty sure are due more to the fact that I’m hooking it up to Linux rather than to Windows, but on the whole I am very pleased with its ease of use and performance. The sound quality is excellent and the battery life is great; last night I had it playing all night and this morning it was still 3/4 charged.
The only thing I wish it had was a back light for the navigation buttons. That would make it much easier to use, especially at night.
Thanks a lot ! This is exactly what I needed because all others solutions with Gnomad are uneasy.
Great! I’m glad this was useful to you.
cool
i’m also thinkng about getting one of these 🙂
Wow! thanks a lot for this, was getting frustrated trying to use my new x-fi in ubuntu! you rock!
You’re very welcome. I’m glad this proved useful to you. 🙂
Hi.
Seemed to start working: Detected my player, but refuses to transfer any of the music files. Any ideas?
Cheers. Ray
Ray,
I’m not an expert by any means, so take my thoughts with a grain of salt.
Are you receiving any specific error messages when you try to transfer files? Are you using Amarok to transfer the files, or are you trying to drag-and-drop within KDE (a process I have not had any luck with myself).
From the command line you might try:
$ mtp-detect
Just to make sure your system can see the device properly. If you get “segmentation fault” then something’s gone wrong; if you get a bunch of XML scrolling past the screen then it’s connected right.
Hey!
Thanks for this good advice!I only had to add the lines in the files you mentioned.
I use gnomad2 for music and video transferring.
With gnomad you can easily add videos to your zen xfi, faster/better than mounting the device.
Just install gnomad2 and try it:
$ apt-get install gnomad2
Greets,
Jochen
sry: $ sudo apt-get install gnomad2
Hi Jochen.
Yep, I’ve used Gnomad2. The issue I have with using Gnomad2, though, is that I had to run it with sudo to make it work. Also, on an aesthetic level, I just prefer using KDE applications wherever possible.
However, thanks for the tip regarding using Gnomad2 to transfer videos. If it works better than mounting the device and doesn’t result in any file corruption, then I’ll definitely use it for that. I’ll also incorporate this into my write-up.
Thanks Richard.
I did persevere and it was a matter of resetting the device (twice) and then it connected. I also booted into my dusty Windoze environment and did a firmware upgrade. So, as of now, this is working well with Amarok and I even get some luck with Gnomad2, although I often have to reset it after disconnecting, but it works.
Cheers. Ray
Hello,
Thank you very much for this “Howto”, it’s been so helpful.
To get mtp to work one wants to make sure it has read/write
access to the USB devices (/dev/usbdev*) otherwise only root user might
be able to connect to the device.
I confirm njb seems not necessary to connect the Zen X-FI with amarok
(it’s installed on my system but I didn’t tune it for the X-FI).
I confirm the Zen X-FI is very picky about video/audio format,after multiple “video format is not supported” messages, I also got “audio format is not supported” so I had to scale down the sampling rate of the audio stream while converting the video by using mencoder (added the option -srate 44100)
Video files can be transferred by using the mtp command line utilities: mtp-folders (to get folders IDs) , mtp-newfolder (to create any folder) and mtp-sendfile (to write the file in a given folder). Actually one might wait
a few bugs are fixed in these commands (as of release 0.3.5) but otherwise they work great.
Is there anybody able to get some album arts displayed by the Zen X-FI ?
Cheers,
Christian.
@Christian
Re: album covers. See Jouke’s suggestion below. The album cover usually transfers automatically when you use Amarok, as long as the album cover exists in your collection.
I have found that your suggestions regarding mtp-tools to transfer files to my device have worked out really well, and I intend to incorporate them into this write up soon. Right now I’m not sure I have the right version of mtplib compiled into my system, so I need to test that first. But thanks very much for the tip!
@ Christian Well, I get the album art automatically when using Amarok to transfer the files (I do transfer a whole album at once so maybe if you transfer each song apart it doesn’t).
@ Richard, thank you so much for this howto!
Jouke,
I’m glad you found this guide useful. Christian’s suggestions regarding the use of mtp-sendfile etc. have proven to work out pretty well for me, and I plan on incorporating them into this write up soon.
like everyone who has read the article great informative and detailed well
Hi! Thanks so much for all the information. I’m looking for a new music player that will work in Linux and this sounds very promising. Thanks for your time in doing it.
Quick question…any idea if you can use a music subscription (such as the Rhapsody to Go) that this player supports while using Linux? I have no frame of reference for how the music is transferred on Rhapsody so I wasn’t sure if it’s Linux compatible.
thanks ! exactly what I was looking for… for those who might wonder, that works perfectly for a Creative Zen too.
Thanks again !
Hello there,
First of all, thanks for the instructions!
I’ve been trying to get this to work for almost a year now, without any success. I still have issues with Amarok – maybe it’s because I’m running Ubuntu? Trying to connect to my Zen causes Amarok to crash. mtpfs hasn’t been very helpful either; my Zen locks up!
I also noticed that in /etc/udev/rules.d/45-libmtp7.rules, the libmtp_usb_device_rules section has “ATTRS” instead of “ATTR”. Would that matter?
I’m going to try and use Gnomad and see if I have any luck.
I’ve actually found that I have more luck using the latest version of libmtp (which you can find here) rather than the version that ships with Ubuntu. Unfortunately when I tried to remove the version that came with Ubuntu, it removes Amarok and just about every other piece of multimedia software on my computer. But fortunately, both versions seem to be living happily side by side and Amarok is more stable.
Good luck!
Oh, I know what you mean! I tried that too a while back and removing libmtp7 removed every single media player on the system! So I now have a libmtp8 in /usr/local/lib. How do I tell mtp-tools and amarok to use this one instead? Should I symlink libmtp.so.7 to libmtp.so.8 in /usr/local/lib?
Well, the system now detects libmtp7 (0.3.6) – I just had to symlink the version in /usr/local/lib into /usr/lib (leaving libmtp7 intact). However, Amarok still crashes. mtp-detect is not as slow as it used to be before, but towards the end it still locks up my player. I thought it might be the firmware version, but I checked it out and I am running the latest firmware for the X-Fi. I guess I’ll try using mtpfs. Thanks for your help!
Vivin,
You are right regarding the ATTR vs. ATTRS in /etc/udev/rules.d/45-libmtp7.rules. I’ve updated this how-to to reflect that.
Hey, I was wondering…when I go to put in:
# Creative Zen X-fi
SYSFS{idVendor}==”041e”, SYSFS{idProduct}==”4162″, GROUP=”plugdev”, MODE=”0660″
Do I put it in all of the categories?
This question also applies to:
LABEL=â€libmtp_usb_rulesâ€
I’m not to sure where I put these. If you could tell me, that would really help.
Kyle,
Sorry it took me so long to reply to you. I didn’t see any notification about your comment; something weird is going on in WordPress.
When you edit /etc/udev/rules.d/45-libnjb.rules, you only need to put that one line, the line that starts with SYSFS, into the file. I added the file to the very top. That is the only modification you need to make to that file. This file is not sectioned out into labels or sections the way that /etc/udev/rules.d/45-limmtp7.rules is. See my notes above for which line goes in which section.
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.
The 2nd line to copy to /etc/udev/rules.d/45-libmtp7.rules is false, i think the 2nd ATTR should be an ATTRS, shouldn’t it? My X-FI is only detected as a UNKNOWN device by mtp-detect and i only can use gnomead2 to copy files cause rhytmbox or amarok do not detect the player… got some hints for me?
Hi, Betzi. You are correct, the second one should be “ATTRS”, not “ATTR”. I’ve updated this article to reflect this.
You might also try going to the libmtp website (I’m blanking on the URL at the moment, but it should be found easily on Google) and downloading the latest version. The version which ships with Kubuntu is kind of wonky. Some have found that it might be necessary to insert a symbolic link to the mtp7 libs in their computer (see comments above), but I’ve had no problem with the two versions coexisting side by side on my computer.
Good luck.
Ok, i made it out why i didn’t work at my Intrepid Ibex (8.10). It looks like, that with libmtp8 the rulesfiles have changed again, so u got also to use ATTR in the 2nd label rules (LABEL=”lib_usb_device_rules”). Now my zen x-fi 16gb is doing very well with intrepid ibex and amarok!
Thanks for this tutorial and the great help!
For applying this to OTHER devices (e.g., Sansa), plug in your device in MTP mode and go to the Windoze Device Mangler.
Select the device (should be in Portable Devices class), and select it with right-click -> Properties.
Go to the Details pane and select Hardware IDs. The VID is the ATTR{idVendor} (or ATTRS), and the PID is the ATTR{idProduct}.
When using my Creative Zen x-fi under Ubuntu or OpenSuse I have no problems transferring podcasts or music files into my Zen using Banshee or Amarok. But as I wanted to transfer some photos I followed the instructions given and modified the rules.d accordingly. Everything went fine when I did mtpfs aand I could see my directory structure and transfer some files. But when I reopened my Zen, the transferred pictures were nowhere to be found and when I tried to connect it did not work. Here is what I got when I did mtp-detect
charlie@charlie-laptop:~$ mtp-detect
libmtp version: 0.3.0
Listing raw device(s)
No raw devices found.
charlie@charlie-laptop:~$ mtp-detect
libmtp version: 0.3.0
Listing raw device(s)
Device 0 (VID=041e and PID=4162) is UNKNOWN.
Please report this VID/PID and the device model to the libmtp development team
Found 1 device(s):
041e:4162 @ bus 0, dev 15
Attempting to connect device(s)
PTP: Opening session
PTP_ERROR_IO: Trying again after re-initializing USB interface
inep: usb_get_endpoint_status(): Protocol error
outep: usb_get_endpoint_status(): Protocol error
usb_clear_halt() on IN endpoint: Protocol error
usb_clear_halt() on OUT endpoint: Protocol error
usb_clear_halt() on INTERRUPT endpoint: Protocol error
usb_claim_interface(): Bad file descriptor
LIBMTP PANIC: Could not open session on device
Unable to open raw device 0
OK.
Any idea of what went wrong? any advice on what to do? may be I should install the latest version of libmtp (I used libmtp8)
Jean-Claude
The perfect post.
I’m sure you’d have thought about getting an iPod Touch instead. How would using it with either linux hacks or with a virtual Windows compare?
I’ve never used an iPod of any sort, so I can’t really answer that question. My understanding, though, is that more recent iPods can’t work with Linux, and I wouldn’t want to run a Windows virtual machine just for that purpose (especially since the virtualization software I use doesn’t talk to USB ports at all).
Hi, thanks for this guide.
I would like to know if someone’s got a good transcoding tips for mediatomb, something to stream also video from PC and from Youtube etc..
Hi
I got the X-fi a while back and when i moved to linux in june i struggled with my zen, your ideas have been very helpful.
If anyone has instructions on how to connect the X-fi to mediatomb, it would be great if you could post them, or email me at nottellingyou2@gmail.com
Thanks
Sam