The Problem
Getting video working on the Sansa is ridiculously difficult if you are not able to use their archaic Sansa Media Converter Windows software, regardless of your own OS. The Sansa Fuze is in theory a pretty nice media player, which (again in theory) can play mpeg videos in an avi container. In practise, the Sansa expects this video to be in a absurdly specific format. For everything else it displays an error message. To get video into the correct format you must use the converter they have provided.
Sansa Media Converter
Sansa Media Converter is a horrible little video converting program, a true nightmare to use, and the only supported way of getting video to play on the player. It seems to be a rebranded Intervision product, which converts some common video formats to the format used by the Sansa Fuze. It is naturally Windows only and even on Windows it requires the player to be plugged in for conversion to be possible. It doesn't even load on Wine. On a virtual Windows machine it starts but refuses to convert as it can't see the player even if it's plugged in. Also on my old Windows machine it refuses to see the player. Sansa Media Converter represents everything that is wrong in today's computing, and does that faithfully. The pox on the people who wrote it.
Working Example
On the Sansa there is a preloaded video file, which can be used to investigate the format accepted by the player. Also, I have converted some other examples with the Sansa converter on a machine it actually accepted. I have loaded the files into a Windows program abcAvi Tag Editor (works under Wine), which displays a lot of information on avi files. Here's what it has to say about the preloaded example:
[RIFF AVI 20988512]: Audio/Video Interleaved File
[LIST hdrl 64638]: Format Definition Chunk
[avih 56]: Main AVI Header
[dwMicroSecPerFrame]: Microseconds Per Frame: 50000
[dwMaxBytesPerSec]: Maximum Bytes Per Second: 101885
[dwPaddingGranularity]: Padding Granularity (bytes): 1
[dwFlags]: Flags 0x00000810
[AVIF_HASINDEX]: AVI file has 'idx1' chunk
[AVIF_TRUSTCKTYPE]: use chunk type to find key frames
[dwTotalFrames]: Number Of Frames: 4137
[dwInitialFrames]: Numer Of Initial Frames: 0
[dwStreams]: Number Of Streams: 2
[dwSuggestedBufferSize]: Suggested Buffer Size (bytes): 15237
[dwWidth]: Image Width (pixels): 224
[dwHeight]: Image Height (pixels): 176
[LIST strl 32148]: Stream Format Definition Chunk
[strh 56]: Stream Header
[fccType]: Type: vids (Video Data)
[fccHandler]: Handler: 0x00000000 (No Compression <0x00000000>)
[dwFlags]: Flags 0x00000000
[wPriority]: Stream Priority: 0
[wLanguage]: Language: 0 (Undefined)
[dwInitialFrames]: Numer Of Initial Frames: 0
[dwScale]: Stream Scale: 500000
[dwRate]: Stream Rate: 10000000
[dwStart]: Stream Start: 0
[dwLength]: Stream Duration: 4137
[dwSuggestedBufferSize]: Suggested Buffer Size (bytes): 15237
[dwQuality]: Stream Quality (1-10000): 0
[dwSampleSize]: Sample Size: 0
[rcFrame]: Frame Size Of Stream
[wX1]: Top: 0
[wY1]: Bottom: 0
[wX2]: Left: 0
[wY2]: Right: 0
[strf 40]: Video Stream Format
[biSize]: Header Size (bytes): 40
[biWidth]: Image Width (pixels): 224
[biHeight]: Image Height (pixels): 176
[biPlanes]: Number Of Planes: 1
[biBitCount]: Number Of Bits Per Pixel: 32
[biCompression]: Compression Algorithm: DX50 (DivX 5.0 codec 'DX50' <0x30355844>)
[biSizeImage]: Image Size (bytes, 0 = uncompressed): 230400
[biXPelsPerMeter]: Horizontal resolution of target device: 0
[biYPelsPerMeter]: Vertical resolution of target device: 0
[biClrUsed]: Number of colors used (0 = maximum): 0
[biClrImportant]: Number of important colors (0 = all): 0
[indx 32024]: AVI2 (OpenDML) Super Index Chunk
[LIST strl 32138]: Stream Format Definition Chunk
[strh 56]: Stream Header
[fccType]: Type: auds (Audio Data)
[fccHandler]: Handler: 0x00000000 (No Compression <0x00000000>)
[dwFlags]: Flags 0x00000000
[wPriority]: Stream Priority: 0
[wLanguage]: Language: 0 (Undefined)
[dwInitialFrames]: Numer Of Initial Frames: 0
[dwScale]: Stream Scale: 1
[dwRate]: Stream Rate: 16000
[dwStart]: Stream Start: 417
[dwLength]: Stream Duration: 3309595
[dwSuggestedBufferSize]: Suggested Buffer Size (bytes): 2008
[dwQuality]: Stream Quality (1-10000): 0
[dwSampleSize]: Sample Size: 1
[rcFrame]: Frame Size Of Stream
[wX1]: Top: 0
[wY1]: Bottom: 0
[wX2]: Left: 0
[wY2]: Right: 0
[strf 30]: Audio Stream Format
[wFormatTag]: Audio Format: 0x0055 (MPEG-1 Layer 3 (MP3) <0x0055>)
[nChannels]: Number of channels: 2
[nSamplesPerSec]: Frequency of the sample rate (Hz): 44100
[nAvgBytesPerSec]: Average data rate (byte/s): 16000
[nBlockAlign]: Block alignment of the data (bytes): 1
[wBitsPerSample]: Number of bits per sample (0 = undefined): 0
[cbSize]: Size of extra information (bytes): 12
[wID]: Type: 0x0002 (Constant frame size)
[fwFlags]: Flags: 0x0000 (ISO Padding)
[nBlockSize]: Block size (bytes): 417
[nFramesPerBlock]: Number of frames per block: 1
[nCodecDelay]: Codec delay (ms): 0
[indx 32024]: AVI2 (OpenDML) Super Index Chunk
[LIST odml 260]: AVI2 (OpenDML) Format Definition Chunk
[dmlh 248]: Total Number Of Frames AVI2 (OpenDML) 4137
[JUNK 34]: Padding
[LIST movi 20824326]: Audio/Video Data
Skipped
[idx1 99312]: AVI Index Chunk
[LIST INFO 92]: RIFF Textual Informative Details
[ILNG 10]: Language: Undefined
[IRTD 8]: Rating: Unrated
[INAM 12]: Title: sansatesti
[IPRD 6]: Product: Movie
[ISFT 12]: Software Used: IntraAudio
[LIST MID 58]: Movie IDentifier Tags
[TITL 12]: Title: sansatesti
[AGES 8]: Rating: Unrated
[LANG 10]: Language: Undefined
[IDVX 128]: Unknown Tag
[LIST DIVXTAG 128]: IDivX tags
[Movie 32]: Title: sansatest
[Author 28]: Director:
[Year 4]: Creation Date Of Subject:
[Comment 48]: Comments:
[Genre 00000003]: IDivX Genre: 017 (Movie)
[Rated 00000001]: IDivX Rating: 0 (Unrated)
My attempts
I attempted to reproduce a working file with mencoder. I used the following command on the example file. The command does not produce a file acceptable to Sansa.
mencoder -ofps 20 -vf scale=224:176 -ni -noidx -nocache -ovc copy -oac copy -ffourcc DX50 -of avi infile.avi -o outfile.avi
The command does nothing to the audio and video streams, it just copies them to a new file. Only thing that changes is the container part of the file. I manually set the resolution, frame rate and FourCC code for this file. (The noidx option is actually not actually needed, as the example file has an index. That's just something I forgot there.) This resulted in a file described below
[RIFF AVI 20719086]: Audio/Video Interleaved File
[LIST hdrl 306]: Format Definition Chunk
[avih 56]: Main AVI Header
[dwMicroSecPerFrame]: Microseconds Per Frame: 50000
[dwMaxBytesPerSec]: Maximum Bytes Per Second: 0
[dwPaddingGranularity]: Padding Granularity (bytes): 0
[dwFlags]: Flags 0x00000900
[AVIF_ISINTERLEAVED]: AVI file is interleaved
[AVIF_TRUSTCKTYPE]: use chunk type to find key frames
[dwTotalFrames]: Number Of Frames: 0
[dwInitialFrames]: Numer Of Initial Frames: 0
[dwStreams]: Number Of Streams: 2
[dwSuggestedBufferSize]: Suggested Buffer Size (bytes): 0
[dwWidth]: Image Width (pixels): 224
[dwHeight]: Image Height (pixels): 176
[LIST strl 116]: Stream Format Definition Chunk
[strh 56]: Stream Header
[fccType]: Type: vids (Video Data)
[fccHandler]: Handler: DX50 (DivX 5.0 codec 'DX50' <0x30355844>)
[dwFlags]: Flags 0x00000000
[wPriority]: Stream Priority: 0
[wLanguage]: Language: 0 (Undefined)
[dwInitialFrames]: Numer Of Initial Frames: 0
[dwScale]: Stream Scale: 1
[dwRate]: Stream Rate: 20
[dwStart]: Stream Start: 0
[dwLength]: Stream Duration: 4137
[dwSuggestedBufferSize]: Suggested Buffer Size (bytes): 15229
[dwQuality]: Stream Quality (1-10000): 0
[dwSampleSize]: Sample Size: 0
[rcFrame]: Frame Size Of Stream
[wX1]: Top: 0
[wY1]: Bottom: 0
[wX2]: Left: 224
[wY2]: Right: 176
[strf 40]: Video Stream Format
[biSize]: Header Size (bytes): 40
[biWidth]: Image Width (pixels): 224
[biHeight]: Image Height (pixels): 176
[biPlanes]: Number Of Planes: 1
[biBitCount]: Number Of Bits Per Pixel: 32
[biCompression]: Compression Algorithm: DX50 (DivX 5.0 codec 'DX50' <0x30355844>)
[biSizeImage]: Image Size (bytes, 0 = uncompressed): 230400
[biXPelsPerMeter]: Horizontal resolution of target device: 0
[biYPelsPerMeter]: Vertical resolution of target device: 0
[biClrUsed]: Number of colors used (0 = maximum): 0
[biClrImportant]: Number of important colors (0 = all): 0
[LIST strl 106]: Stream Format Definition Chunk
[strh 56]: Stream Header
[fccType]: Type: auds (Audio Data)
[fccHandler]: Handler: U (Unknown Four Character Code 'U' <0x00000055>)
[dwFlags]: Flags 0x00000000
[wPriority]: Stream Priority: 0
[wLanguage]: Language: 0 (Undefined)
[dwInitialFrames]: Numer Of Initial Frames: 0
[dwScale]: Stream Scale: 1
[dwRate]: Stream Rate: 16000
[dwStart]: Stream Start: 417
[dwLength]: Stream Duration: 3309595
[dwSuggestedBufferSize]: Suggested Buffer Size (bytes): 8000
[dwQuality]: Stream Quality (1-10000): 0
[dwSampleSize]: Sample Size: 1
[rcFrame]: Frame Size Of Stream
[wX1]: Top: 0
[wY1]: Bottom: 0
[wX2]: Left: 0
[wY2]: Right: 0
[strf 30]: Audio Stream Format
[wFormatTag]: Audio Format: 0x0055 (MPEG-1 Layer 3 (MP3) <0x0055>)
[nChannels]: Number of channels: 2
[nSamplesPerSec]: Frequency of the sample rate (Hz): 44100
[nAvgBytesPerSec]: Average data rate (byte/s): 16000
[nBlockAlign]: Block alignment of the data (bytes): 1
[wBitsPerSample]: Number of bits per sample (0 = undefined): 0
[cbSize]: Size of extra information (bytes): 12
[wID]: Type: 0x0002 (Constant frame size)
[fwFlags]: Flags: 0x0000 (ISO Padding)
[nBlockSize]: Block size (bytes): 417
[nFramesPerBlock]: Number of frames per block: 1
[nCodecDelay]: Codec delay (ms): 0
[LIST INFO 42]: RIFF Textual Informative Details
[ISFT 30]: Software Used: MEncoder 2:1.0~rc2-0ubuntu13
[JUNK 3712]: Padding
[LIST movi 20714990]: Audio/Video Data
Skipped
There are some notable differences to the working example file. I suspect the most important one is "AVIF_ISINTERLEAVED" flag, which means that this avi file has interleaved video and audio. It is possible that this may be too much for the Sansa Fuze to handle.
Mencoder/Mplayer has, by the way, an option called -ni, which forces non-interleaved mode for reading files. Unfortunately it doesn's seem to affect decoding.
It is worth mentioning that the Sansa isn't picky about every little detail. I changed the FourCC code, for instance, on the preloaded clip to some false value and the clip still played.
VirtualDub
There is this Windows program called VirtualDub, which has an option for turning of interleaving avi files. I tried it under Wine. The program worked, but unfortunately, the file it produced had other differences to the examples. I haven't found options to fix those differences in the program
Possible Solutions
I'm no expert when it comes to video encoding, so currently I have no ideas how to move forward. I guess there might be some program somewhere that can reproduce Sansa's format, or perhaps it could be possible to make a non-interleaved version of avi codecs and try those.
For reference you might want to see further information on the video clip and this discussion.
Any help with this would be appreciated.