Linux and the Sandisk Sansa e200


I recenty received a Sandisk Sansa e260R as a gift.  It came with MS Windows software (no surprise there). Since I rarely run Windows, I spent an evening Googling for information on how to use the Sansa with Linux instead of Windows. I've gathered the information I've gleaned here in hopes that it may be useful to others.

My Sansa is an e260R.  The "R" models have firmware that is tailored to work with the Rhapsody online music store.  At this time I have neither done anything with nor know anything about Rhapsody.

USB Interface

The non-R e200 models have two different USB modes that can be selected under the "settings->USB" menu:
  1. A mode that works with some music-player protocol that Microsoft Invented.
  2. A standard USB mass-storage mode.
AFAICT, the "R" series only has the standard USB mass-storage mode: just plug it in and it shows up as /dev/sdN1.

Music

It plays all of the mp3 files I've tried.  Just put them anywhere under the /music directory and it will find them when you disconnect the USB interface.

Rather than having a filesystem browser, the Sansa reads the id3 tags into a database and then provides a database browser. That means that when you're using the Sansa GUI, it doesn't matter how the /music directory tree is organized: you can put all the .mp3 files in a single directory and you'll see the same thing on the Sansa GUI that you would if the .mp3 files were organized by /music/<artist>/<album>.

I choose to do the latter even though the Sansa doesn't care. I don't use any Linux GUI programs to manage the Sansa, so having .mp3 files organized in subdirectories by artist and album makes it easier for me.

Playlists

The playlists go in the /playlists directory. The Sansa doesn't grok m3u playlists. It expects them to be in PLP/PLA format.  I use filenames ending in .plp, and that seems to work.  My .mp3 collection was created by mp3c which creates .m3u format playlists, so I'm using an AWK script called m3upla.awk by Micah Tischler that converts an m3u into a plp playlist.

Playing tracks in Album order

Some other Sansa models (the "m" series) will play tracks in order by the the id3v2 track tag. The "e" series won't. When the "e" series plays an Album, it plays the tracks in alphabetical order by track name or filename (they're the same on mine, so I'm not sure). That means you have two choices if you want tracks within an Album to play in the correct order:
I wrote a bash script called addtrack.sh that given an .m3u playlist will add id3v2 track tags to the .mp3 files using the id3v2 utility. If you do happen to have an "m" series Sansa that pays attention to track IDs, you might find it useful. Or not.

Video

The Sansa comes with a Windows "media converter" program that will re-encode video files to the format required by the Sansa. I haven't yet used (or even installed) the Sandisk media-converter program.
The Sansa appears to only support playback of video files with one precise format:
The 1.0-rc1 version of mencoder (part of the mplayer project) can almost-but-not-quite encode it that format. There are currently two problems:
  1. The "pcm" audio encoder always encodes the audio stream in little-endian format. The Sansa will refuse to play a little-endian audio stream. The existing options for setting the audio format to big-endian ("-format s16be" and "-av format=s16be") don't work. I've hacked together a patch to mplayer-1.0rc1 that adds a "pcms" audio encoder that swaps bytes in the audiostream resulting in audio that's playable on the Sansa. There was probably a better way to do that (e.g. fix the "format" option), but I know very little about mplayer internals, and adding another encoder seemed the simplest. 
  2. The MJPEG-B video encoder that's part of ffmpeg's libavcodec library that comes with mplayer supports only 420P video. This results in incorrect color when played back on the Sansa (it will, however, play the video). My current work-around is to encode in grayscale: it's not very sexy, but it works.
Here's my sansencode.sh script:
#!/bin/bash

mencoder -ofps 15 \
-vf rotate=1,scale=160:208 \
-ffourcc mjpb \
-ovc lavc -lavcopts vcodec=mjpeg:vbitrate=150:vhq:gray \
-oac pcms -srate 11025 \
-of lavf -lavfopts i_certify_that_my_video_stream_does_not_use_b_frames \
$1 -o $2
I have noticed that with some source material there is an audio/video sync problem. The audio will start out a second or two behind the video and lose about 1 second per minute. It plays the same with xine, mplayer, and the Sansa, so it seems to be an encoding problem not a bug in the Sansa. With other source files (most importantly, MPEG2 files created by MythTV using a PVR-350), the sync is fine. [A 1/2 hour program encodes to about 225MB.]

Photos

Ulrich Pfeifer sent me this python script called bmp16 that can be used to convert photos to the a format that the Sansa will display. It's based on a program found in this forum thread:http://www.python-forum.de/viewtopic.php?p=35924

Rockbox

The Rockbox project is an open-source firmware replacement for mp3 players. A Sansa e200 port is in-progress but has a ways to go yet.

Next on the list of things to do...

Come up with a udev rule that will auto-mount the Sansa when it's plugged in.

Resources


last updated 8 June 2007